Skip to content

Commit

Permalink
add an init container to stop the pod with bad revision
Browse files Browse the repository at this point in the history
  • Loading branch information
alaypatel07 committed Mar 27, 2020
1 parent de1b88f commit d514d93
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 0 deletions.
23 changes: 23 additions & 0 deletions bindata/etcd/pod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,29 @@ metadata:
revision: "REVISION"
spec:
initContainers:
- name: etcd-ensure-env-vars
image: ${IMAGE}
imagePullPolicy: IfNotPresent
terminationMessagePolicy: FallbackToLogsOnError
command:
- /bin/sh
- -c
- |
#!/bin/sh
set -euo pipefail
: "${NODE_NODE_ENVVAR_NAME_ETCD_URL_HOST?not set}"
: "${NODE_NODE_ENVVAR_NAME_ETCD_NAME?not set}"
: "${NODE_NODE_ENVVAR_NAME_IP?not set}"
resources:
requests:
memory: 60Mi
cpu: 30m
securityContext:
privileged: true
env:
${COMPUTED_ENV_VARS}
- name: etcd-resources-copy
image: ${IMAGE}
imagePullPolicy: IfNotPresent
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,13 @@ func (c *ClusterMemberController) getEtcdPodToAddToMembership() (*corev1.Pod, er
continue
}

// if pod is not initialized we dont know the env is correct
for _, cond := range pod.Status.Conditions {
if cond.Type == corev1.PodInitialized && cond.Status == corev1.ConditionFalse {
continue
}
}

// check to see if this member is updating from 4.3
etcdMember, err := c.etcdClient.GetMember("etcd-member-" + pod.Spec.NodeName)
switch {
Expand Down
23 changes: 23 additions & 0 deletions pkg/operator/etcd_assets/bindata.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit d514d93

Please sign in to comment.