Merge pull request #4301 from MaxRink/ca-helm-clusterapi

[CA][Helm] Add ClusterAPI as supported Provider to the helm chart
This commit is contained in:
Kubernetes Prow Robot 2022-02-16 13:42:45 -08:00 committed by GitHub
commit 0d9fb78c92
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 156 additions and 14 deletions

View File

@ -17,4 +17,4 @@ name: cluster-autoscaler
sources:
- https://github.com/kubernetes/autoscaler/tree/master/cluster-autoscaler
type: application
version: 9.14.0
version: 9.15.0

View File

@ -209,6 +209,18 @@ Install the chart with
```
$ helm install my-release autoscaler/cluster-autoscaler -f myvalues.yaml
```
### Cluster-API
`cloudProvider: clusterapi` must be set, and then one or more of
- `autoDiscovery.clusterName`
- or `autoDiscovery.labels`
See [here](https://github.com/kubernetes/autoscaler/blob/master/cluster-autoscaler/cloudprovider/clusterapi/README.md#configuring-node-group-auto-discovery) for more details
Additional config parameters avaible, see the `values.yaml` for more details
`clusterAPIMode`
`clusterAPIKubeconfigSecret`
`clusterAPIWorkloadKubeconfigPath`
`clusterAPICloudConfigPath`
## Uninstalling the Chart
@ -338,7 +350,8 @@ Though enough for the majority of installations, the default PodSecurityPolicy _
|-----|------|---------|-------------|
| additionalLabels | object | `{}` | Labels to add to each object of the chart. |
| affinity | object | `{}` | Affinity for pod assignment |
| autoDiscovery.clusterName | string | `nil` | Enable autodiscovery for `cloudProvider=aws`, for groups matching `autoDiscovery.tags`. Enable autodiscovery for `cloudProvider=gce`, but no MIG tagging required. Enable autodiscovery for `cloudProvider=magnum`, for groups matching `autoDiscovery.roles`. |
| autoDiscovery.clusterName | string | `nil` | Enable autodiscovery for `cloudProvider=aws`, for groups matching `autoDiscovery.tags`. Enable autodiscovery for `cloudProvider=clusterapi`, for groups matching `autoDiscovery.labels`. Enable autodiscovery for `cloudProvider=gce`, but no MIG tagging required. Enable autodiscovery for `cloudProvider=magnum`, for groups matching `autoDiscovery.roles`. |
| autoDiscovery.labels | list | `[]` | Cluster-API labels to match https://github.com/kubernetes/autoscaler/blob/master/cluster-autoscaler/cloudprovider/clusterapi/README.md#configuring-node-group-auto-discovery |
| autoDiscovery.roles | list | `["worker"]` | Magnum node group roles to match. |
| autoDiscovery.tags | list | `["k8s.io/cluster-autoscaler/enabled","k8s.io/cluster-autoscaler/{{ .Values.autoDiscovery.clusterName }}"]` | ASG tags to match, run through `tpl`. |
| autoscalingGroups | list | `[]` | For AWS, Azure AKS or Magnum. At least one element is required if not using `autoDiscovery`. For example: <pre> - name: asg1<br /> maxSize: 2<br /> minSize: 1 </pre> |
@ -356,7 +369,11 @@ Though enough for the majority of installations, the default PodSecurityPolicy _
| azureUseManagedIdentityExtension | bool | `false` | Whether to use Azure's managed identity extension for credentials. If using MSI, ensure subscription ID, resource group, and azure AKS cluster name are set. |
| azureVMType | string | `"AKS"` | Azure VM type. |
| cloudConfigPath | string | `"/etc/gce.conf"` | Configuration file for cloud provider. |
| cloudProvider | string | `"aws"` | The cloud provider where the autoscaler runs. Currently only `gce`, `aws`, `azure` and `magnum` are supported. `aws` supported for AWS. `gce` for GCE. `azure` for Azure AKS. `magnum` for OpenStack Magnum. |
| cloudProvider | string | `"aws"` | The cloud provider where the autoscaler runs. Currently only `gce`, `aws`, `azure`, `magnum` and `clusterapi` are supported. `aws` supported for AWS. `gce` for GCE. `azure` for Azure AKS. `magnum` for OpenStack Magnum, `clusterapi` for Cluster API. |
| clusterAPICloudConfigPath | string | `"/etc/kubernetes/mgmt-kubeconfig"` | Path to kubeconfig for connecting to Cluster API Management Cluster, only used if `clusterAPIMode=kubeconfig-kubeconfig or incluster-kubeconfig` |
| clusterAPIKubeconfigSecret | string | `""` | Secret containing kubeconfig for connecting to Cluster API managed workloadcluster Required if `cloudProvider=clusterapi` and `clusterAPIMode=kubeconfig-kubeconfig,kubeconfig-incluster or incluster-kubeconfig` |
| clusterAPIMode | string | `"incluster-incluster"` | Cluster API mode, see https://github.com/kubernetes/autoscaler/blob/master/cluster-autoscaler/cloudprovider/clusterapi/README.md#connecting-cluster-autoscaler-to-cluster-api-management-and-workload-clusters Syntax: workloadClusterMode-ManagementClusterMode for `kubeconfig-kubeconfig`, `incluster-kubeconfig` and `single-kubeconfig` you always must mount the external kubeconfig using either `extraVolumeSecrets` or `extraMounts` and `extraVolumes` if you dont set `clusterAPIKubeconfigSecret`and thus use an in-cluster config or want to use a non capi generated kubeconfig you must do so for the workload kubeconfig as well |
| clusterAPIWorkloadKubeconfigPath | string | `"/etc/kubernetes/value"` | Path to kubeconfig for connecting to Cluster API managed workloadcluster, only used if `clusterAPIMode=kubeconfig-kubeconfig or kubeconfig-incluster` |
| containerSecurityContext | object | `{}` | [Security context for container](https://kubernetes.io/docs/tasks/configure-pod-container/security-context/) |
| dnsPolicy | string | `"ClusterFirst"` | Defaults to `ClusterFirst`. Valid values are: `ClusterFirstWithHostNet`, `ClusterFirst`, `Default` or `None`. If autoscaler does not depend on cluster DNS, recommended to set this to `Default`. |
| envFromConfigMap | string | `""` | ConfigMap name to use as envFrom. |
@ -389,6 +406,7 @@ Though enough for the majority of installations, the default PodSecurityPolicy _
| prometheusRule.interval | string | `nil` | How often rules in the group are evaluated (falls back to `global.evaluation_interval` if not set). |
| prometheusRule.namespace | string | `"monitoring"` | Namespace which Prometheus is running in. |
| prometheusRule.rules | list | `[]` | Rules spec template (see https://github.com/prometheus-operator/prometheus-operator/blob/master/Documentation/api.md#rule). |
| rbac.clusterScoped | bool | `true` | if set to false will only provision RBAC to alter resources in the current namespace. Most useful for Cluster-API |
| rbac.create | bool | `true` | If `true`, create and use RBAC resources. |
| rbac.pspEnabled | bool | `false` | If `true`, creates and uses RBAC resources required in the cluster with [Pod Security Policies](https://kubernetes.io/docs/concepts/policy/pod-security-policy/) enabled. Must be used with `rbac.create` set to `true`. |
| rbac.serviceAccount.annotations | object | `{}` | Additional Service Account annotations. |

View File

@ -209,6 +209,19 @@ Install the chart with
```
$ helm install my-release autoscaler/cluster-autoscaler -f myvalues.yaml
```
### Cluster-API
`cloudProvider: clusterapi` must be set, and then one or more of
- `autoDiscovery.clusterName`
- or `autoDiscovery.labels`
See [here](https://github.com/kubernetes/autoscaler/blob/master/cluster-autoscaler/cloudprovider/clusterapi/README.md#configuring-node-group-auto-discovery) for more details
Additional config parameters avaible, see the `values.yaml` for more details
`clusterAPIMode`
`clusterAPIKubeconfigSecret`
`clusterAPIWorkloadKubeconfigPath`
`clusterAPICloudConfigPath`
## Uninstalling the Chart

View File

@ -94,4 +94,24 @@ Return true if the priority expander is enabled
{{- if has "priority" $expanders -}}
{{- true -}}
{{- end -}}
{{- end -}}
{{- end -}}
{{/*
Return the autodiscoveryparameters for clusterapi.
*/}}
{{- define "cluster-autoscaler.capiAutodiscoveryConfig" -}}
{{- if .Values.autoDiscovery.clusterName -}}
{{- print "clusterName=" -}}{{ .Values.autoDiscovery.clusterName }}
{{- end -}}
{{- if and .Values.autoDiscovery.clusterName .Values.autoDiscovery.labels -}}
{{- print "," -}}
{{- end -}}
{{- if .Values.autoDiscovery.labels -}}
{{- range $i, $el := .Values.autoDiscovery.labels -}}
{{- if $i -}}{{- print "," -}}{{- end -}}
{{- range $key, $val := $el -}}
{{- $key -}}{{- print "=" -}}{{- $val -}}
{{- end -}}
{{- end -}}
{{- end -}}
{{- end -}}

View File

@ -1,4 +1,4 @@
{{- if .Values.rbac.create -}}
{{- if and .Values.rbac.create .Values.rbac.clusterScoped -}}
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
@ -146,5 +146,18 @@ rules:
verbs:
- use
{{- end -}}
{{- if and ( and ( eq .Values.cloudProvider "clusterapi" ) ( .Values.rbac.clusterScoped ) ( or ( eq .Values.clusterAPIMode "incluster-incluster" ) ( eq .Values.clusterAPIMode "incluster-kubeconfig" ) ))}}
- apiGroups:
- cluster.x-k8s.io
resources:
- machinedeployments
- machinedeployments/scale
- machines
- machinesets
verbs:
- get
- list
- update
- watch
{{- end }}
{{- end -}}

View File

@ -1,4 +1,4 @@
{{- if .Values.rbac.create -}}
{{- if and .Values.rbac.create .Values.rbac.clusterScoped -}}
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:

View File

@ -1,4 +1,4 @@
{{- if or .Values.autoDiscovery.clusterName .Values.autoscalingGroups }}
{{- if or ( or .Values.autoDiscovery.clusterName .Values.autoDiscovery.labels ) .Values.autoscalingGroups }}
{{/* one of the above is required */}}
apiVersion: {{ template "deployment.apiVersion" . }}
kind: Deployment
@ -69,6 +69,21 @@ spec:
{{- else }}
- --cluster-name={{ .Values.magnumClusterName }}
{{- end }}
{{- else if eq .Values.cloudProvider "clusterapi" }}
{{- if or .Values.autoDiscovery.clusterName .Values.autoDiscovery.labels }}
- --node-group-auto-discovery=clusterapi:{{ template "cluster-autoscaler.capiAutodiscoveryConfig" . }}
{{- end }}
{{- if eq .Values.clusterAPIMode "incluster-kubeconfig"}}
- --cloud-config={{ .Values.clusterAPICloudConfigPath }}
{{- else if eq .Values.clusterAPIMode "kubeconfig-incluster"}}
- --kubeconfig={{ .Values.clusterAPIWorkloadKubeconfigPath }}
- --clusterapi-cloud-config-authoritative
{{- else if eq .Values.clusterAPIMode "kubeconfig-kubeconfig"}}
- --kubeconfig={{ .Values.clusterAPIWorkloadKubeconfigPath }}
- --cloud-config={{ .Values.clusterAPICloudConfigPath }}
{{- else if eq .Values.clusterAPIMode "single-kubeconfig"}}
- --kubeconfig={{ .Values.clusterAPIWorkloadKubeconfigPath }}
{{- end }}
{{- end }}
{{- if eq .Values.cloudProvider "magnum" }}
- --cloud-config={{ .Values.cloudConfigPath }}
@ -203,6 +218,10 @@ spec:
mountPath: {{ required "Must specify mountPath!" $value.mountPath }}
readOnly: true
{{- end }}
{{- if .Values.clusterAPIKubeconfigSecret }}
- name: cluster-api-kubeconfig
mountPath: {{ .Values.clusterAPIWorkloadKubeconfigPath | trimSuffix "/value" }}
{{- end }}
{{- if .Values.extraVolumeMounts }}
{{ toYaml .Values.extraVolumeMounts | nindent 12 }}
{{- end }}
@ -250,6 +269,11 @@ spec:
{{- if .Values.extraVolumes }}
{{- toYaml .Values.extraVolumes | nindent 10 }}
{{- end }}
{{- if .Values.clusterAPIKubeconfigSecret }}
- name: cluster-api-kubeconfig
secret:
secretName: {{ .Values.clusterAPIKubeconfigSecret }}
{{- end }}
{{- end }}
{{- if .Values.image.pullSecrets }}
imagePullSecrets:

View File

@ -43,4 +43,35 @@ rules:
- get
- update
{{- end }}
{{- if and ( and ( eq .Values.cloudProvider "clusterapi" ) ( not .Values.rbac.clusterScoped ) ( or ( eq .Values.clusterAPIMode "incluster-incluster" ) ( eq .Values.clusterAPIMode "incluster-kubeconfig" ) ))}}
- apiGroups:
- cluster.x-k8s.io
resources:
- machinedeployments
- machinedeployments/scale
- machines
- machinesets
verbs:
- get
- list
- update
- watch
{{- end }}
{{- if ( not .Values.rbac.clusterScoped ) }}
- apiGroups:
- coordination.k8s.io
resources:
- leases
verbs:
- create
- apiGroups:
- coordination.k8s.io
resourceNames:
- cluster-autoscaler
resources:
- leases
verbs:
- get
- update
{{- end }}
{{- end -}}

View File

@ -3,24 +3,29 @@
affinity: {}
autoDiscovery:
# cloudProviders `aws`, `gce` and `magnum` are supported by auto-discovery at this time
# cloudProviders `aws`, `gce`, `magnum` and `clusterapi` are supported by auto-discovery at this time
# AWS: Set tags as described in https://github.com/kubernetes/autoscaler/blob/master/cluster-autoscaler/cloudprovider/aws/README.md#auto-discovery-setup
# autoDiscovery.clusterName -- Enable autodiscovery for `cloudProvider=aws`, for groups matching `autoDiscovery.tags`.
# Enable autodiscovery for `cloudProvider=clusterapi`, for groups matching `autoDiscovery.labels`.
# Enable autodiscovery for `cloudProvider=gce`, but no MIG tagging required.
# Enable autodiscovery for `cloudProvider=magnum`, for groups matching `autoDiscovery.roles`.
clusterName: # cluster.local
# autoDiscovery.tags -- ASG tags to match, run through `tpl`.
tags:
- k8s.io/cluster-autoscaler/enabled
- k8s.io/cluster-autoscaler/{{ .Values.autoDiscovery.clusterName }}
- k8s.io/cluster-autoscaler/enabled
- k8s.io/cluster-autoscaler/{{ .Values.autoDiscovery.clusterName }}
# - kubernetes.io/cluster/{{ .Values.autoDiscovery.clusterName }}
# autoDiscovery.roles -- Magnum node group roles to match.
roles:
- worker
- worker
# autoDiscovery.labels -- Cluster-API labels to match https://github.com/kubernetes/autoscaler/blob/master/cluster-autoscaler/cloudprovider/clusterapi/README.md#configuring-node-group-auto-discovery
labels: []
# - color: green
# - shape: circle
# autoscalingGroups -- For AWS, Azure AKS or Magnum. At least one element is required if not using `autoDiscovery`. For example:
# <pre>
# - name: asg1<br />
@ -99,13 +104,29 @@ magnumClusterName: ""
# magnumCABundlePath -- Path to the host's CA bundle, from `ca-file` in the cloud-config file.
magnumCABundlePath: "/etc/kubernetes/ca-bundle.crt"
# clusterAPIMode -- Cluster API mode, see https://github.com/kubernetes/autoscaler/blob/master/cluster-autoscaler/cloudprovider/clusterapi/README.md#connecting-cluster-autoscaler-to-cluster-api-management-and-workload-clusters
# Syntax: workloadClusterMode-ManagementClusterMode
# for `kubeconfig-kubeconfig`, `incluster-kubeconfig` and `single-kubeconfig` you always must mount the external kubeconfig using either `extraVolumeSecrets` or `extraMounts` and `extraVolumes`
# if you dont set `clusterAPIKubeconfigSecret`and thus use an in-cluster config or want to use a non capi generated kubeconfig you must do so for the workload kubeconfig as well
clusterAPIMode: incluster-incluster # incluster-incluster, incluster-kubeconfig, kubeconfig-incluster, kubeconfig-kubeconfig, single-kubeconfig
# clusterAPIKubeconfigSecret -- Secret containing kubeconfig for connecting to Cluster API managed workloadcluster
# Required if `cloudProvider=clusterapi` and `clusterAPIMode=kubeconfig-kubeconfig,kubeconfig-incluster or incluster-kubeconfig`
clusterAPIKubeconfigSecret: ""
# clusterAPIWorkloadKubeconfigPath -- Path to kubeconfig for connecting to Cluster API managed workloadcluster, only used if `clusterAPIMode=kubeconfig-kubeconfig or kubeconfig-incluster`
clusterAPIWorkloadKubeconfigPath: /etc/kubernetes/value
# clusterAPICloudConfigPath -- Path to kubeconfig for connecting to Cluster API Management Cluster, only used if `clusterAPIMode=kubeconfig-kubeconfig or incluster-kubeconfig`
clusterAPICloudConfigPath: /etc/kubernetes/mgmt-kubeconfig
# cloudConfigPath -- Configuration file for cloud provider.
cloudConfigPath: /etc/gce.conf
# cloudProvider -- The cloud provider where the autoscaler runs.
# Currently only `gce`, `aws`, `azure` and `magnum` are supported.
# Currently only `gce`, `aws`, `azure`, `magnum` and `clusterapi` are supported.
# `aws` supported for AWS. `gce` for GCE. `azure` for Azure AKS.
# `magnum` for OpenStack Magnum.
# `magnum` for OpenStack Magnum, `clusterapi` for Cluster API.
cloudProvider: aws
# containerSecurityContext -- [Security context for container](https://kubernetes.io/docs/tasks/configure-pod-container/security-context/)
@ -247,6 +268,8 @@ rbac:
# rbac.pspEnabled -- If `true`, creates and uses RBAC resources required in the cluster with [Pod Security Policies](https://kubernetes.io/docs/concepts/policy/pod-security-policy/) enabled.
# Must be used with `rbac.create` set to `true`.
pspEnabled: false
# rbac.clusterScoped -- if set to false will only provision RBAC to alter resources in the current namespace. Most useful for Cluster-API
clusterScoped: true
serviceAccount:
# rbac.serviceAccount.annotations -- Additional Service Account annotations.
annotations: {}