diff --git a/template/deploy/helm/[[operator]]/templates/deployment.yaml.j2 b/template/deploy/helm/[[operator]]/templates/deployment.yaml.j2 index 4ff5c593..06bfbe78 100644 --- a/template/deploy/helm/[[operator]]/templates/deployment.yaml.j2 +++ b/template/deploy/helm/[[operator]]/templates/deployment.yaml.j2 @@ -56,6 +56,18 @@ spec: fieldRef: fieldPath: metadata.annotations['internal.stackable.tech/image'] + # Namespace the operator Pod is running in, e.g. used to construct the conversion + # webhook endpoint. + - name: OPERATOR_NAMESPACE + valueFrom: + fieldRef: + fieldPath: metadata.namespace + + # The name of the Kubernetes Service that point to the operator Pod, e.g. used to + # construct the conversion webhook endpoint. + - name: OPERATOR_SERVICE_NAME + value: {{ include "operator.fullname" . }} + # Operators need to know the node name they are running on, to e.g. discover the # Kubernetes domain name from the kubelet API. - name: KUBERNETES_NODE_NAME diff --git a/template/deploy/helm/[[operator]]/templates/service.yaml b/template/deploy/helm/[[operator]]/templates/service.yaml new file mode 100644 index 00000000..0cb05696 --- /dev/null +++ b/template/deploy/helm/[[operator]]/templates/service.yaml @@ -0,0 +1,19 @@ + +--- +apiVersion: v1 +kind: Service +metadata: + # Note(@sbernauer): We could also call the Service something like + # "product-operator-conversion-webhook". However, in the future we will have more webhooks, and + # it seems like an overkill to have a dedicated Service per webhook. + name: {{ include "operator.fullname" . }} + labels: + {{- include "operator.labels" . | nindent 4 }} +spec: + selector: + {{- include "operator.selectorLabels" . | nindent 6 }} + ports: + - name: conversion-webhook + protocol: TCP + port: 8443 + targetPort: 8443