Skip to content

Commit

Permalink
Merge pull request #1625 from FabianKramm/main
Browse files Browse the repository at this point in the history
refactor: disabled -> enabled: auto & telemetry refactor
  • Loading branch information
FabianKramm authored Mar 26, 2024
2 parents f23d2a6 + d5354f8 commit 70d5f9a
Show file tree
Hide file tree
Showing 23 changed files with 617 additions and 508 deletions.
8 changes: 4 additions & 4 deletions chart/templates/_init-containers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
{{ toYaml .Values.controlPlane.distro.eks.securityContext | indent 4 }}
resources:
{{ toYaml .Values.controlPlane.distro.eks.resources | indent 4 }}
{{- if not .Values.controlPlane.distro.eks.controllerManager.disabled }}
{{- if .Values.controlPlane.distro.eks.controllerManager.enabled }}
- name: kube-controller-manager
image: "{{ .Values.controlPlane.advanced.defaultImageRegistry }}{{ .Values.controlPlane.distro.eks.controllerManager.image.repository }}:{{ .Values.controlPlane.distro.eks.controllerManager.image.tag }}"
volumeMounts:
Expand Down Expand Up @@ -72,7 +72,7 @@
resources:
{{ toYaml .Values.controlPlane.distro.eks.resources | indent 4 }}
{{- end }}
{{- if not .Values.controlPlane.distro.eks.apiServer.disabled }}
{{- if .Values.controlPlane.distro.eks.apiServer.enabled }}
- name: kube-apiserver
image: "{{ .Values.controlPlane.advanced.defaultImageRegistry }}{{ .Values.controlPlane.distro.eks.apiServer.image.repository }}:{{ .Values.controlPlane.distro.eks.apiServer.image.tag }}"
volumeMounts:
Expand Down Expand Up @@ -116,7 +116,7 @@
{{ toYaml .Values.controlPlane.distro.k8s.securityContext | indent 4 }}
resources:
{{ toYaml .Values.controlPlane.distro.k8s.resources | indent 4 }}
{{- if not .Values.controlPlane.distro.k8s.controllerManager.disabled }}
{{- if .Values.controlPlane.distro.k8s.controllerManager.enabled }}
- name: kube-controller-manager
image: "{{ .Values.controlPlane.advanced.defaultImageRegistry }}{{ .Values.controlPlane.distro.k8s.controllerManager.image.repository }}:{{ .Values.controlPlane.distro.k8s.controllerManager.image.tag }}"
volumeMounts:
Expand Down Expand Up @@ -156,7 +156,7 @@
resources:
{{ toYaml .Values.controlPlane.distro.k8s.resources | indent 4 }}
{{- end }}
{{- if not .Values.controlPlane.distro.k8s.apiServer.disabled }}
{{- if .Values.controlPlane.distro.k8s.apiServer.enabled }}
- name: kube-apiserver
image: "{{ .Values.controlPlane.advanced.defaultImageRegistry }}{{ .Values.controlPlane.distro.k8s.apiServer.image.repository }}:{{ .Values.controlPlane.distro.k8s.apiServer.image.tag }}"
volumeMounts:
Expand Down
4 changes: 3 additions & 1 deletion chart/templates/_persistence.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ volumeClaimTemplates:
{{- define "vcluster.persistence.volumeClaim.enabled" -}}
{{- if .Values.controlPlane.statefulSet.persistence.volumeClaimTemplates -}}
{{- true -}}
{{- else if and (not .Values.controlPlane.statefulSet.persistence.volumeClaim.disabled) (not (include "vcluster.externalEtcd.enabled" .)) -}}
{{- else if eq (toString .Values.controlPlane.statefulSet.persistence.volumeClaim.enabled) "true" -}}
{{- true -}}
{{- else if and (eq (toString .Values.controlPlane.statefulSet.persistence.volumeClaim.enabled) "auto") (not (include "vcluster.externalEtcd.enabled" .)) -}}
{{- true -}}
{{- end -}}
{{- end -}}
4 changes: 3 additions & 1 deletion chart/templates/_rbac.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@
Whether to create a cluster role or not
*/}}
{{- define "vcluster.createClusterRole" -}}
{{- if not .Values.rbac.clusterRole.disabled -}}
{{- if eq (toString .Values.rbac.clusterRole.enabled) "true" -}}
{{- true -}}
{{- else if eq (toString .Values.rbac.clusterRole.enabled) "auto" -}}
{{- if or
.Values.rbac.clusterRole.overwriteRules
(not (empty (include "vcluster.rbac.clusterRoleExtraRules" . )))
Expand Down
4 changes: 2 additions & 2 deletions chart/templates/etcd-statefulset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ spec:
{{- if $externalEtcd.persistence.volumeClaimTemplates }}
volumeClaimTemplates:
{{ toYaml $externalEtcd.persistence.volumeClaimTemplates | indent 4 }}
{{- else if not $externalEtcd.persistence.volumeClaim.disabled }}
{{- else if $externalEtcd.persistence.volumeClaim.enabled }}
volumeClaimTemplates:
- metadata:
name: data
Expand Down Expand Up @@ -121,7 +121,7 @@ spec:
{{- if $externalEtcd.persistence.addVolumes }}
{{ toYaml $externalEtcd.persistence.addVolumes | indent 8 }}
{{- end }}
{{- if $externalEtcd.persistence.volumeClaim.disabled }}
{{- if not $externalEtcd.persistence.volumeClaim.enabled }}
- name: data
emptyDir: {}
{{- end }}
Expand Down
29 changes: 29 additions & 0 deletions chart/tests/clusterrole_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,37 @@ tests:
- hasDocuments:
count: 0

- it: force enable
set:
rbac:
clusterRole:
enabled: true
asserts:
- hasDocuments:
count: 1

- it: force disable
set:
rbac:
clusterRole:
enabled: false
extraRules:
- apiGroups: [""]
resources: ["test123"]
verbs: ["test123"]
overwriteRules:
- apiGroups: [""]
resources: ["test"]
verbs: ["test"]
asserts:
- hasDocuments:
count: 0

- it: enable by multi namespace mode
set:
rbac:
clusterRole:
enabled: auto
experimental:
multiNamespaceMode:
enabled: true
Expand Down
2 changes: 1 addition & 1 deletion chart/tests/etcd-statefulset_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ tests:
- name: my-new-env
persistence:
volumeClaim:
disabled: true
enabled: false
addVolumes:
- name: my-new-volume
addVolumeMounts:
Expand Down
2 changes: 1 addition & 1 deletion chart/tests/statefulset_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ tests:
statefulSet:
persistence:
volumeClaim:
disabled: true
enabled: false
volumeClaimTemplates:
- metadata:
name: data
Expand Down
106 changes: 90 additions & 16 deletions chart/values.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -680,11 +680,11 @@
"additionalProperties": false,
"type": "object"
},
"DistroContainerDisabled": {
"DistroContainerEnabled": {
"properties": {
"disabled": {
"enabled": {
"type": "boolean",
"description": "Disabled signals this container should be disabled."
"description": "Enabled signals this container should be enabled."
},
"image": {
"$ref": "#/$defs/Image",
Expand Down Expand Up @@ -821,16 +821,16 @@
"description": "Enabled specifies if the K8s distro should be enabled. Only one distro can be enabled at the same time."
},
"apiServer": {
"$ref": "#/$defs/DistroContainerDisabled",
"$ref": "#/$defs/DistroContainerEnabled",
"description": "APIServer holds configuration specific to starting the api server."
},
"controllerManager": {
"$ref": "#/$defs/DistroContainerDisabled",
"$ref": "#/$defs/DistroContainerEnabled",
"description": "ControllerManager holds configuration specific to starting the scheduler."
},
"scheduler": {
"$ref": "#/$defs/DistroContainer",
"description": "Scheduler holds configuration specific to starting the scheduler."
"description": "Scheduler holds configuration specific to starting the scheduler. Enable this via controlPlane.virtualScheduler.enabled"
},
"env": {
"items": {
Expand Down Expand Up @@ -1235,6 +1235,66 @@
"additionalProperties": false,
"type": "object"
},
"ExternalEtcdPersistence": {
"properties": {
"volumeClaim": {
"$ref": "#/$defs/ExternalEtcdPersistenceVolumeClaim",
"description": "VolumeClaim can be used to configure the persistent volume claim."
},
"volumeClaimTemplates": {
"items": {
"type": "object"
},
"type": "array",
"description": "VolumeClaimTemplates defines the volumeClaimTemplates for the statefulSet"
},
"addVolumes": {
"items": {
"type": "object"
},
"type": "array",
"description": "AddVolumes defines extra volumes for the pod"
},
"addVolumeMounts": {
"items": {
"$ref": "#/$defs/VolumeMount"
},
"type": "array",
"description": "AddVolumeMounts defines extra volume mounts for the container"
}
},
"additionalProperties": false,
"type": "object"
},
"ExternalEtcdPersistenceVolumeClaim": {
"properties": {
"enabled": {
"type": "boolean",
"description": "Enabled enables deploying a persistent volume claim."
},
"accessModes": {
"items": {
"type": "string"
},
"type": "array",
"description": "AccessModes are the persistent volume claim access modes."
},
"retentionPolicy": {
"type": "string",
"description": "RetentionPolicy is the persistent volume claim retention policy."
},
"size": {
"type": "string",
"description": "Size is the persistent volume claim storage size."
},
"storageClass": {
"type": "string",
"description": "StorageClass is the persistent volume claim storage class."
}
},
"additionalProperties": false,
"type": "object"
},
"ExternalEtcdService": {
"properties": {
"enabled": {
Expand Down Expand Up @@ -1301,7 +1361,7 @@
"description": "Security options for the etcd pods."
},
"persistence": {
"$ref": "#/$defs/ControlPlanePersistence",
"$ref": "#/$defs/ExternalEtcdPersistence",
"description": "Persistence options for the etcd pods."
},
"annotations": {
Expand Down Expand Up @@ -2015,9 +2075,16 @@
},
"RBACClusterRole": {
"properties": {
"disabled": {
"type": "boolean",
"description": "Disabled defines if the cluster role should be disabled. Otherwise, vCluster automatically determines whether the virtual cluster requires a cluster role."
"enabled": {
"oneOf": [
{
"type": "string"
},
{
"type": "boolean"
}
],
"description": "Enabled defines if the cluster role should be enabled or disabled. If auto, vCluster automatically determines whether the virtual cluster requires a cluster role."
},
"extraRules": {
"items": {
Expand Down Expand Up @@ -2529,9 +2596,9 @@
},
"Telemetry": {
"properties": {
"disabled": {
"enabled": {
"type": "boolean",
"description": "Disabled specifies that the telemetry for the vCluster control plane should be disabled."
"description": "Enabled specifies that the telemetry for the vCluster control plane should be enabled."
},
"instanceCreator": {
"type": "string"
Expand Down Expand Up @@ -2577,9 +2644,16 @@
},
"VolumeClaim": {
"properties": {
"disabled": {
"type": "boolean",
"description": "Disabled signals to disable deploying a persistent volume claim. If false, vCluster will automatically determine\nbased on the chosen distro and other options if this is required."
"enabled": {
"oneOf": [
{
"type": "string"
},
{
"type": "boolean"
}
],
"description": "Enabled enables deploying a persistent volume claim. If auto, vCluster will automatically determine\nbased on the chosen distro and other options if this is required."
},
"accessModes": {
"items": {
Expand Down Expand Up @@ -2639,7 +2713,7 @@
"properties": {
"exportKubeConfig": {
"$ref": "#/$defs/ExportKubeConfig",
"description": "ExportKubeConfig describes how vCluster should export the vCluster kubeconfig file."
"description": "ExportKubeConfig describes how vCluster should export the vCluster kubeConfig file."
},
"sync": {
"$ref": "#/$defs/Sync",
Expand Down
16 changes: 8 additions & 8 deletions chart/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -101,15 +101,15 @@ controlPlane:
k8s:
enabled: false
apiServer:
disabled: false
enabled: true
command: []
extraArgs: []
imagePullPolicy: ""
image:
repository: "registry.k8s.io/kube-apiserver"
tag: "v1.29.0"
controllerManager:
disabled: false
enabled: true
command: []
extraArgs: []
imagePullPolicy: ""
Expand All @@ -136,15 +136,15 @@ controlPlane:
eks:
enabled: false
apiServer:
disabled: false
enabled: true
command: []
extraArgs: []
imagePullPolicy: ""
image:
repository: "public.ecr.aws/eks-distro/kubernetes/kube-apiserver"
tag: "v1.28.2-eks-1-28-6"
controllerManager:
disabled: false
enabled: true
command: []
extraArgs: []
imagePullPolicy: ""
Expand Down Expand Up @@ -205,7 +205,7 @@ controlPlane:
containerSecurityContext: {}
persistence:
volumeClaim:
disabled: false
enabled: true
# Defines if the PVC should get automatically deleted when the StatefulSet is deleted. Can be either Delete or Retain
retentionPolicy: Retain
size: 5Gi
Expand Down Expand Up @@ -317,7 +317,7 @@ controlPlane:

persistence:
volumeClaim:
disabled: false
enabled: auto
# Defines if the PVC should get automatically deleted when the StatefulSet is deleted. Can be either Delete or Retain
retentionPolicy: Retain
size: 5Gi
Expand Down Expand Up @@ -381,7 +381,7 @@ rbac:
overwriteRules: []
extraRules: []
clusterRole:
disabled: false
enabled: auto
overwriteRules: []
extraRules: []

Expand Down Expand Up @@ -505,4 +505,4 @@ platform:
namespace: ""

telemetry:
disabled: false
enabled: true
Loading

0 comments on commit 70d5f9a

Please sign in to comment.