Skip to content

Commit

Permalink
Improve the skaffold setup of the extension. Fix make extension-down (
Browse files Browse the repository at this point in the history
gardener#40)

* This PR improves the skaffold setup of the extension

The change incorporates the changes from gardener/gardener#7757 and gardener/gardener-extension-shoot-rsyslog-relp#5.

It simplifies the skaffold setup and drops the ControllerRegistration chart (`./charts/registration`). The `make extension-up` target is now fixed and invoked by the `make ci-e2e-kind` target now.

* Add docs

* Drop the `make start`, `make start-admission` and `make debug-admission` targets

Dropping these targets makes sense because:
- similar to gardener we have skaffold setup and gardener dropped `make start-*` targets
- some of these targets were already outdated, hence, it means that they are not used
- the setup required for these targets is not easy (compared to the skaffold setup), or at least not documented

We already have the skaffold-based local setup.
  • Loading branch information
ialidzhikov authored Sep 11, 2023
1 parent dc34900 commit a73babe
Show file tree
Hide file tree
Showing 23 changed files with 96 additions and 367 deletions.
64 changes: 0 additions & 64 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,67 +20,16 @@ REPO_ROOT := $(shell dirname $(realpath $(lastword $(MAKEFILE_
HACK_DIR := $(REPO_ROOT)/hack
VERSION := $(shell cat "$(REPO_ROOT)/VERSION")
LD_FLAGS := "-w -X github.com/gardener/$(EXTENSION_PREFIX)-$(NAME)/pkg/version.Version=$(IMAGE_TAG)"
LEADER_ELECTION := false
IGNORE_OPERATION_ANNOTATION := true
PARALLEL_E2E_TESTS := 2


WEBHOOK_CONFIG_PORT := 8444
WEBHOOK_CONFIG_MODE := url
WEBHOOK_CONFIG_URL := host.docker.internal:${WEBHOOK_CONFIG_PORT}
WEBHOOK_CERT_DIR := ./example/admission
EXTENSION_NAMESPACE :=

WEBHOOK_PARAM := --webhook-config-url=${WEBHOOK_CONFIG_URL}
ifeq (${WEBHOOK_CONFIG_MODE}, service)
WEBHOOK_PARAM := --webhook-config-namespace=${EXTENSION_NAMESPACE}
endif

#########################################
# Tools #
#########################################

TOOLS_DIR := hack/tools
include $(REPO_ROOT)/vendor/github.com/gardener/gardener/hack/tools.mk

#########################################
# Rules for local development scenarios #
#########################################

.PHONY: start
start:
@LEADER_ELECTION_NAMESPACE=garden GO111MODULE=on go run \
-mod=vendor \
-ldflags $(LD_FLAGS) \
./cmd/$(EXTENSION_PREFIX)-$(NAME) \
--ignore-operation-annotation=$(IGNORE_OPERATION_ANNOTATION) \
--leader-election=$(LEADER_ELECTION) \
--config=./example/00-config.yaml \
--gardener-version="v1.39.0"


.PHONY: start-admission
start-admission:
@LEADER_ELECTION_NAMESPACE=garden GO111MODULE=on go run \
-mod=vendor \
-ldflags ${LD_FLAGS} \
./cmd/${EXTENSION_PREFIX}-${ADMISSION_NAME} \
--kubeconfig=dev/garden-kubeconfig.yaml \
--webhook-config-server-host=0.0.0.0 \
--webhook-config-server-port=9443 \
--webhook-config-cert-dir=${WEBHOOK_CERT_DIR}

.PHONY: debug-admission
debug-admission:
LEADER_ELECTION_NAMESPACE=garden dlv debug \
./cmd/${EXTENSION_PREFIX}-${ADMISSION_NAME} -- \
--leader-election=${LEADER_ELECTION} \
--kubeconfig=dev/garden-kubeconfig.yaml \
--webhook-config-server-host=0.0.0.0 \
--webhook-config-server-port=9443 \
--health-bind-address=:8085 \
--webhook-config-cert-dir=${WEBHOOK_CERT_DIR}

#################################################################
# Rules related to binary build, Docker image build and release #
#################################################################
Expand Down Expand Up @@ -177,16 +126,3 @@ extension-dev: $(SKAFFOLD) $(HELM)

extension-down: $(SKAFFOLD) $(HELM)
$(SKAFFOLD) delete

# use static label for skaffold to prevent rolling all gardener components on every `skaffold` invocation
admission-up admission-down: export SKAFFOLD_LABEL = skaffold.dev/run-id=admission-local
admission-%: export SKAFFOLD_FILENAME = skaffold-admission.yaml

admission-up: $(SKAFFOLD) $(KIND) $(HELM)
$(SKAFFOLD) run

admission-dev: $(SKAFFOLD) $(HELM)
$(SKAFFOLD) dev --cleanup=false --trigger=manual

admission-down: $(SKAFFOLD) $(HELM)
$(SKAFFOLD) delete
1 change: 1 addition & 0 deletions charts/admission/charts/runtime/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ spec:
# TODO(ialidzhikov): Double check whether we need these NetworkPolicy labels.
networking.gardener.cloud/to-dns: allowed
networking.resources.gardener.cloud/to-virtual-garden-kube-apiserver-tcp-443: allowed
networking.gardener.cloud/to-runtime-apiserver: allowed
{{ include "labels" . | indent 8 }}
spec:
{{- if not .Values.global.virtualGarden.enabled }}
Expand Down
5 changes: 1 addition & 4 deletions charts/gardener-extension-registry-cache/doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

//go:generate sh -c "../../vendor/github.com/gardener/gardener/hack/generate-controller-registration.sh extension-registry-cache . $(cat ../../VERSION) ../../example/registration/controller-registration.yaml Extension:registry-cache"
//go:generate cp ../../example/registration/controller-registration.yaml ../../charts/registration/templates/controller-registration.yaml
//go:generate sh -c "sed -i 's/ image:/{{ toYaml .Values.values | indent 4 }}/g' ../../charts/registration/templates/controller-registration.yaml"
//go:generate sh -c "sed -i 's/ tag: .*//g' ../../charts/registration/templates/controller-registration.yaml"
//go:generate sh -c "../../vendor/github.com/gardener/gardener/hack/generate-controller-registration.sh extension-registry-cache . $(cat ../../VERSION) ../../example/controller-registration.yaml Extension:registry-cache"

// Package chart enables go:generate support for generating the correct controller registration.
package chart
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,6 @@ apiVersion: config.registry.extensions.gardener.cloud/v1alpha1
kind: Configuration
{{- end }}

{{- define "image" -}}
{{- 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 }}

{{- define "leaderelectionid" -}}
extension-registry-cache-leader-election
{{- end -}}
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ spec:
serviceAccountName: gardener-extension-registry-cache
containers:
- name: gardener-extension-registry-cache
image: {{ include "image" . }}
imagePullPolicy: {{ .Values.image.pullPolicy }}
image: {{ .Values.image }}
imagePullPolicy: {{ .Values.imagePullPolicy }}
args:
- --config=/etc/registry-cache/config.yaml
- --max-concurrent-reconciles={{ .Values.controllers.concurrentSyncs }}
Expand Down
6 changes: 2 additions & 4 deletions charts/gardener-extension-registry-cache/values.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
image:
repository: eu.gcr.io/gardener-project/gardener/extensions/registry-cache
tag: latest
pullPolicy: IfNotPresent
image: eu.gcr.io/gardener-project/gardener/extensions/registry-cache:latest
imagePullPolicy: IfNotPresent

leaderElection:
resourceLock: leases
Expand Down
5 changes: 0 additions & 5 deletions charts/registration/Chart.yaml

This file was deleted.

25 changes: 0 additions & 25 deletions charts/registration/templates/controller-registration.yaml

This file was deleted.

1 change: 0 additions & 1 deletion charts/registration/values.yaml

This file was deleted.

35 changes: 35 additions & 0 deletions docs/development/getting-started-locally.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Deploying Registry Cache Extension Locally

## Prerequisites

- Make sure that you have a running local Gardener setup. The steps to complete this can be found in the [Deploying Gardener Locally guide](https://github.com/gardener/gardener/blob/master/docs/deployment/getting_started_locally.md).

## Setting up the Registry Cache Extension

Make sure that your `KUBECONFIG` environment variable is targeting the local Gardener cluster. When this is ensured, run:

```bash
make extension-up
```

The corresponding make target will build the extension image, load it into the kind cluster Nodes, and deploy the registry-cache ControllerDeployment and ControllerRegistration resources. The container image in the ControllerDeployment will be the image that was build and loaded into the kind cluster Nodes.

The make target will then deploy then registry-cache admission component. It will build the admission image, load it into the kind cluster Nodes, and finally install the admission component charts to the kind cluster.

## Creating a `Shoot` Cluster

Once the above step is completed you can create a Shoot cluster. Review the Shoot specification in [`example/shoot.yaml`](../../example/shoot.yaml). Create the Shoot:

```bash
kubectl create -f example/shoot.yaml
```

## Tearing Down the Dev Environment

To tear down the development environment delete the Shoot cluster or disable the `registry-cache` extension in the Shoot's specification. When the extension is not used by the Shoot anymore, you can run:

```bash
make extension-down
```

The make target will delete the ControllerDeployment and ControllerRegistration of the extension, and the registry-cache admission helm deployment.
3 changes: 0 additions & 3 deletions example/00-config.yaml

This file was deleted.

30 changes: 0 additions & 30 deletions example/40-validatingwebhookconfiguration.yaml

This file was deleted.

26 changes: 0 additions & 26 deletions example/admission/tls.crt

This file was deleted.

27 changes: 0 additions & 27 deletions example/admission/tls.key

This file was deleted.

Loading

0 comments on commit a73babe

Please sign in to comment.