|
| 1 | +package spegel |
| 2 | + |
| 3 | +import ( |
| 4 | + appsv1 "k8s.io/api/apps/v1" |
| 5 | + "k8s.io/api/core/v1" |
| 6 | +) |
| 7 | + |
| 8 | +#DaemonSetList: appsv1.#DaemonSetList & { |
| 9 | + apiVersion: "apps/v1" |
| 10 | + kind: "DaemonSetList" |
| 11 | + items: [...{ |
| 12 | + apiVersion: "apps/v1" |
| 13 | + kind: "DaemonSet" |
| 14 | + }] |
| 15 | +} |
| 16 | + |
| 17 | +#DaemonSetList: items: [{ |
| 18 | + spec: { |
| 19 | + selector: matchLabels: "app.kubernetes.io/name": #Name |
| 20 | + template: { |
| 21 | + metadata: labels: "app.kubernetes.io/name": #Name |
| 22 | + spec: { |
| 23 | + volumes: [{ |
| 24 | + name: "containerd-sock" |
| 25 | + hostPath: { |
| 26 | + path: "/run/containerd/containerd.sock" |
| 27 | + type: v1.#HostPathSocket |
| 28 | + } |
| 29 | + }, { |
| 30 | + name: "containerd-content" |
| 31 | + hostPath: { |
| 32 | + path: "/var/lib/containerd/io.containerd.content.v1.content" |
| 33 | + type: v1.#HostPathDirectory |
| 34 | + } |
| 35 | + }, { |
| 36 | + name: "containerd-config" |
| 37 | + hostPath: { |
| 38 | + path: "/etc/cri/conf.d/hosts" |
| 39 | + type: v1.#HostPathDirectoryOrCreate |
| 40 | + } |
| 41 | + }] |
| 42 | + initContainers: [{ |
| 43 | + name: "config" |
| 44 | + image: _image.reference |
| 45 | + args: [ |
| 46 | + "configuration", |
| 47 | + "--log-level=INFO", |
| 48 | + "--containerd-registry-config-path=/etc/cri/conf.d/hosts", |
| 49 | + "--mirror-targets", |
| 50 | + "http://$(NODE_IP):30020", |
| 51 | + "--resolve-tags=true", |
| 52 | + "--prepend-existing=false", |
| 53 | + ] |
| 54 | + env: [{ |
| 55 | + name: "NODE_IP" |
| 56 | + valueFrom: fieldRef: fieldPath: "status.hostIP" |
| 57 | + }] |
| 58 | + resources: limits: { |
| 59 | + cpu: "100m" |
| 60 | + memory: "128Mi" |
| 61 | + } |
| 62 | + volumeMounts: [{ |
| 63 | + name: "containerd-config" |
| 64 | + mountPath: "/etc/cri/conf.d/hosts" |
| 65 | + }] |
| 66 | + imagePullPolicy: v1.#PullIfNotPresent |
| 67 | + securityContext: { |
| 68 | + capabilities: drop: ["ALL"] |
| 69 | + readOnlyRootFilesystem: true |
| 70 | + allowPrivilegeEscalation: false |
| 71 | + } |
| 72 | + }] |
| 73 | + containers: [{ |
| 74 | + name: "spegel" |
| 75 | + image: _image.reference |
| 76 | + args: [ |
| 77 | + "registry", |
| 78 | + "--log-level=INFO", |
| 79 | + "--mirror-resolve-retries=3", |
| 80 | + "--mirror-resolve-timeout=20ms", |
| 81 | + "--registry-addr=:5000", |
| 82 | + "--router-addr=:5001", |
| 83 | + "--metrics-addr=:9090", |
| 84 | + "--containerd-sock=/run/containerd/containerd.sock", |
| 85 | + "--containerd-namespace=k8s.io", |
| 86 | + "--containerd-registry-config-path=/etc/cri/conf.d/hosts", |
| 87 | + "--bootstrap-kind=dns", |
| 88 | + "--dns-bootstrap-domain=\(#Name)-bootstrap.\(#Namespace).svc.cluster.local.", |
| 89 | + "--resolve-latest-tag=true", |
| 90 | + "--containerd-content-path=/var/lib/containerd/io.containerd.content.v1.content", |
| 91 | + "--debug-web-enabled=true", |
| 92 | + ] |
| 93 | + env: [{ |
| 94 | + name: "DATA_DIR" |
| 95 | + value: "" |
| 96 | + }, { |
| 97 | + name: "NODE_IP" |
| 98 | + valueFrom: fieldRef: fieldPath: "status.hostIP" |
| 99 | + }, { |
| 100 | + name: "GOMEMLIMIT" |
| 101 | + valueFrom: resourceFieldRef: { |
| 102 | + resource: "limits.memory" |
| 103 | + divisor: 1 |
| 104 | + } |
| 105 | + }] |
| 106 | + ports: [{ |
| 107 | + name: "registry" |
| 108 | + containerPort: 5000 |
| 109 | + }, { |
| 110 | + name: "router" |
| 111 | + containerPort: 5001 |
| 112 | + }, { |
| 113 | + name: "metrics" |
| 114 | + containerPort: 9090 |
| 115 | + }] |
| 116 | + resources: limits: { |
| 117 | + (v1.#ResourceCPU): "300m" |
| 118 | + (v1.#ResourceMemory): "128Mi" |
| 119 | + } |
| 120 | + volumeMounts: [{ |
| 121 | + name: "containerd-sock" |
| 122 | + mountPath: "/run/containerd/containerd.sock" |
| 123 | + }, { |
| 124 | + name: "containerd-content" |
| 125 | + mountPath: "/var/lib/containerd/io.containerd.content.v1.content" |
| 126 | + readOnly: true |
| 127 | + }] |
| 128 | + |
| 129 | + let probe = { |
| 130 | + httpGet: { |
| 131 | + path: "/readyz" |
| 132 | + port: "registry" |
| 133 | + } |
| 134 | + } |
| 135 | + |
| 136 | + livenessProbe: probe |
| 137 | + readinessProbe: probe |
| 138 | + startupProbe: probe & { |
| 139 | + periodSeconds: 3 |
| 140 | + failureThreshold: 60 |
| 141 | + } |
| 142 | + |
| 143 | + imagePullPolicy: v1.#PullIfNotPresent |
| 144 | + // securityContext: { |
| 145 | + // capabilities: drop: ["ALL"] |
| 146 | + // readOnlyRootFilesystem: true |
| 147 | + // allowPrivilegeEscalation: false |
| 148 | + // } |
| 149 | + securityContext: readOnlyRootFilesystem: true |
| 150 | + }] |
| 151 | + // securityContext: { |
| 152 | + // runAsUser: 1000 |
| 153 | + // runAsGroup: 3000 |
| 154 | + // runAsNonRoot: true |
| 155 | + // fsGroup: 2000 |
| 156 | + // seccompProfile: type: v1.#SeccompProfileTypeRuntimeDefault |
| 157 | + // } |
| 158 | + tolerations: [{ |
| 159 | + key: "CriticalAddonsOnly" |
| 160 | + operator: v1.#TolerationOpExists |
| 161 | + }, { |
| 162 | + operator: v1.#TolerationOpExists |
| 163 | + effect: v1.#TaintEffectNoExecute |
| 164 | + }, { |
| 165 | + operator: v1.#TolerationOpExists |
| 166 | + effect: v1.#TaintEffectNoSchedule |
| 167 | + }] |
| 168 | + } |
| 169 | + } |
| 170 | + } |
| 171 | +}] |
0 commit comments