Skip to content

Commit 218d7ea

Browse files
Adapt to new shoot access restriction configurations in CloudProfile, Seed, and Shoot APIs (#2163)
* Adapt to new shoot access restriction configurations in CloudProfile, Seed, and Shoot APIs * Update frontend/src/store/cloudProfile/index.js Co-authored-by: Holger Koser <[email protected]> --------- Co-authored-by: Holger Koser <[email protected]>
1 parent 3eb5f93 commit 218d7ea

File tree

10 files changed

+197
-183
lines changed

10 files changed

+197
-183
lines changed

charts/__tests__/gardener-dashboard/runtime/dashboard/__snapshots__/configmap.spec.js.snap

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,9 @@ exports[`gardener-dashboard configmap access restrictions should render the temp
99
"display": {
1010
"description": "display Foo description",
1111
"title": "display Foo",
12-
"visibleIf": true,
1312
},
1413
"input": {
1514
"description": "input Foo description",
16-
"inverted": true,
1715
"title": "input Foo",
1816
},
1917
"key": "foo",
@@ -31,9 +29,6 @@ exports[`gardener-dashboard configmap access restrictions should render the temp
3129
"key": "foo-option-1",
3230
},
3331
{
34-
"display": {
35-
"visibleIf": true,
36-
},
3732
"input": {
3833
"description": "input Foo Option 2 description",
3934
"inverted": true,
@@ -56,7 +51,7 @@ exports[`gardener-dashboard configmap access restrictions should render the temp
5651
"items": [
5752
{
5853
"display": {
59-
"visibleIf": true,
54+
"title": "Foo Only",
6055
},
6156
"input": {
6257
"title": "Foo",

charts/__tests__/gardener-dashboard/runtime/dashboard/configmap.spec.js

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ describe('gardener-dashboard', function () {
250250
{
251251
key: 'foo',
252252
display: {
253-
visibleIf: true,
253+
title: 'Foo Only',
254254
},
255255
input: {
256256
title: 'Foo',
@@ -279,14 +279,12 @@ describe('gardener-dashboard', function () {
279279
{
280280
key: 'foo',
281281
display: {
282-
visibleIf: true,
283282
title: 'display Foo',
284283
description: 'display Foo description',
285284
},
286285
input: {
287286
title: 'input Foo',
288287
description: 'input Foo description',
289-
inverted: true,
290288
},
291289
options: [
292290
{
@@ -304,9 +302,6 @@ describe('gardener-dashboard', function () {
304302
},
305303
{
306304
key: 'foo-option-2',
307-
display: {
308-
visibleIf: true,
309-
},
310305
input: {
311306
title: 'input Foo Option 2',
312307
description: 'input Foo Option 2 description',

charts/gardener-dashboard/charts/runtime/templates/dashboard/configmap.yaml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -284,26 +284,27 @@ data:
284284
items:
285285
{{- range .Values.global.dashboard.frontendConfig.accessRestriction.items }}
286286
- key: {{ .key }}
287+
{{- if .display }}
287288
display:
288-
visibleIf: {{ .display.visibleIf }}{{- if .display.title }}
289+
{{- if .display.title }}
289290
title: {{ .display.title }}{{- end }}{{- if .display.description }}
290291
description: {{ .display.description }}{{- end }}
292+
{{- end }}
291293
input:
292294
title: {{ quote .input.title }}
293295
{{- if .input.description }}
294296
description: {{ quote .input.description }}
295297
{{- end }}
296-
{{- if .input.inverted }}
297-
inverted: {{ .input.inverted }}
298-
{{- end }}
299298
{{- if .options }}
300299
options:
301300
{{- range .options }}
302301
- key: {{ .key }}
302+
{{- if .display }}
303303
display:
304304
visibleIf: {{ .display.visibleIf }}{{- if .display.title }}
305305
title: {{ .display.title }}{{- end }}{{- if .display.description }}
306306
description: {{ .display.description }}{{- end }}
307+
{{- end }}
307308
input:
308309
title: {{ quote .input.title }}
309310
{{- if .input.description }}

charts/gardener-dashboard/values.yaml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -289,16 +289,14 @@ global:
289289
# accessRestriction:
290290
# noItemsText: No access restriction options available for region ${region} and cloud profile ${cloudProfile}
291291
# items:
292-
# - key: seed.gardener.cloud/eu-access
292+
# - key: eu-access
293293
# display:
294-
# visibleIf: true
295294
# # title: foo # optional title, if not defined key will be used
296295
# # description: bar # optional description displayed in a tooltip
297296
# input:
298297
# title: EU Access
299298
# description: |
300299
# This service is offered to you with our regular SLAs and 24x7 support for the control plane of the cluster. 24x7 support for cluster add-ons and nodes is only available if you meet the following conditions:
301-
# # inverted: false
302300
# options:
303301
# - key: support.gardener.cloud/eu-access-for-cluster-addons
304302
# display:
Lines changed: 88 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -1,88 +1,115 @@
11
# Access Restrictions
22

3-
The dashboard can be configured with access restrictions.
3+
For an overview and usage of access restrictions, refer to the [Access Restrictions Usage Documentation](https://github.com/gardener/gardener/blob/master/docs/usage/shoot/access_restrictions.md).
44

5-
<img src="../images/access-restrictions-1.png">
5+
## Configuring the Dashboard
66

7-
Access restrictions are shown for regions that have a matching label in the `CloudProfile`
8-
```yaml
9-
regions:
10-
- name: pangaea-north-1
11-
zones:
12-
- name: pangaea-north-1a
13-
- name: pangaea-north-1b
14-
- name: pangaea-north-1c
15-
labels:
16-
seed.gardener.cloud/eu-access: "true"
17-
```
7+
Operators can configure the Gardener Dashboard to define available access restrictions and their options. This configuration determines what is displayed to end-users in the Dashboard UI.
188

19-
- If the user selects the access restriction, `spec.seedSelector.matchLabels[key]` will be set.
20-
- When selecting an option, `metadata.annotations[optionKey]` will be set.
9+
### Configuration Methods
2110

22-
The value that is set depends on the configuration. See _2._ under _Configuration_ section below.
11+
The Dashboard can be installed and configured in two ways:
2312

24-
```yaml
25-
apiVersion: core.gardener.cloud/v1beta1
26-
kind: Shoot
27-
metadata:
28-
annotations:
29-
support.gardener.cloud/eu-access-for-cluster-addons: "true"
30-
support.gardener.cloud/eu-access-for-cluster-nodes: "true"
31-
...
32-
spec:
33-
seedSelector:
34-
matchLabels:
35-
seed.gardener.cloud/eu-access: "true"
36-
```
13+
1. **Via Helm Chart**: Configuration is provided through the `values.yaml` file.
14+
2. **Via Gardener Operator**: Configuration is provided through a ConfigMap referenced by the Gardener Operator.
3715

38-
In order for the shoot (with enabled access restriction) to be scheduled on a seed, the seed needs to have the label set. E.g.
39-
```yaml
40-
apiVersion: core.gardener.cloud/v1beta1
41-
kind: Seed
42-
metadata:
43-
labels:
44-
seed.gardener.cloud/eu-access: "true"
45-
...
46-
```
16+
#### 1. Installing via Helm Chart
17+
18+
When installing the Dashboard via Helm chart, access restrictions are configured in the `values.yaml` file.
4719

48-
<img src="../images/access-restrictions-2.png">
20+
**Example `values.yaml`:**
4921

50-
**Configuration**
51-
As gardener administrator:
52-
1. you can control the visibility of the chips with the `accessRestriction.items[].display.visibleIf` and `accessRestriction.items[].options[].display.visibleIf` property. E.g. in this example the access restriction chip is shown if the value is true and the option is shown if the value is false.
53-
2. you can control the value of the input field (switch / checkbox) with the `accessRestriction.items[].input.inverted` and `accessRestriction.items[].options[].input.inverted` property. Setting the `inverted` property to `true` will invert the value. That means that when selecting the input field the value will be`'false'` instead of `'true'`.
54-
3. you can configure the text that is displayed when no access restriction options are available by setting `accessRestriction.noItemsText`
55-
example `values.yaml`:
5622
```yaml
5723
accessRestriction:
5824
noItemsText: No access restriction options available for region {region} and cloud profile {cloudProfile}
5925
items:
60-
- key: seed.gardener.cloud/eu-access
26+
- key: eu-access-only
6127
display:
62-
visibleIf: true
63-
# title: foo # optional title, if not defined key will be used
64-
# description: bar # optional description displayed in a tooltip
28+
title: EU Access Only # Optional title; if not specified, `key` is used
29+
description: Restricts access to EU regions only # Optional description displayed in a tooltip
6530
input:
6631
title: EU Access
6732
description: |
68-
This service is offered to you with our regular SLAs and 24x7 support for the control plane of the cluster. 24x7 support for cluster add-ons and nodes is only available if you meet the following conditions:
33+
This service is offered with our regular SLAs and 24x7 support for the control plane of the cluster. 24x7 support for cluster add-ons and nodes is only available if you meet the following conditions:
6934
options:
7035
- key: support.gardener.cloud/eu-access-for-cluster-addons
7136
display:
72-
visibleIf: false
73-
# title: bar # optional title, if not defined key will be used
74-
# description: baz # optional description displayed in a tooltip
37+
visibleIf: true # Controls visibility based on a condition
7538
input:
76-
title: No personal data is used as name or in the content of Gardener or Kubernetes resources (e.g. Gardener project name or Kubernetes namespace, configMap or secret in Gardener or Kubernetes)
39+
title: No personal data is used in resource names or contents
7740
description: |
78-
If you can't comply, only third-level/dev support at usual 8x5 working hours in EEA will be available to you for all cluster add-ons such as DNS and certificates, Calico overlay network and network policies, kube-proxy and services, and everything else that would require direct inspection of your cluster through its API server
79-
inverted: true
41+
If you can't comply, only third-level support during usual 8x5 working hours in the EEA will be available for cluster add-ons.
42+
inverted: false # Determines if the input value is inverted
8043
- key: support.gardener.cloud/eu-access-for-cluster-nodes
8144
display:
82-
visibleIf: false
45+
visibleIf: false # Controls visibility based on a condition
8346
input:
84-
title: No personal data is stored in any Kubernetes volume except for container file system, emptyDirs, and persistentVolumes (in particular, not on hostPath volumes)
47+
title: No personal data is stored in Kubernetes volumes except certain types
8548
description: |
86-
If you can't comply, only third-level/dev support at usual 8x5 working hours in EEA will be available to you for all node-related components such as Docker and Kubelet, the operating system, and everything else that would require direct inspection of your nodes through a privileged pod or SSH
87-
inverted: true
88-
```
49+
If you can't comply, only third-level support during usual 8x5 working hours in the EEA will be available for node-related components.
50+
inverted: true # Determines if the input value is inverted
51+
```
52+
53+
#### 2. Installing via Gardener Operator
54+
55+
When the Dashboard is installed via the Gardener Operator, access restrictions are configured in a separate `ConfigMap` referenced by the Operator using `.spec.virtualCluster.gardener.gardenerDashboard.frontendConfigMapRef` within the `Garden` resource.
56+
57+
**Example ConfigMap:**
58+
59+
```yaml
60+
apiVersion: v1
61+
kind: ConfigMap
62+
metadata:
63+
name: gardener-dashboard-frontend
64+
namespace: garden
65+
data:
66+
frontend-config.yaml: |
67+
accessRestriction:
68+
noItemsText: No access restriction options available for region {region} and cloud profile {cloudProfile}
69+
items:
70+
- key: eu-access-only
71+
display:
72+
title: EU Access Only
73+
description: Restricts access to EU regions only
74+
input:
75+
title: EU Access
76+
description: |
77+
This service is offered with our regular SLAs and 24x7 support for the control plane of the cluster. 24x7 support for cluster add-ons and nodes is only available if you meet the following conditions:
78+
options:
79+
- key: support.gardener.cloud/eu-access-for-cluster-addons
80+
display:
81+
visibleIf: true
82+
input:
83+
title: No personal data is used in resource names or contents
84+
description: |
85+
If you can't comply, only third-level support during usual 8x5 working hours in the EEA will be available for cluster add-ons.
86+
inverted: false
87+
- key: support.gardener.cloud/eu-access-for-cluster-nodes
88+
display:
89+
visibleIf: false
90+
input:
91+
title: No personal data is stored in Kubernetes volumes except certain types
92+
description: |
93+
If you can't comply, only third-level support during usual 8x5 working hours in the EEA will be available for node-related components.
94+
inverted: true
95+
```
96+
97+
### Understanding `input` and `display`
98+
99+
- **`display`**:
100+
- **Purpose**: Defines how the access restriction and its options are presented in the Dashboard UI using **chips**.
101+
- **Properties**:
102+
- `title`: Label shown on the chip. If not specified, `key` is used.
103+
- `description`: Tooltip content when hovering over the chip.
104+
- `visibleIf` (for options): Determines if the option's chip is displayed based on its value.
105+
106+
- **`input`**:
107+
- **Purpose**: Configures the interactive elements (switches, checkboxes) that users interact with to enable or disable access restrictions and options.
108+
- **Properties**:
109+
- `title`: Label for the input control.
110+
- `description`: Detailed information or instructions for the input control.
111+
- `inverted` (for options): Determines if the input value is inverted (`true` or `false`). When `inverted` is `true`, the control behaves inversely (e.g., checked means `false`).
112+
113+
### No Access Restrictions Available
114+
115+
If no access restrictions are available for the selected region and cloud profile, the text specified in `accessRestriction.noItemsText` is displayed. Placeholders `{region}` and `{cloudProfile}` can be used in the text.

frontend/__fixtures__/config.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ export default {
5959
{
6060
key: 'seed.gardener.cloud/eu-access',
6161
display: {
62-
visibleIf: true,
6362
title: 'Limited Access',
6463
description: 'Clusters will not be migrated ...',
6564
},

frontend/__tests__/composables/useShootAccessRestrictions.spec.js

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ describe('composables', () => {
3131
accessRestrictionDefinition = {
3232
key: 'foo',
3333
input: {
34-
inverted: false,
34+
title: 'Foo',
3535
},
3636
options: [
3737
{
@@ -62,20 +62,20 @@ describe('composables', () => {
6262
}
6363
shootResource = shallowRef({
6464
metadata: {
65-
annotations: {
66-
'foo-option-1': 'false',
67-
'foo-option-2': 'false',
68-
'foo-option-3': 'true',
69-
},
7065
},
7166
spec: {
7267
cloudProfileName: 'cloud-profile-name',
7368
region: 'region',
74-
seedSelector: {
75-
matchLabels: {
76-
foo: 'true',
69+
accessRestrictions: [
70+
{
71+
name: 'foo',
72+
options: {
73+
'foo-option-1': 'false',
74+
'foo-option-2': 'false',
75+
'foo-option-3': 'true',
76+
},
7777
},
78-
},
78+
],
7979
},
8080
})
8181

@@ -93,23 +93,22 @@ describe('composables', () => {
9393
})
9494
const { key, options } = accessRestrictionDefinition
9595
expect(getAccessRestrictionValue(key)).toBe(true)
96-
expect(options.map(({ key }) => getAccessRestrictionOptionValue(key))).toEqual([
96+
expect(options.map(({ key: optionKey }) => getAccessRestrictionOptionValue(key, optionKey))).toEqual([
9797
false,
9898
true,
9999
false,
100100
false,
101101
])
102102
})
103103

104-
it('should invert access restriction', () => {
105-
accessRestrictionDefinition.input.inverted = true
104+
it('should get access restriction value', () => {
106105
const {
107106
getAccessRestrictionValue,
108107
} = useShootAccessRestrictions(shootResource, {
109108
cloudProfileStore,
110109
})
111110
const { key } = accessRestrictionDefinition
112-
expect(getAccessRestrictionValue(key)).toBe(false)
111+
expect(getAccessRestrictionValue(key)).toBe(true)
113112
})
114113

115114
it('should not invert option', () => {
@@ -120,7 +119,7 @@ describe('composables', () => {
120119
} = useShootAccessRestrictions(shootResource, {
121120
cloudProfileStore,
122121
})
123-
expect(getAccessRestrictionOptionValue(option.key)).toBe(false)
122+
expect(getAccessRestrictionOptionValue(accessRestrictionDefinition.key, option.key)).toBe(false)
124123
})
125124

126125
it('should invert option', () => {
@@ -131,7 +130,7 @@ describe('composables', () => {
131130
} = useShootAccessRestrictions(shootResource, {
132131
cloudProfileStore,
133132
})
134-
expect(getAccessRestrictionOptionValue(option.key)).toBe(true)
133+
expect(getAccessRestrictionOptionValue(accessRestrictionDefinition.key, option.key)).toBe(true)
135134
})
136135
})
137136
})

0 commit comments

Comments
 (0)