私はhttps://www.mongodb.com/blog/post/running-mongodb-as-a-microservice-with-docker-and-kubernetesに続き、Google CloudアカウントでLoadBalancerサービスとReplication Controllerを使用して単一のmongodbインスタンスを実行しようとしました。Kubernetes with MongoDb
---
apiVersion: v1
kind: Service
metadata:
name: mongo-svc-a
labels:
name: mongo-svc-a
spec:
type: LoadBalancer
ports:
- port: 27017
targetPort: 27017
protocol: TCP
name: mongo-svc-a
selector:
name: mongo-node1
instance: rod
---
apiVersion: v1
kind: ReplicationController
metadata:
name: mongo-rc1
labels:
name: mongo-rc
spec:
replicas: 1
selector:
name: mongo-node1
template:
metadata:
labels:
name: mongo-node1
instance: rod
spec:
containers:
- name: mongo-node1
image: mongo
ports:
- containerPort: 27017
volumeMounts:
- name: mongo-persistent-storage1
mountPath: /data/db
volumes:
- name: mongo-persistent-storage1
gcePersistentDisk:
pdName: mongodb-disk1-in-cluster1
fsType: ext4
作成されたサービス、レプリケーション・コントローラおよびポッドの詳細は次のとおりです。以下の
はYAMLファイルです。すべてはうまくいくようです。
$ kubectl describe service mongo-svc-a
Name: mongo-svc-a
Namespace: default
Labels: name=mongo-svc-a
Selector: instance=rod,name=mongo-node1
Type: LoadBalancer
IP: 10.3.241.11
LoadBalancer Ingress: 104.198.236.2
Port: mongo-svc-a 27017/TCP
NodePort: mongo-svc-a 31808/TCP
Endpoints: 10.0.0.3:27017
Session Affinity: None
No events.
$ kubectl describe rc mongo-rc1
Name: mongo-rc1
Namespace: default
Image(s): mongo
Selector: name=mongo-node1
Labels: name=mongo-rc
Replicas: 1 current/1 desired
Pods Status: 1 Running/0 Waiting/0 Succeeded/0 Failed
Volumes:
mongo-persistent-storage1:
Type: GCEPersistentDisk (a Persistent Disk resource in Google Compute Engine)
PDName: mongodb-disk1-in-cluster1
FSType: ext4
Partition: 0
ReadOnly: false
No events.
$ kubectl describe pod mongo-rc1-h0j8r
Name: mongo-rc1-h0j8r
Namespace: default
Node: gke-cluster1-default-pool-d58b6c05-74fq/10.128.0.6
Start Time: Sat, 11 Feb 2017 18:43:00 +0530
Labels: instance=rod
name=mongo-node1
Status: Running
IP: 10.0.0.3
Controllers: ReplicationController/mongo-rc1
Containers:
mongo-node1:
Container ID: docker://9f28e482d3806b74f7f595c47e6c7940c2313e95860db13d137ad6eaa88bb341
Image: mongo
Image ID: docker://sha256:ad974e767ec4f06945b1e7ffdfc57bd10e06baf66cdaf5a003e0e6a36924e30b
Port: 27017/TCP
Requests:
cpu: 100m
State: Running
Started: Sat, 11 Feb 2017 18:45:37 +0530
Ready: True
Restart Count: 0
Volume Mounts:
/data/db from mongo-persistent-storage1 (rw)
/var/run/secrets/kubernetes.io/serviceaccount from default-token-3wfv3 (ro)
Environment Variables: <none>
Conditions:
Type Status
Initialized True
Ready True
PodScheduled True
Volumes:
mongo-persistent-storage1:
Type: GCEPersistentDisk (a Persistent Disk resource in Google Compute Engine)
PDName: mongodb-disk1-in-cluster1
FSType: ext4
Partition: 0
ReadOnly: false
default-token-3wfv3:
Type: Secret (a volume populated by a Secret)
SecretName: default-token-3wfv3
QoS Class: Burstable
Tolerations: <none>
No events.
しかし、私は、リモート、新しく作成されたmonogdbインスタンスにmongo --hostname <Extenal_IP_of_the_service>
を接続しようとすると、私は接続することができません。私は構成が大丈夫だと思う。どんな助けもありがとう。おかげで、
- Pavan
を
は、次のチュートリアルに従っ問題を再現する。 [アプリケーションのトラブルシューティングガイド](https://kubernetes.io/docs/user-guide/application-troubleshooting/)を開始するクーベルネット上で動作するアプリケーションの場合は、適切な場合があります。途中でエラーが見つかった場合は、調査結果を使って質問を編集してください。 – pagidありがとうございます。ログを追加します。 –