Skip to content

Commit 2fffc7f

Browse files
committed
updating to 0.24.0
1 parent d2844f9 commit 2fffc7f

File tree

10 files changed

+213
-7
lines changed

10 files changed

+213
-7
lines changed

charts/vcluster/Chart.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,4 @@ sources:
2323
- https://github.com/loft-demos/vcluster-charts/charts/vcluster
2424
type: application
2525

26-
version: 0.23.0 # version is auto-generated by release pipeline
26+
version: 0.24.0 # version is auto-generated by release pipeline
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
{{- define "vcluster.exportKubeConfig.validate" }}
2+
{{- /*
3+
Verify that exportKubeConfig.secret and exportKubeConfig.additionalSecrets are
4+
not set at the same time.
5+
*/}}
6+
{{- $secretSet := false }}
7+
{{- if .Values.exportKubeConfig.secret }}
8+
{{- $secretSet = or (.Values.exportKubeConfig.secret.name | trim | ne "") (.Values.exportKubeConfig.secret.namespace | trim | ne "") }}
9+
{{- end }}
10+
{{- $additionalSecretsSet := false }}
11+
{{- if .Values.exportKubeConfig.additionalSecrets }}
12+
{{- $additionalSecretsSet = gt (len .Values.exportKubeConfig.additionalSecrets) 0 }}
13+
{{- end }}
14+
{{- if and $secretSet $additionalSecretsSet }}
15+
{{- fail "exportKubeConfig.secret and exportKubeConfig.additionalSecrets cannot be set at the same time" }}
16+
{{- end }}
17+
{{- /*
18+
Verify that additional secrets have name or namespace set.
19+
*/}}
20+
{{- range $_, $additionalSecret := .Values.exportKubeConfig.additionalSecrets }}
21+
{{- $nameSet := false }}
22+
{{- $namespaceSet := false }}
23+
{{- if $additionalSecret.name }}
24+
{{- if $additionalSecret.name | trim | ne "" }}
25+
{{- $nameSet = true }}
26+
{{- end }}
27+
{{- end }}
28+
{{- if $additionalSecret.namespace }}
29+
{{- if $additionalSecret.namespace | trim | ne "" }}
30+
{{- $namespaceSet = true }}
31+
{{- end }}
32+
{{- end }}
33+
{{- if not (or $nameSet $namespaceSet) }}
34+
{{- fail (cat "additional secret must have name and/or namespace set, found:" (toJson $additionalSecret)) }}
35+
{{- end }}
36+
{{- end }}
37+
{{- end }}

charts/vcluster/templates/clusterrole.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ rules:
7575
verbs: ["get", "watch", "list"]
7676
{{- end }}
7777
{{- if .Values.sync.fromHost.runtimeClasses.enabled }}
78-
- apiGroups: ["nodes.k8s.io"]
78+
- apiGroups: ["node.k8s.io"]
7979
resources: ["runtimeclasses"]
8080
verbs: ["get", "watch", "list"]
8181
{{- end }}

charts/vcluster/templates/service-monitor.yaml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@ metadata:
77
labels:
88
app: vcluster
99
chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
10+
{{- if or (not .Values.controlPlane.serviceMonitor.labels) (not (hasKey .Values.controlPlane.serviceMonitor.labels "release")) }}
1011
release: "{{ .Release.Name }}"
12+
{{- end}}
1113
heritage: "{{ .Release.Service }}"
1214
{{- if .Values.controlPlane.serviceMonitor.labels }}
1315
{{ toYaml .Values.controlPlane.serviceMonitor.labels | indent 4 }}
@@ -24,11 +26,15 @@ spec:
2426
release: "{{ .Release.Name }}"
2527
chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
2628
heritage: "{{ .Release.Service }}"
29+
vcluster.loft.sh/service: "true"
2730
endpoints:
2831
- interval: 30s
2932
port: https
3033
path: /metrics
3134
scheme: https
35+
relabelings:
36+
- targetLabel: endpoint
37+
replacement: "apiserver"
3238
tlsConfig:
3339
ca:
3440
secret:
@@ -41,4 +47,46 @@ spec:
4147
keySecret:
4248
name: vc-{{ .Release.Name }}
4349
key: client-key
50+
{{- if eq (include "vcluster.distro" .) "k8s" }}
51+
- interval: 30s
52+
port: https
53+
path: /controller-manager/metrics
54+
scheme: https
55+
relabelings:
56+
- targetLabel: endpoint
57+
replacement: "controller-manager"
58+
tlsConfig:
59+
ca:
60+
secret:
61+
name: vc-{{ .Release.Name }}
62+
key: certificate-authority
63+
cert:
64+
secret:
65+
name: vc-{{ .Release.Name }}
66+
key: client-certificate
67+
keySecret:
68+
name: vc-{{ .Release.Name }}
69+
key: client-key
70+
{{- if .Values.controlPlane.advanced.virtualScheduler.enabled }}
71+
- interval: 30s
72+
port: https
73+
path: /scheduler/metrics
74+
scheme: https
75+
relabelings:
76+
- targetLabel: endpoint
77+
replacement: "scheduler"
78+
tlsConfig:
79+
ca:
80+
secret:
81+
name: vc-{{ .Release.Name }}
82+
key: certificate-authority
83+
cert:
84+
secret:
85+
name: vc-{{ .Release.Name }}
86+
key: client-certificate
87+
keySecret:
88+
name: vc-{{ .Release.Name }}
89+
key: client-key
90+
{{- end }}
91+
{{- end }}
4492
{{- end }}

charts/vcluster/templates/service.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ metadata:
99
chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
1010
release: "{{ .Release.Name }}"
1111
heritage: "{{ .Release.Service }}"
12+
vcluster.loft.sh/service: "true"
1213
{{- if .Values.controlPlane.service.labels }}
1314
{{ toYaml .Values.controlPlane.service.labels | indent 4 }}
1415
{{- end }}

charts/vcluster/templates/statefulset.yaml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -118,10 +118,6 @@ spec:
118118
- name: coredns
119119
configMap:
120120
name: vc-coredns-{{ .Release.Name }}
121-
# - name: custom-config-volume
122-
# configMap:
123-
# name: coredns-custom
124-
# optional: true
125121
{{- end }}
126122
{{- if .Values.controlPlane.statefulSet.persistence.dataVolume }}
127123
{{ toYaml .Values.controlPlane.statefulSet.persistence.dataVolume | indent 8 }}

charts/vcluster/tests/service-monitor_test.yaml

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,33 @@ tests:
1616
controlPlane:
1717
serviceMonitor:
1818
enabled: true
19+
asserts:
20+
- hasDocuments:
21+
count: 1
22+
- equal:
23+
path: metadata.name
24+
value: vc-my-release
25+
- equal:
26+
path: metadata.namespace
27+
value: my-namespace
28+
- equal:
29+
path: spec.selector.matchLabels.app
30+
value: vcluster
31+
- lengthEqual:
32+
path: spec.endpoints
33+
count: 2
34+
35+
- it: check defaults k3s
36+
release:
37+
name: my-release
38+
namespace: my-namespace
39+
set:
40+
controlPlane:
41+
distro:
42+
k3s:
43+
enabled: true
44+
serviceMonitor:
45+
enabled: true
1946
asserts:
2047
- hasDocuments:
2148
count: 1
@@ -31,3 +58,38 @@ tests:
3158
- lengthEqual:
3259
path: spec.endpoints
3360
count: 1
61+
62+
- it: override release label
63+
release:
64+
name: my-release
65+
namespace: my-namespace
66+
set:
67+
controlPlane:
68+
serviceMonitor:
69+
enabled: true
70+
labels:
71+
release: kube-prometheus-stack
72+
asserts:
73+
- hasDocuments:
74+
count: 1
75+
- equal:
76+
path: metadata.labels.release
77+
value: kube-prometheus-stack
78+
79+
- it: check virtual scheduler
80+
release:
81+
name: my-release
82+
namespace: my-namespace
83+
set:
84+
controlPlane:
85+
advanced:
86+
virtualScheduler:
87+
enabled: true
88+
serviceMonitor:
89+
enabled: true
90+
asserts:
91+
- hasDocuments:
92+
count: 1
93+
- lengthEqual:
94+
path: spec.endpoints
95+
count: 3

charts/vcluster/tests/statefulset_test.yaml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -914,3 +914,25 @@ tests:
914914
- equal:
915915
path: kind
916916
value: StatefulSet
917+
918+
- it: fails when you set both exportKubeConfig.secret and exportKubeConfig.additionalSecrets
919+
set:
920+
exportKubeConfig:
921+
secret:
922+
name: my-secret
923+
additionalSecrets:
924+
- name: another-secret
925+
asserts:
926+
- failedTemplate:
927+
errorMessage: "exportKubeConfig.secret and exportKubeConfig.additionalSecrets cannot be set at the same time"
928+
929+
- it: fails when additional secret does not have at least name or namespace
930+
set:
931+
exportKubeConfig:
932+
additionalSecrets:
933+
- name: my-secret
934+
context: my-context
935+
- server: my-server
936+
asserts:
937+
- failedTemplate:
938+
errorMessage: "additional secret must have name and/or namespace set, found: {\"server\":\"my-server\"}"

charts/vcluster/values.schema.json

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1636,13 +1636,51 @@
16361636
},
16371637
"secret": {
16381638
"$ref": "#/$defs/ExportKubeConfigSecretReference",
1639-
"description": "Declare in which host cluster secret vCluster should store the generated virtual cluster kubeconfig.\nIf this is not defined, vCluster will create it with `vc-NAME`. If you specify another name,\nvCluster creates the config in this other secret."
1639+
"description": "Declare in which host cluster secret vCluster should store the generated virtual cluster kubeconfig.\nIf this is not defined, vCluster will create it with `vc-NAME`. If you specify another name,\nvCluster creates the config in this other secret.\n\nDeprecated: Use AdditionalSecrets instead."
1640+
},
1641+
"additionalSecrets": {
1642+
"items": {
1643+
"$ref": "#/$defs/ExportKubeConfigAdditionalSecretReference"
1644+
},
1645+
"type": "array",
1646+
"description": "AdditionalSecrets specifies the additional host cluster secrets in which vCluster will store the\ngenerated virtual cluster kubeconfigs."
16401647
}
16411648
},
16421649
"additionalProperties": false,
16431650
"type": "object",
16441651
"description": "ExportKubeConfig describes how vCluster should export the vCluster kubeconfig."
16451652
},
1653+
"ExportKubeConfigAdditionalSecretReference": {
1654+
"properties": {
1655+
"context": {
1656+
"type": "string",
1657+
"description": "Context is the name of the context within the generated kubeconfig to use."
1658+
},
1659+
"server": {
1660+
"type": "string",
1661+
"description": "Override the default https://localhost:8443 and specify a custom hostname for the generated kubeconfig."
1662+
},
1663+
"insecure": {
1664+
"type": "boolean",
1665+
"description": "If tls should get skipped for the server"
1666+
},
1667+
"serviceAccount": {
1668+
"$ref": "#/$defs/ExportKubeConfigServiceAccount",
1669+
"description": "ServiceAccount can be used to generate a service account token instead of the default certificates."
1670+
},
1671+
"name": {
1672+
"type": "string",
1673+
"description": "Name is the name of the secret where the kubeconfig is stored."
1674+
},
1675+
"namespace": {
1676+
"type": "string",
1677+
"description": "Namespace where vCluster stores the kubeconfig secret. If this is not equal to the namespace\nwhere you deployed vCluster, you need to make sure vCluster has access to this other namespace."
1678+
}
1679+
},
1680+
"additionalProperties": false,
1681+
"type": "object",
1682+
"description": "ExportKubeConfigAdditionalSecretReference defines the additional host cluster secret in which vCluster stores the generated virtual cluster kubeconfigs."
1683+
},
16461684
"ExportKubeConfigSecretReference": {
16471685
"properties": {
16481686
"name": {

charts/vcluster/values.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -972,6 +972,8 @@ exportKubeConfig:
972972
# Declare in which host cluster secret vCluster should store the generated virtual cluster kubeconfig.
973973
# If this is not defined, vCluster will create it with `vc-NAME`. If you specify another name,
974974
# vCluster creates the config in this other secret.
975+
976+
# Deprecated: Use AdditionalSecrets instead.
975977
secret:
976978
# Name is the name of the secret where the kubeconfig should get stored.
977979
name: ""

0 commit comments

Comments
 (0)