# The operator: one Deployment that reconciles the simmer.foo resources # in every namespace and serves the data plane to Session Jobs. Its # state outside the API server is the data plane on the simmer-data # volume: the events that wait for each Session, and each Session's # transcript. --- apiVersion: apps/v1 kind: Deployment metadata: name: simmer-operator spec: # The data plane is on a ReadWriteOnce volume, and the operator has no # leader election. Recreate stops the old pod before the new one # starts, so two operators never run at once and never both write the # volume. replicas: 1 strategy: type: Recreate selector: matchLabels: app: simmer-operator template: metadata: labels: app: simmer-operator spec: serviceAccountName: simmer-operator securityContext: runAsNonRoot: true runAsUser: 65532 runAsGroup: 65532 # The kubelet gives the volume this group, so the unprivileged # user can write the data plane. fsGroup: 65532 seccompProfile: type: RuntimeDefault containers: - name: operator image: atcr.io/guid.foo/simmer args: [operator] env: # The operator's own namespace, where it runs the probe Jobs # and reads the Secrets that Accounts and Signals name. - name: SIMMER_NAMESPACE valueFrom: fieldRef: fieldPath: metadata.namespace # The pod's name, so the operator can read its own pod. - name: SIMMER_POD_NAME valueFrom: fieldRef: fieldPath: metadata.name # The image of each Session pod's simmer-install init # container, which must be this container's image. The # downward API cannot give a container its image, and # kustomize's images transformer does not change an env # value. A replacement in this base would copy the base's # tag, because it runs before the overlay's images entry. # When this is empty, the operator reads the image of its # container "operator" from its own pod. An overlay that # sets it keeps it in step with a replacement of its own, # which runs after its images entry: # # replacements: # - source: # kind: Deployment # name: simmer-operator # fieldPath: spec.template.spec.containers.[name=operator].image # targets: # - select: { kind: Deployment, name: simmer-operator } # fieldPaths: # - spec.template.spec.containers.[name=operator].env.[name=SIMMER_OPERATOR_IMAGE].value - name: SIMMER_OPERATOR_IMAGE value: "" - name: SIMMER_DATA_DIR value: /data - name: SIMMER_METRICS_ADDRESS value: :9200 - name: SIMMER_DATAPLANE_ADDRESS value: :8443 # The address that Session Jobs use to reach the data plane: # the Service below. It names the namespace, so an overlay # that changes the namespace changes this too. - name: SIMMER_DATAPLANE_URL value: http://simmer-operator.simmer.svc:8443 # The base URL of wicket, where each Signal subscribes to # /. The overlay sets it. - name: SIMMER_WICKET_URL value: "" # The operator's ServiceAccount token for the audience # wicket, from the volume wicket. A Signal with no token # sends it, and wicket admits the operator by its # ServiceAccount. - name: SIMMER_WICKET_TOKEN_FILE value: /var/run/secrets/wicket/token # The image that each Session's container runs. It must hold # claude and git. The overlay sets it. - name: SIMMER_SESSION_IMAGE value: "" ports: - name: metrics containerPort: 9200 - name: dataplane containerPort: 8443 # /livez answers while the process serves, so a collection that # the cluster does not serve yet, such as a CRD that is not # installed, never restarts the pod. livenessProbe: httpGet: path: /livez port: metrics periodSeconds: 20 failureThreshold: 3 # /healthz answers once every watch has read its whole # collection, so the Service sends the data plane no request # before the operator holds a copy of the cluster. readinessProbe: httpGet: path: /healthz port: metrics periodSeconds: 5 volumeMounts: - name: data mountPath: /data - name: tmp mountPath: /tmp - name: wicket mountPath: /var/run/secrets/wicket readOnly: true securityContext: runAsNonRoot: true runAsUser: 65532 capabilities: drop: ["ALL"] privileged: false allowPrivilegeEscalation: false readOnlyRootFilesystem: true resources: requests: cpu: 10m memory: 64Mi # The informers hold every simmer.foo object and the Jobs # and pods of the Sessions. No CPU limit, so a burst of # events is not throttled. limits: memory: 256Mi volumes: - name: data persistentVolumeClaim: claimName: simmer-data # The root filesystem is read-only, so temporary files, such as # a transcript upload in progress, go here. - name: tmp emptyDir: {} # The kubelet replaces the token before it expires, and the # operator reads the file again for each attempt to subscribe. - name: wicket projected: sources: - serviceAccountToken: audience: wicket expirationSeconds: 3600 path: token --- # The data plane's store. No storageClassName, so the cluster's default # class provisions it, unless the overlay names one. apiVersion: v1 kind: PersistentVolumeClaim metadata: name: simmer-data spec: accessModes: [ReadWriteOnce] resources: requests: storage: 1Gi --- # The data plane for Session Jobs, and the metrics for Prometheus. The # data plane is plain HTTP inside the cluster, and each request carries # a projected ServiceAccount token that the operator checks. # # The base has no NetworkPolicy. A policy must admit the data plane from # Session, schedule, and probe pods in every namespace, and the metrics # from Prometheus, and both depend on the cluster. Add one in your # overlay. A schedule's pod carries the label simmer.foo/schedule, not # simmer.foo/session, and takes nothing from the Mandate's template, so # a policy or a pull secret that finds Session pods by that label or # through the template misses it. apiVersion: v1 kind: Service metadata: name: simmer-operator spec: type: ClusterIP selector: app: simmer-operator ports: - name: metrics port: 9200 targetPort: metrics - name: dataplane port: 8443 targetPort: dataplane