From 49c8ed802a9e9c1ba0153c2a6575bcc68d578928 Mon Sep 17 00:00:00 2001 From: Guangya Liu Date: Sat, 6 May 2017 17:55:09 +0800 Subject: [PATCH] Put initContainers to PodSpec for some statefulset examples. --- .../cockroachdb/cockroachdb-statefulset.yaml | 65 ++++++--------- .../statefulset/cockroachdb/statefulset.yaml | 63 ++++++-------- .../statefulset/mysql-galera/statefulset.yaml | 75 +++++++---------- .../statefulset/redis/statefulset.yaml | 76 +++++++---------- .../statefulset/zookeeper/statefulset.yaml | 82 ++++++++----------- 5 files changed, 142 insertions(+), 219 deletions(-) diff --git a/examples/cockroachdb/cockroachdb-statefulset.yaml b/examples/cockroachdb/cockroachdb-statefulset.yaml index 6e1ab97c025..7bb06e7d628 100644 --- a/examples/cockroachdb/cockroachdb-statefulset.yaml +++ b/examples/cockroachdb/cockroachdb-statefulset.yaml @@ -77,46 +77,33 @@ spec: metadata: labels: app: cockroachdb - annotations: - # Init containers are run only once in the lifetime of a pod, before - # it's started up for the first time. It has to exit successfully - # before the pod's main containers are allowed to start. - # This particular init container does a DNS lookup for other pods in - # the set to help determine whether or not a cluster already exists. - # If any other pods exist, it creates a file in the cockroach-data - # directory to pass that information along to the primary container that - # has to decide what command-line flags to use when starting CockroachDB. - # This only matters when a pod's persistent volume is empty - if it has - # data from a previous execution, that data will always be used. - pod.alpha.kubernetes.io/init-containers: '[ - { - "name": "bootstrap", - "image": "cockroachdb/cockroach-k8s-init:0.1", - "imagePullPolicy": "IfNotPresent", - "args": [ - "-on-start=/on-start.sh", - "-service=cockroachdb" - ], - "env": [ - { - "name": "POD_NAMESPACE", - "valueFrom": { - "fieldRef": { - "apiVersion": "v1", - "fieldPath": "metadata.namespace" - } - } - } - ], - "volumeMounts": [ - { - "name": "datadir", - "mountPath": "/cockroach/cockroach-data" - } - ] - } - ]' spec: + # Init containers are run only once in the lifetime of a pod, before + # it's started up for the first time. It has to exit successfully + # before the pod's main containers are allowed to start. + # This particular init container does a DNS lookup for other pods in + # the set to help determine whether or not a cluster already exists. + # If any other pods exist, it creates a file in the cockroach-data + # directory to pass that information along to the primary container that + # has to decide what command-line flags to use when starting CockroachDB. + # This only matters when a pod's persistent volume is empty - if it has + # data from a previous execution, that data will always be used. + initContainers: + - name: bootstrap + image: cockroachdb/cockroach-k8s-init:0.1 + imagePullPolicy: IfNotPresent + args: + - "-on-start=/on-start.sh" + - "-service=cockroachdb" + env: + - name: POD_NAMESPACE + valueFrom: + fieldRef: + apiVersion: v1 + fieldPath: metadata.namespace + volumeMounts: + - name: datadir + mountPath: "/cockroach/cockroach-data" affinity: podAntiAffinity: preferredDuringSchedulingIgnoredDuringExecution: diff --git a/test/e2e/testing-manifests/statefulset/cockroachdb/statefulset.yaml b/test/e2e/testing-manifests/statefulset/cockroachdb/statefulset.yaml index 06d7e140742..4632fb165d6 100644 --- a/test/e2e/testing-manifests/statefulset/cockroachdb/statefulset.yaml +++ b/test/e2e/testing-manifests/statefulset/cockroachdb/statefulset.yaml @@ -9,45 +9,32 @@ spec: metadata: labels: app: cockroachdb - annotations: - # Init containers are run only once in the lifetime of a pod, before - # it's started up for the first time. It has to exit successfully - # before the pod's main containers are allowed to start. - # This particular init container does a DNS lookup for other pods in - # the set to help determine whether or not a cluster already exists. - # If any other pods exist, it creates a file in the cockroach-data - # directory to pass that information along to the primary container that - # has to decide what command-line flags to use when starting CockroachDB. - # This only matters when a pod's persistent volume is empty - if it has - # data from a previous execution, that data will always be used. - pod.alpha.kubernetes.io/init-containers: '[ - { - "name": "bootstrap", - "image": "cockroachdb/cockroach-k8s-init:0.1", - "args": [ - "-on-start=/on-start.sh", - "-service=cockroachdb" - ], - "env": [ - { - "name": "POD_NAMESPACE", - "valueFrom": { - "fieldRef": { - "apiVersion": "v1", - "fieldPath": "metadata.namespace" - } - } - } - ], - "volumeMounts": [ - { - "name": "datadir", - "mountPath": "/cockroach/cockroach-data" - } - ] - } - ]' spec: + # Init containers are run only once in the lifetime of a pod, before + # it's started up for the first time. It has to exit successfully + # before the pod's main containers are allowed to start. + # This particular init container does a DNS lookup for other pods in + # the set to help determine whether or not a cluster already exists. + # If any other pods exist, it creates a file in the cockroach-data + # directory to pass that information along to the primary container that + # has to decide what command-line flags to use when starting CockroachDB. + # This only matters when a pod's persistent volume is empty - if it has + # data from a previous execution, that data will always be used. + initContainers: + - name: bootstrap + image: cockroachdb/cockroach-k8s-init:0.1 + args: + - "-on-start=/on-start.sh" + - "-service=cockroachdb" + env: + - name: POD_NAMESPACE + valueFrom: + fieldRef: + apiVersion: v1 + fieldPath: metadata.namespace + volumeMounts: + - name: datadir + mountPath: "/cockroach/cockroach-data" containers: - name: cockroachdb # Runs the master branch. Not recommended for production, but since diff --git a/test/e2e/testing-manifests/statefulset/mysql-galera/statefulset.yaml b/test/e2e/testing-manifests/statefulset/mysql-galera/statefulset.yaml index f80d1c82bd9..e0f4c8ec04f 100644 --- a/test/e2e/testing-manifests/statefulset/mysql-galera/statefulset.yaml +++ b/test/e2e/testing-manifests/statefulset/mysql-galera/statefulset.yaml @@ -9,53 +9,36 @@ spec: metadata: labels: app: mysql - annotations: - pod.alpha.kubernetes.io/init-containers: '[ - { - "name": "install", - "image": "gcr.io/google_containers/galera-install:0.1", - "imagePullPolicy": "Always", - "args": ["--work-dir=/work-dir"], - "volumeMounts": [ - { - "name": "workdir", - "mountPath": "/work-dir" - }, - { - "name": "config", - "mountPath": "/etc/mysql" - } - ] - }, - { - "name": "bootstrap", - "image": "debian:jessie", - "command": ["/work-dir/peer-finder"], - "args": ["-on-start=\"/work-dir/on-start.sh\"", "-service=galera"], - "env": [ - { - "name": "POD_NAMESPACE", - "valueFrom": { - "fieldRef": { - "apiVersion": "v1", - "fieldPath": "metadata.namespace" - } - } - } - ], - "volumeMounts": [ - { - "name": "workdir", - "mountPath": "/work-dir" - }, - { - "name": "config", - "mountPath": "/etc/mysql" - } - ] - } - ]' spec: + initContainers: + - name: install + image: gcr.io/google_containers/galera-install:0.1 + imagePullPolicy: Always + args: + - "--work-dir=/work-dir" + volumeMounts: + - name: workdir + mountPath: "/work-dir" + - name: config + mountPath: "/etc/mysql" + - name: bootstrap + image: debian:jessie + command: + - "/work-dir/peer-finder" + args: + - -on-start="/work-dir/on-start.sh" + - "-service=galera" + env: + - name: POD_NAMESPACE + valueFrom: + fieldRef: + apiVersion: v1 + fieldPath: metadata.namespace + volumeMounts: + - name: workdir + mountPath: "/work-dir" + - name: config + mountPath: "/etc/mysql" containers: - name: mysql image: gcr.io/google_containers/mysql-galera:e2e diff --git a/test/e2e/testing-manifests/statefulset/redis/statefulset.yaml b/test/e2e/testing-manifests/statefulset/redis/statefulset.yaml index ff770733df9..1779b502a72 100644 --- a/test/e2e/testing-manifests/statefulset/redis/statefulset.yaml +++ b/test/e2e/testing-manifests/statefulset/redis/statefulset.yaml @@ -9,53 +9,37 @@ spec: metadata: labels: app: redis - annotations: - pod.alpha.kubernetes.io/init-containers: '[ - { - "name": "install", - "image": "gcr.io/google_containers/redis-install-3.2.0:e2e", - "imagePullPolicy": "Always", - "args": ["--install-into=/opt", "--work-dir=/work-dir"], - "volumeMounts": [ - { - "name": "opt", - "mountPath": "/opt" - }, - { - "name": "workdir", - "mountPath": "/work-dir" - } - ] - }, - { - "name": "bootstrap", - "image": "debian:jessie", - "command": ["/work-dir/peer-finder"], - "args": ["-on-start=\"/work-dir/on-start.sh\"", "-service=redis"], - "env": [ - { - "name": "POD_NAMESPACE", - "valueFrom": { - "fieldRef": { - "apiVersion": "v1", - "fieldPath": "metadata.namespace" - } - } - } - ], - "volumeMounts": [ - { - "name": "opt", - "mountPath": "/opt" - }, - { - "name": "workdir", - "mountPath": "/work-dir" - } - ] - } - ]' spec: + initContainers: + - name: install + image: gcr.io/google_containers/redis-install-3.2.0:e2e + imagePullPolicy: Always + args: + - "--install-into=/opt" + - "--work-dir=/work-dir" + volumeMounts: + - name: opt + mountPath: "/opt" + - name: workdir + mountPath: "/work-dir" + - name: bootstrap + image: debian:jessie + command: + - "/work-dir/peer-finder" + args: + - -on-start="/work-dir/on-start.sh" + - "-service=redis" + env: + - name: POD_NAMESPACE + valueFrom: + fieldRef: + apiVersion: v1 + fieldPath: metadata.namespace + volumeMounts: + - name: opt + mountPath: "/opt" + - name: workdir + mountPath: "/work-dir" containers: - name: redis image: debian:jessie diff --git a/test/e2e/testing-manifests/statefulset/zookeeper/statefulset.yaml b/test/e2e/testing-manifests/statefulset/zookeeper/statefulset.yaml index 3f454ebd9f9..f9bf9b7786b 100644 --- a/test/e2e/testing-manifests/statefulset/zookeeper/statefulset.yaml +++ b/test/e2e/testing-manifests/statefulset/zookeeper/statefulset.yaml @@ -9,57 +9,39 @@ spec: metadata: labels: app: zk - annotations: - pod.alpha.kubernetes.io/init-containers: '[ - { - "name": "install", - "image": "gcr.io/google_containers/zookeeper-install-3.5.0-alpha:e2e", - "imagePullPolicy": "Always", - "args": ["--install-into=/opt", "--work-dir=/work-dir"], - "volumeMounts": [ - { - "name": "opt", - "mountPath": "/opt/" - }, - { - "name": "workdir", - "mountPath": "/work-dir" - } - ] - }, - { - "name": "bootstrap", - "image": "java:openjdk-8-jre", - "command": ["/work-dir/peer-finder"], - "args": ["-on-start=\"/work-dir/on-start.sh\"", "-service=zk"], - "env": [ - { - "name": "POD_NAMESPACE", - "valueFrom": { - "fieldRef": { - "apiVersion": "v1", - "fieldPath": "metadata.namespace" - } - } - } - ], - "volumeMounts": [ - { - "name": "opt", - "mountPath": "/opt" - }, - { - "name": "workdir", - "mountPath": "/work-dir" - }, - { - "name": "datadir", - "mountPath": "/tmp/zookeeper" - } - ] - } - ]' spec: + initContainers: + - name: install + image: gcr.io/google_containers/zookeeper-install-3.5.0-alpha:e2e + imagePullPolicy: Always + args: + - "--install-into=/opt" + - "--work-dir=/work-dir" + volumeMounts: + - name: opt + mountPath: "/opt/" + - name: workdir + mountPath: "/work-dir" + - name: bootstrap + image: java:openjdk-8-jre + command: + - "/work-dir/peer-finder" + args: + - -on-start="/work-dir/on-start.sh" + - "-service=zk" + env: + - name: POD_NAMESPACE + valueFrom: + fieldRef: + apiVersion: v1 + fieldPath: metadata.namespace + volumeMounts: + - name: opt + mountPath: "/opt" + - name: workdir + mountPath: "/work-dir" + - name: datadir + mountPath: "/tmp/zookeeper" containers: - name: zk image: java:openjdk-8-jre