flink-kubernetes-operator
A Helm chart for the Apache Flink Kubernetes Operator, modified for WMF.
About this chart
flink-kubernetes-operator Helm chart
This chart was copied from upstream flink-kubernetes-operator's helm chart, and modified to work in WMF's kubernetes environments.
This chart will enable use of the FlinkDeployment CRD to deploy Flink clusters in single application mode.
WMF separates the installation of CRDs from the installation of this operator. Please install the flink-kubernetes-operator-crds chart before this one.
See the Flink Kubernetes Operator documentation for more information.
Modifications from upstream flink-kubernetes-operator helm chart
https://github.com/apache/flink-kubernetes-operator/tree/main/helm/flink-kubernetes-operator
- crds are moved to a separate chart: flink-kubernetes-operator-crds
- package.json and templates/vendor use sextant for networkpolicy_1.2.0.tpl
- templates/networkpolicy.yaml is added to allow:
-- ingress access to metrics port
-- egress-basic using WMF's vendor/base/networkpolicy_1.2.0.tpl.
Set
networkpolicy.egress.enabled: truein your helmfile values to use this. If you enable egress, you must also set at least one ofnetworkpolicy.egress.dst_netsornetworkpolicy.egress.dst_ports. -- egress to kubernetes API at .Values.kubernetesMasters.cidrs -- ingress to webhook from kubernetes API at .Values.kubernetesMasters.cidrs if .Values.webhook.create is true. - Added .fixtures for CI.
- Lowered operator logging level from ERROR to WARN
Upgrading from upstream helm chart.
TODO: add better instructions.
The basic idea is to copy all files from upstream helm chart, and keep any of the customizations noted in "Modifications from upstream..." above.
Ideally we can keep all custom modifications in helm template files that are not present in the upstream helm chart, e.g. networkpolicy.yaml. In the cases where there are changes to a file used by upstream, we should submit a JIRA and PR to get our changes upstreamed.
Summary of ServiceAccounts and RBAC
flink-operatorServiceAccount is created in.Release.Namespace.
For each namespace in watchNamespaces:
-
flinkServiceAccount is created in the watched namespace. -
A
flink-operatorRole is created with a RoleBinding giving theflink-operatorServiceAccount in.Release.Namespacepermissions to managepods,services,events,configmaps,secrets,deployments,deployments/finalizers,replicasets,ingresses, and all flink operator CRDs (e.g. FlinkDeployments ). This will allow the operator to create Flink JobManager pods in the watched namespace. -
A
flinkRole is created with a RoleBinding giving theflinkServiceAccount in the watched namespace permissions to managepods,configmaps,deploymentsanddeployments/finalizers. These resources are managed by the Flink JobManager pod, as well as manage some minimal state needed for HA inconfigmaps.
Dynamic operator configuration and namespaces
If kubernetes.operator.dynamic.namespaces.enabled and kubernetes.operator.dynamic.config.enabled
are enabled for the operator, watchNamespaces will dynamically be
propagated through to the operator as kubernetes.operator.watched.namespaces
in flink-conf.yaml. This allows you to add new namespaces to which
the operator will be able to create resources in. You should
be able to change the value of watchNamespaces, upgrade your helm release,
and then deploy FlinkDeployments into new namespaces.
See:
- https://nightlies.apache.org/flink/flink-kubernetes-operator-docs-main/docs/operations/configuration/#dynamic-operator-configuration
- https://nightlies.apache.org/flink/flink-kubernetes-operator-docs-main/docs/operations/helm/#watching-only-specific-namespaces
Deploy flink-kubernetes-operator with OpenTenant
Each tenant gets its own release of this chart, with its own namespace, secrets and domain. The builder below already has flink-kubernetes-operator on a Hetzner server. Change the host, add apps from the marketplace, then copy the generated files. Providers and prices are samples, and nothing here is sent anywhere.
- Pick a serverConnect Hetzner, OVHcloud or AWS. The builder starts on Hetzner, the cheapest sample rate.
- Place the chartflink-kubernetes-operator is pinned at v2.4.8 in opentenant.yaml. Drag more apps from the marketplace onto a rack.
- ApplySave opentenant.yaml and main.tf from the console, then run the commands below.
# opentenant.yaml, main.tf and dns.tf come from the builder below opentenant validate opentenant.yaml terraform init && terraform apply