Created
December 30, 2018 14:05
-
-
Save Wolke/14e15a52f5bc972b2231596d181c9e28 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 和google qwlke範例差在 command 和 image/ mongo 3.4版 | |
# kubectl exec -ti mongo-0 mongo | |
# rs.initiate() | |
# rs.conf() | |
# mongo mongodb://mongo-0.mongo,mongo-1.mongo,mongo-2.mongo:27017/test | |
# | |
--- | |
apiVersion: v1 | |
kind: Service | |
metadata: | |
name: mongo | |
labels: | |
name: mongo | |
spec: | |
ports: | |
- port: 27017 | |
targetPort: 27017 | |
clusterIP: None | |
selector: | |
role: mongo | |
--- | |
apiVersion: apps/v1beta1 | |
kind: StatefulSet | |
metadata: | |
name: mongo | |
spec: | |
serviceName: "mongo" | |
replicas: 3 | |
template: | |
metadata: | |
labels: | |
role: mongo | |
environment: test | |
spec: | |
terminationGracePeriodSeconds: 10 | |
containers: | |
- name: mongo | |
image: mongo:3.4 | |
command: | |
- mongod | |
- "--replSet" | |
- rs0 | |
- "--bind_ip" | |
- 0.0.0.0 | |
- "--smallfiles" | |
- "--noprealloc" | |
ports: | |
- containerPort: 27017 | |
volumeMounts: | |
- name: mongo-persistent-storage | |
mountPath: /data/db | |
- name: mongo-sidecar | |
image: cvallance/mongo-k8s-sidecar | |
env: | |
- name: MONGO_SIDECAR_POD_LABELS | |
value: "role=mongo,environment=test" | |
volumeClaimTemplates: | |
- metadata: | |
name: mongo-persistent-storage | |
annotations: | |
volume.beta.kubernetes.io/storage-class: "fast" | |
spec: | |
accessModes: [ "ReadWriteOnce" ] | |
resources: | |
requests: | |
storage: 2Gi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment