Skip to content

Commit

Permalink
Merge branch 'main' into enh/allow-use-of-client-public-keys
Browse files Browse the repository at this point in the history
  • Loading branch information
rrhubenov authored Oct 21, 2024
2 parents 31b25f8 + c38c17c commit 5dd25c3
Show file tree
Hide file tree
Showing 20 changed files with 147 additions and 39 deletions.
11 changes: 11 additions & 0 deletions .github/workflows/reuse-check.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
name: REUSE Compliance Check

on: [push, pull_request]

jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1
- name: REUSE Compliance Check
uses: fsfe/reuse-action@3ae3c6bdf1257ab19397fab11fd3312144692083 # v4.0.0
5 changes: 4 additions & 1 deletion .reuse/dep5
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,22 @@ Comment:
# --------------------------------------------------
# source code
Files:
.github/*
.gitignore
.golangci.yaml
.github/dependabot.yaml
CODEOWNERS
VERSION
charts/gardener-extension-shoot-lakom-service/.helmignore
charts/gardener-extension-shoot-lakom-service/templates/_helpers.tpl
charts/gardener-extension-shoot-lakom-service/templates/_versions.tpl
charts/gardener-extension-shoot-lakom-admission/.helmignore
charts/gardener-extension-shoot-lakom-admission/templates/_helpers.tpl
charts/lakom/.helmignore
charts/lakom/templates/_helpers.tpl
charts/lakom/templates/_versions.tpl
config/lakom/cosign/password
example/controller-registration.yaml
local-setup/.gitignore
go.mod
go.sum
*.json
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# SPDX-License-Identifier: Apache-2.0

############# builder
FROM golang:1.23.1 AS builder
FROM golang:1.23.2 AS builder

ARG EFFECTIVE_VERSION
ARG TARGETARCH
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v0.14.0-dev
v0.16.0-dev
4 changes: 4 additions & 0 deletions charts/gardener-extension-shoot-lakom-admission/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# SPDX-FileCopyrightText: 2024 SAP SE or an SAP affiliate company and Gardener contributors
#
# SPDX-License-Identifier: Apache-2.0

apiVersion: v1
appVersion: "1.0"
description: A Helm chart for the admission controller of gardener-extension-shoot-lakom
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# SPDX-FileCopyrightText: 2024 SAP SE or an SAP affiliate company and Gardener contributors
#
# SPDX-License-Identifier: Apache-2.0

apiVersion: v1
description: A Helm chart to deploy the gardener-extension-shoot-lakom-admission application related resources
name: application
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# SPDX-FileCopyrightText: 2024 SAP SE or an SAP affiliate company and Gardener contributors
#
# SPDX-License-Identifier: Apache-2.0

---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# SPDX-FileCopyrightText: 2024 SAP SE or an SAP affiliate company and Gardener contributors
#
# SPDX-License-Identifier: Apache-2.0

{{- if and .Values.global.virtualGarden.enabled ( not .Values.global.virtualGarden.user.name ) }}
apiVersion: v1
kind: ServiceAccount
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# SPDX-FileCopyrightText: 2024 SAP SE or an SAP affiliate company and Gardener contributors
#
# SPDX-License-Identifier: Apache-2.0

apiVersion: v1
description: A Helm chart to deploy the gardener-extension-shoot-lakom-admission runtime related resources
name: runtime
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# SPDX-FileCopyrightText: 2024 SAP SE or an SAP affiliate company and Gardener contributors
#
# SPDX-License-Identifier: Apache-2.0

---
apiVersion: apps/v1
kind: Deployment
metadata:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# SPDX-FileCopyrightText: 2024 SAP SE or an SAP affiliate company and Gardener contributors
#
# SPDX-License-Identifier: Apache-2.0

---
apiVersion: policy/v1
kind: PodDisruptionBudget
metadata:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# SPDX-FileCopyrightText: 2024 SAP SE or an SAP affiliate company and Gardener contributors
#
# SPDX-License-Identifier: Apache-2.0

---
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# SPDX-FileCopyrightText: 2024 SAP SE or an SAP affiliate company and Gardener contributors
#
# SPDX-License-Identifier: Apache-2.0

{{- if .Values.global.kubeconfig }}
apiVersion: v1
kind: Secret
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# SPDX-FileCopyrightText: 2024 SAP SE or an SAP affiliate company and Gardener contributors
#
# SPDX-License-Identifier: Apache-2.0

---
apiVersion: v1
kind: Service
metadata:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# SPDX-FileCopyrightText: 2024 SAP SE or an SAP affiliate company and Gardener contributors
#
# SPDX-License-Identifier: Apache-2.0

---
apiVersion: v1
kind: ServiceAccount
metadata:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# SPDX-FileCopyrightText: 2024 SAP SE or an SAP affiliate company and Gardener contributors
#
# SPDX-License-Identifier: Apache-2.0

---
{{- if .Values.global.vpa.enabled}}
apiVersion: autoscaling.k8s.io/v1
kind: VerticalPodAutoscaler
Expand Down
4 changes: 4 additions & 0 deletions charts/gardener-extension-shoot-lakom-admission/values.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# SPDX-FileCopyrightText: 2024 SAP SE or an SAP affiliate company and Gardener contributors
#
# SPDX-License-Identifier: Apache-2.0

global:
virtualGarden:
enabled: false
Expand Down
2 changes: 1 addition & 1 deletion example/controller-registration.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ helm:
rawChart: H4sIAAAAAAAAA+09a2/bOLbz2b+Cq8xi22Ilv5OOgV5c1/G0QdvEiDPdu7i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lLtQI5IUXMU38fvqedCfmFclp/MDWPWBPNKNPOtFHrzptWy2rXCZdXEUKzlDkakxIa5xMrFDqIe6ja8WlYjNFsvP9AayD1ZJ/1GTZxCWaW5yuol6eq4Az1tEraGVNZGrZYJM6iPGKxK9l/eHUnvNKQaNHvhQJJxTd6JTa8kbKimT3aSO73lJHygPlmz9Pkmvc1yS4LMN510SbLZt2TRjIvkrZipvL0z83roctwfj/vm6N1g3DTnzeuuOX7bb3WP07oqE/SLmf4G+pHwevjm7ByNfnv9/myA3g3/rgozlZqtdqfYZnh+uqJFBsvWPrHEE9vZDstlLnsPvWy8lPuQCUWpMrm+K79XlJBM9ReIcm+rPiuUVCh9KKj0maDlvaY1H/l5NBfuAAc4wAEOcIADHOAABzjAAbaCfwODb+9PAHgAAA==
values:
image:
tag: v0.14.0-dev
tag: v0.16.0-dev
---
apiVersion: core.gardener.cloud/v1beta1
kind: ControllerRegistration
Expand Down
62 changes: 39 additions & 23 deletions pkg/controller/lifecycle/actuator.go
Original file line number Diff line number Diff line change
Expand Up @@ -685,11 +685,10 @@ func getShootResources(webhookCaBundle []byte, extensionNamespace, shootAccessSe
ObjectSelector: &objectSelector,
}},
},
&rbacv1.Role{
&rbacv1.ClusterRole{
ObjectMeta: metav1.ObjectMeta{
Name: constants.LakomResourceReader,
Namespace: metav1.NamespaceSystem,
Labels: getLabels(),
Name: constants.LakomResourceReader,
Labels: getLabels(),
},
Rules: []rbacv1.PolicyRule{
{
Expand All @@ -699,25 +698,7 @@ func getShootResources(webhookCaBundle []byte, extensionNamespace, shootAccessSe
},
},
},
&rbacv1.RoleBinding{
ObjectMeta: metav1.ObjectMeta{
Name: constants.LakomResourceReader,
Namespace: metav1.NamespaceSystem,
Labels: getLabels(),
},
RoleRef: rbacv1.RoleRef{
APIGroup: "rbac.authorization.k8s.io",
Kind: "Role",
Name: constants.LakomResourceReader,
},
Subjects: []rbacv1.Subject{
{
Kind: rbacv1.ServiceAccountKind,
Name: shootAccessServiceAccountName,
Namespace: metav1.NamespaceSystem,
},
},
},
getRoleBinding(scope, shootAccessServiceAccountName),
)

if err != nil {
Expand Down Expand Up @@ -752,3 +733,38 @@ func getClientKeys(ctx context.Context, client client.Client, resources []v1beta
return clientKeys, nil
}

func getRoleBinding(scope lakom.ScopeType, shootAccessServiceAccountName string) client.Object {
roleRef := rbacv1.RoleRef{
APIGroup: "rbac.authorization.k8s.io",
Kind: "ClusterRole",
Name: constants.LakomResourceReader,
}
subjects := []rbacv1.Subject{
{
Kind: rbacv1.ServiceAccountKind,
Name: shootAccessServiceAccountName,
Namespace: metav1.NamespaceSystem,
},
}

if scope == lakom.Cluster {
return &rbacv1.ClusterRoleBinding{
ObjectMeta: metav1.ObjectMeta{
Name: constants.LakomResourceReader,
Labels: getLabels(),
},
RoleRef: roleRef,
Subjects: subjects,
}
}

return &rbacv1.RoleBinding{
ObjectMeta: metav1.ObjectMeta{
Name: constants.LakomResourceReader,
Namespace: metav1.NamespaceSystem,
Labels: getLabels(),
},
RoleRef: roleRef,
Subjects: subjects,
}
}
44 changes: 32 additions & 12 deletions pkg/controller/lifecycle/actuator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@ var _ = Describe("Actuator", func() {
Expect(manifests).To(ConsistOf(
expectedSeedValidatingWebhook(caBundle, extensionNamespace, managedByGardenerObjectSelector, kubeSystemNamespaceSelector),
expectedShootMutatingWebhook(caBundle, extensionNamespace, managedByGardenerObjectSelector, kubeSystemNamespaceSelector),
expectedShootRole(),
expectedShootRoleBinding(shootAccessServiceAccountName),
expectedShootClusterRole(),
expectedShootRoleBinding(shootAccessServiceAccountName, scope),
))
})

Expand Down Expand Up @@ -132,16 +132,17 @@ var _ = Describe("Actuator", func() {
)

DescribeTable("Should ensure the rolebinding is correctly set",
func(saName string) {
resources, err := getShootResources(caBundle, extensionNamespace, saName, scope)
func(saName string, lakomScope lakom.ScopeType) {
resources, err := getShootResources(caBundle, extensionNamespace, saName, lakomScope)
Expect(err).ToNot(HaveOccurred())
manifests, err := test.ExtractManifestsFromManagedResourceData(resources)
Expect(err).ToNot(HaveOccurred())

Expect(manifests).To(ContainElement(expectedShootRoleBinding(saName)))
Expect(manifests).To(ContainElement(expectedShootRoleBinding(saName, lakomScope)))
},
Entry("ServiceAccount name: test", "test"),
Entry("ServiceAccount name: foo-bar", "foo-bar"),
Entry("ServiceAccount name: test, scope: KubeSystemManagedByGardener", "test", lakom.KubeSystemManagedByGardener),
Entry("ServiceAccount name: foo-bar, scope: KubeSystem", "foo-bar", lakom.KubeSystem),
Entry("ServiceAccount name: foo-bar, scope: Cluster", "foo-bar", lakom.Cluster),
)

DescribeTable("Should return the correct object and namespace selectors based on scope",
Expand Down Expand Up @@ -326,16 +327,15 @@ webhooks:
`
}

func expectedShootRole() string {
func expectedShootClusterRole() string {
return `apiVersion: rbac.authorization.k8s.io/v1
kind: Role
kind: ClusterRole
metadata:
creationTimestamp: null
labels:
app.kubernetes.io/name: lakom
app.kubernetes.io/part-of: shoot-lakom-service
name: gardener-extension-shoot-lakom-service-resource-reader
namespace: kube-system
rules:
- apiGroups:
- ""
Expand All @@ -346,7 +346,27 @@ rules:
`
}

func expectedShootRoleBinding(saName string) string {
func expectedShootRoleBinding(saName string, lakomScope lakom.ScopeType) string {
if lakomScope == lakom.Cluster {
return `apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
creationTimestamp: null
labels:
app.kubernetes.io/name: lakom
app.kubernetes.io/part-of: shoot-lakom-service
name: gardener-extension-shoot-lakom-service-resource-reader
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: gardener-extension-shoot-lakom-service-resource-reader
subjects:
- kind: ServiceAccount
name: ` + saName + `
namespace: kube-system
`
}

return `apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
Expand All @@ -358,7 +378,7 @@ metadata:
namespace: kube-system
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: Role
kind: ClusterRole
name: gardener-extension-shoot-lakom-service-resource-reader
subjects:
- kind: ServiceAccount
Expand Down

0 comments on commit 5dd25c3

Please sign in to comment.