Skip to content

Commit

Permalink
add e2e test for deployment on Garden runtime cluster
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinWeindel committed Jan 13, 2025
1 parent 81d7278 commit 420ecb1
Show file tree
Hide file tree
Showing 31 changed files with 824 additions and 130 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
/local
**/dev
/hack/tools/bin
/gardener

*.coverprofile
*.html
Expand Down
27 changes: 25 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ REPO_ROOT := $(shell dirname $(realpath $(lastword $(MAKEFILE_
HACK_DIR := $(REPO_ROOT)/hack
VERSION := $(shell cat "$(REPO_ROOT)/VERSION")
EFFECTIVE_VERSION := $(VERSION)-$(shell git rev-parse HEAD)
BUILD_DATE := $(shell date '+%Y-%m-%dT%H:%M:%S%z' | sed 's/\([0-9][0-9]\)$$/:\1/g')
LD_FLAGS := "-w $(shell bash $(GARDENER_HACK_DIR)/get-build-ld-flags.sh k8s.io/component-base $(REPO_ROOT)/VERSION $(EXTENSION_PREFIX))"
LEADER_ELECTION := false
IGNORE_OPERATION_ANNOTATION := true
Expand Down Expand Up @@ -82,8 +83,9 @@ check-generate:

.PHONY: check
check: $(GOIMPORTS) $(GOLANGCI_LINT) $(HELM)
@bash $(GARDENER_HACK_DIR)/check.sh --golangci-lint-config=./.golangci.yaml ./cmd/... ./pkg/... ./test/...
@bash $(GARDENER_HACK_DIR)/check-charts.sh ./charts
#@bash $(GARDENER_HACK_DIR)/check.sh --golangci-lint-config=./.golangci.yaml ./cmd/... ./pkg/... ./test/...
#@bash $(GARDENER_HACK_DIR)/check-charts.sh ./charts
@GARDENER_HACK_DIR=$(GARDENER_HACK_DIR) $(REPO_ROOT)/hack/check-skaffold-deps.sh

.PHONY: generate
generate: $(CONTROLLER_GEN) $(GEN_CRD_API_REFERENCE_DOCS) $(HELM) $(MOCKGEN) $(YQ) $(VGOPATH)
Expand Down Expand Up @@ -120,3 +122,24 @@ verify: check format test sast

.PHONY: verify-extended
verify-extended: check-generate check format test-cov test-clean sast-report

.PHONY: test-e2e-local
test-e2e-local: $(KIND) $(YQ) $(GINKGO)
@$(REPO_ROOT)/hack/test-e2e-provider-local.sh --procs=3

.PHONY: extension-up
extension-up: export EXTENSION_VERSION = $(VERSION)
extension-up: export SKAFFOLD_DEFAULT_REPO = garden.local.gardener.cloud:5001
extension-up: export SKAFFOLD_PUSH = true
extension-up: export SOURCE_DATE_EPOCH = $(shell date -d $(BUILD_DATE) +%s)
extension-up: export LD_FLAGS = $(shell bash $(GARDENER_HACK_DIR)/get-build-ld-flags.sh k8s.io/component-base $(REPO_ROOT)/VERSION gardener-extension-shoot-cert-service $(BUILD_DATE))
extension-up: export EXTENSION_GARDENER_HACK_DIR = $(GARDENER_HACK_DIR)
extension-up: $(SKAFFOLD) $(HELM) $(KUBECTL)
$(SKAFFOLD) run --cache-artifacts=true

extension-down: $(KUBECTL)
kubectl get extop extension-shoot-cert-service -oyaml | yq eval '.spec.deployment.extension.values.gardenerCertificates.seed.enabled = false' | kubectl replace -f -
kubectl delete mutatingwebhookconfigurations.admissionregistration.k8s.io gardener-extension-shoot-cert-service --ignore-not-found
kubectl -n garden annotate extension.extensions.gardener.cloud shoot-cert-service confirmation.gardener.cloud/deletion=true --overwrite || echo "ignored"
kubectl -n garden delete extension.extensions.gardener.cloud shoot-cert-service --ignore-not-found
$(SKAFFOLD) delete
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,14 @@ ca:
{{- end }}

{{- define "image" -}}
{{- if hasPrefix "sha256:" .Values.image.tag }}
{{- printf "%s@%s" .Values.image.repository .Values.image.tag }}
{{- if .Values.skaffoldImage }}
{{- .Values.skaffoldImage }}
{{- else }}
{{- printf "%s:%s" .Values.image.repository .Values.image.tag }}
{{- if hasPrefix "sha256:" .Values.image.tag }}
{{- printf "%s@%s" .Values.image.repository .Values.image.tag }}
{{- else }}
{{- printf "%s:%s" .Values.image.repository .Values.image.tag }}
{{- end }}
{{- end }}
{{- end }}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
name: issuers.cert.gardener.cloud
annotations:
resources.gardener.cloud/keep-object: "true"
labels:
app.kubernetes.io/name: gardener-extension-shoot-cert-service
app.kubernetes.io/instance: {{ .Release.Name }}
Expand Down Expand Up @@ -215,6 +217,8 @@ apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
name: certificates.cert.gardener.cloud
annotations:
resources.gardener.cloud/keep-object: "true"
labels:
shoot.gardener.cloud/no-cleanup: "true"
app.kubernetes.io/name: gardener-extension-shoot-cert-service
Expand Down Expand Up @@ -616,6 +620,8 @@ apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
name: certificaterevocations.cert.gardener.cloud
annotations:
resources.gardener.cloud/keep-object: "true"
labels:
shoot.gardener.cloud/no-cleanup: "true"
app.kubernetes.io/name: gardener-extension-shoot-cert-service
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ spec:
app.kubernetes.io/instance: {{ .Release.Name }}
networking.gardener.cloud/to-runtime-apiserver: allowed
networking.gardener.cloud/to-dns: allowed
networking.resources.gardener.cloud/to-all-istio-ingresses-istio-ingressgateway-tcp-9443: allowed
spec:
{{- if .Values.gardener.runtimeCluster.enabled }}
priorityClassName: {{ .Values.gardener.runtimeCluster.priorityClassName }}
Expand All @@ -44,8 +45,7 @@ spec:
- name: gardener-extension-shoot-cert-service
image: {{ include "image" . }}
imagePullPolicy: {{ .Values.image.pullPolicy }}
command:
- /gardener-extension-shoot-cert-service
args:
- --config=/etc/cert-service/config.yaml
- --max-concurrent-reconciles={{ .Values.controllers.concurrentSyncs }}
- --healthcheck-max-concurrent-reconciles={{ .Values.controllers.healthcheck.concurrentSyncs }}
Expand Down Expand Up @@ -77,8 +77,12 @@ spec:
value: "true"
{{- end }}
{{- if .Values.gardenerCertificates.seed.enabled }}
- name: SEED_NAME
value: {{ .Values.gardener.seed.name }}
- name: SEED_INGRESS_DNS_DOMAIN
value: {{ .Values.gardener.seed.ingressDomain }}
- name: SEED_DNS_SECRET_ROLE
value: {{ .Values.gardenerCertificates.seed.dnsSecretRole }}
{{- end }}
{{- if .Values.imageVectorOverwrite }}
- name: IMAGEVECTOR_OVERWRITE
Expand Down
1 change: 1 addition & 0 deletions charts/gardener-extension-shoot-cert-service/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ disableControllers: []
gardenerCertificates:
seed:
enabled: false # if true, a special cert-controller-manager is deployed to provide the TLS certificate for the seed ingress domain
# dnsSecretRole: internal-domain # the "gardener.cloud/role" label to look up the DNS secret in the seed namespace on the virtual garden to be used for DNS challenges
runtimeCluster:
enabled: false # if true, a special cert-controller-manager is deployed to provide the TLS certificate for the virtual cluster kube-apiserver and garden ingress domain
virtualKubeAPIServerIncludePrimaryDomain: false # if false, the first domain name of the virtual cluster kube-apiserver is excluded from TLS SNI config
Expand Down
4 changes: 2 additions & 2 deletions cmd/gardener-extension-shoot-cert-service/app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (
operatorv1alpha1 "github.com/gardener/gardener/pkg/apis/operator/v1alpha1"
"github.com/spf13/cobra"
corev1 "k8s.io/api/core/v1"
componentbaseconfig "k8s.io/component-base/config"
componentbaseconfigv1alpha1 "k8s.io/component-base/config/v1alpha1"
"k8s.io/component-base/version/verflag"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/manager"
Expand Down Expand Up @@ -58,7 +58,7 @@ func NewServiceControllerCommand() *cobra.Command {

func (o *Options) run(ctx context.Context) error {
// TODO: Make these flags configurable via command line parameters or component config file.
util.ApplyClientConnectionConfigurationToRESTConfig(&componentbaseconfig.ClientConnectionConfiguration{
util.ApplyClientConnectionConfigurationToRESTConfig(&componentbaseconfigv1alpha1.ClientConnectionConfiguration{
QPS: 100.0,
Burst: 130,
}, o.restOptions.Completed().Config)
Expand Down
Loading

0 comments on commit 420ecb1

Please sign in to comment.