|
1 | 1 | apiVersion: apps/v1 |
| 2 | +# TODO may become a daemonset now that we run this on hostnetwork |
| 3 | +# TODO or just a fully functional sidecar mounting memory in pod.gotpl.yaml |
2 | 4 | kind: Deployment |
3 | 5 | metadata: |
4 | 6 | name: dedicated-event-etcd |
5 | 7 | namespace: openshift-etcd |
6 | 8 | labels: |
7 | 9 | app: dedicated-event-etcd |
8 | 10 | k8s-app: dedicated-event-etcd |
9 | | - etcd: "true" |
10 | 11 | spec: |
11 | 12 | replicas: 1 |
12 | 13 | selector: |
13 | 14 | matchLabels: |
14 | 15 | app: dedicated-event-etcd |
15 | 16 | k8s-app: dedicated-event-etcd |
16 | | - etcd: "true" |
17 | 17 | template: |
18 | 18 | metadata: |
19 | 19 | name: dedicated-event-etcd |
20 | 20 | annotations: |
21 | | - kubectl.kubernetes.io/default-container: etcd |
| 21 | + kubectl.kubernetes.io/default-container: etcdctl |
22 | 22 | labels: |
23 | 23 | app: dedicated-event-etcd |
24 | 24 | k8s-app: dedicated-event-etcd |
25 | | - etcd: "true" |
26 | 25 | spec: |
27 | 26 | hostNetwork: true |
28 | | - priority: 2000001000 |
29 | | - priorityClassName: system-node-critical |
| 27 | + nodeSelector: |
| 28 | + node-role.kubernetes.io/master: "" |
30 | 29 | tolerations: |
31 | | - - operator: "Exists" |
| 30 | + - operator: "Exists" |
32 | 31 | containers: |
| 32 | + - name: etcdctl |
| 33 | + # image: {{.Image}} |
| 34 | + # harcoded 4.20.0 |
| 35 | + image: "quay.io/openshift-release-dev/ocp-v4.0-art-dev@sha256:3654c629d9d8c9a07b481f6d9f8b36f77922f4b196b5e9dd4979957821dbd4b2" |
| 36 | + imagePullPolicy: IfNotPresent |
| 37 | + terminationMessagePolicy: FallbackToLogsOnError |
| 38 | + command: |
| 39 | + - "/bin/bash" |
| 40 | + - "-c" |
| 41 | + - "trap TERM INT; sleep infinity & wait" |
| 42 | + volumeMounts: |
| 43 | + - mountPath: /var/lib/etcd/ |
| 44 | + name: data-dir |
| 45 | + - mountPath: /etcd-all-bundles |
| 46 | + name: etcd-ca-bundle |
| 47 | + - mountPath: /etcd-all-certs |
| 48 | + name: etcd-all-certs |
| 49 | + env: |
| 50 | + # export ETCDCTL_ENDPOINTS="https://${MY_POD_IP}:20379" |
| 51 | + # export ETCDCTL_CACERT="/etcd-all-bundles/ca-bundle.crt" |
| 52 | + # export ETCDCTL_CERT="/etcd-all-certs/etcd-peer-${MY_NODE_NAME}.crt" |
| 53 | + # export ETCDCTL_KEY="/etcd-all-certs/etcd-peer-${MY_NODE_NAME}.key" |
| 54 | + |
| 55 | + - name: MY_POD_IP |
| 56 | + valueFrom: |
| 57 | + fieldRef: |
| 58 | + fieldPath: status.podIP |
| 59 | + - name: MY_NODE_NAME |
| 60 | + valueFrom: |
| 61 | + fieldRef: |
| 62 | + fieldPath: spec.nodeName |
| 63 | + - name: ETCD_DATA_DIR |
| 64 | + value: "/var/lib/etcd" |
| 65 | + - name: ETCDCTL_ENDPOINTS |
| 66 | + value: "https://${MY_POD_IP}:20379" |
| 67 | + - name: ETCDCTL_CACERT |
| 68 | + value: "/etcd-all-bundles/ca-bundle.crt" |
| 69 | + - name: ETCDCTL_CERT |
| 70 | + value: "/etcd-all-certs/etcd-peer-${MY_NODE_NAME}.crt" |
| 71 | + - name: ETCDCTL_KEY |
| 72 | + value: "/etcd-all-certs/etcd-peer-${MY_NODE_NAME}.key" |
33 | 73 | - name: etcd |
34 | | - image: quay.io/openshift-release-dev/ocp-v4.0-art-dev@sha256:placeholder |
| 74 | + # image: {{.Image}} |
| 75 | + # harcoded 4.20.0 |
| 76 | + image: "quay.io/openshift-release-dev/ocp-v4.0-art-dev@sha256:3654c629d9d8c9a07b481f6d9f8b36f77922f4b196b5e9dd4979957821dbd4b2" |
35 | 77 | imagePullPolicy: IfNotPresent |
36 | 78 | terminationMessagePolicy: FallbackToLogsOnError |
| 79 | + env: |
| 80 | + - name: MY_POD_IP |
| 81 | + valueFrom: |
| 82 | + fieldRef: |
| 83 | + fieldPath: status.podIP |
| 84 | + - name: MY_NODE_NAME |
| 85 | + valueFrom: |
| 86 | + fieldRef: |
| 87 | + fieldPath: spec.nodeName |
37 | 88 | command: |
38 | 89 | - /bin/sh |
39 | 90 | - -c |
40 | 91 | - | |
41 | 92 | #!/bin/sh |
42 | 93 | set -euo pipefail |
| 94 | + set -x |
| 95 | + |
| 96 | + export ETCD_NAME=events-etcd |
43 | 97 |
|
44 | | - export ETCD_NAME=${NODE_NODE_ENVVAR_NAME_ETCD_NAME} |
| 98 | + echo "----------------" |
45 | 99 | env | grep ETCD | grep -v NODE |
46 | | -
|
47 | | - set -x |
48 | | - # See https://etcd.io/docs/v3.4.0/tuning/ for why we use ionice |
49 | | - exec nice -n -19 ionice -c2 -n0 etcd \ |
| 100 | + echo "----------------" |
| 101 | + echo "$MY_NODE_NAME" |
| 102 | + echo "$MY_POD_IP" |
| 103 | + echo "----------------" |
| 104 | + ls -l /etcd-all-certs |
| 105 | + echo "----------------" |
| 106 | + ls -l /etcd-all-bundles |
| 107 | + echo "----------------" |
| 108 | + |
| 109 | + etcd \ |
| 110 | + --data-dir=/var/lib/etcd \ |
50 | 111 | --logger=zap \ |
51 | 112 | --log-level=WARN \ |
52 | 113 | --snapshot-count=10000 \ |
53 | | - --initial-advertise-peer-urls=https://${NODE_NODE_ENVVAR_NAME_IP}:2380 \ |
54 | | - --cert-file=/etc/kubernetes/static-pod-certs/secrets/etcd-all-certs/etcd-serving-NODE_NAME.crt \ |
55 | | - --key-file=/etc/kubernetes/static-pod-certs/secrets/etcd-all-certs/etcd-serving-NODE_NAME.key \ |
56 | | - --trusted-ca-file=/etc/kubernetes/static-pod-certs/configmaps/etcd-all-bundles/server-ca-bundle.crt \ |
| 114 | + --quota-backend-bytes 8589934592 \ |
| 115 | + --cert-file="/etcd-all-certs/etcd-serving-${MY_NODE_NAME}.crt" \ |
| 116 | + --key-file="/etcd-all-certs/etcd-serving-${MY_NODE_NAME}.key" \ |
| 117 | + --trusted-ca-file="/etcd-all-bundles/ca-bundle.crt" \ |
57 | 118 | --client-cert-auth=true \ |
58 | | - --peer-cert-file=/etc/kubernetes/static-pod-certs/secrets/etcd-all-certs/etcd-peer-NODE_NAME.crt \ |
59 | | - --peer-key-file=/etc/kubernetes/static-pod-certs/secrets/etcd-all-certs/etcd-peer-NODE_NAME.key \ |
60 | | - --peer-trusted-ca-file=/etc/kubernetes/static-pod-certs/configmaps/etcd-all-bundles/server-ca-bundle.crt \ |
| 119 | + --initial-cluster="${ETCD_NAME}=https://${MY_POD_IP}:20380" \ |
| 120 | + --initial-advertise-peer-urls="https://${MY_POD_IP}:20380" \ |
| 121 | + --listen-peer-urls="https://${MY_POD_IP}:20380" \ |
| 122 | + --peer-cert-file="/etcd-all-certs/etcd-peer-${MY_NODE_NAME}.crt"\ |
| 123 | + --peer-key-file="/etcd-all-certs/etcd-peer-${MY_NODE_NAME}.key" \ |
| 124 | + --peer-trusted-ca-file="/etcd-all-bundles/ca-bundle.crt" \ |
61 | 125 | --peer-client-cert-auth=true \ |
62 | | - --advertise-client-urls=https://${NODE_NODE_ENVVAR_NAME_IP}:2379 \ |
63 | | - --listen-client-urls=https://0.0.0.0:2379 \ |
64 | | - --listen-peer-urls=https://0.0.0.0:2380 |
65 | | - |
| 126 | + --advertise-client-urls=https://${MY_POD_IP}:20379 \ |
| 127 | + --listen-client-urls=https://0.0.0.0:20379 |
| 128 | +
|
66 | 129 | ports: |
67 | | - - containerPort: 2379 |
| 130 | + - containerPort: 20379 |
68 | 131 | name: etcd |
69 | 132 | protocol: TCP |
| 133 | + - containerPort: 20380 |
| 134 | + name: etcd-peer |
| 135 | + protocol: TCP |
70 | 136 | resources: |
71 | | - requests: |
72 | | - memory: 5Gi |
73 | 137 | limits: |
74 | | - memory: 10Gi |
| 138 | + memory: 8Gi |
75 | 139 | securityContext: |
76 | 140 | privileged: true |
77 | 141 | readOnlyRootFilesystem: true |
78 | 142 | volumeMounts: |
79 | | - - mountPath: /etc/kubernetes/manifests |
80 | | - name: static-pod-dir |
81 | | - - mountPath: /etc/kubernetes/static-pod-resources |
82 | | - name: resource-dir |
83 | | - - mountPath: /etc/kubernetes/static-pod-certs |
84 | | - name: cert-dir |
85 | | - - mountPath: /tmp |
86 | | - name: tmp-dir |
| 143 | + # TODO inject etcd-all-certs and etcd-all-bundles |
| 144 | + # TODO this is going to be annoying, because the certs are not issued for the pod IP |
| 145 | + # and the peer cert is the client cert IIRC, so might make sense to schedule on the |
| 146 | + # existing CP anyway and mount the static pods for the respective node name via downward API |
87 | 147 | - mountPath: /var/lib/etcd/ |
88 | 148 | name: data-dir |
| 149 | + - mountPath: /etcd-all-bundles |
| 150 | + name: etcd-ca-bundle |
| 151 | + - mountPath: /etcd-all-certs |
| 152 | + name: etcd-all-certs |
89 | 153 | volumes: |
90 | | - - hostPath: |
91 | | - path: /etc/kubernetes/manifests |
92 | | - name: static-pod-dir |
93 | | - - hostPath: |
94 | | - path: /etc/kubernetes/static-pod-resources/etcd-pod-REVISION |
95 | | - name: resource-dir |
96 | | - - hostPath: |
97 | | - path: /etc/kubernetes/static-pod-resources/etcd-certs |
98 | | - name: cert-dir |
99 | | - - emptyDir: {} |
100 | | - name: tmp-dir |
| 154 | + - configMap: |
| 155 | + name: etcd-ca-bundle |
| 156 | + name: etcd-ca-bundle |
| 157 | + - secret: |
| 158 | + secretName: etcd-all-certs |
| 159 | + name: etcd-all-certs |
101 | 160 | - name: data-dir |
102 | 161 | emptyDir: |
103 | 162 | medium: Memory |
104 | | - sizeLimit: 5Gi |
| 163 | + sizeLimit: 8Gi |
105 | 164 |
|
0 commit comments