Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecate kyma provision gardener #40

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 11 additions & 6 deletions hack/gardener.mk
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,23 @@ include ${PROJECT_ROOT}/hack/tools.mk
GARDENER_INFRASTRUCTURE = az
HIBERNATION_HOUR=$(shell echo $$(( ( $(shell date +%H | sed s/^0//g) + 5 ) % 24 )))
GIT_COMMIT_SHA=$(shell git rev-parse --short=8 HEAD)
SHOOT=test-${GIT_COMMIT_SHA}

ifneq (,$(GARDENER_SA_PATH))
GARDENER_K8S_VERSION=$(shell kubectl --kubeconfig=${GARDENER_SA_PATH} get cloudprofiles.core.gardener.cloud ${GARDENER_INFRASTRUCTURE} -o=jsonpath='{.spec.kubernetes.versions[0].version}')
else
GARDENER_K8S_VERSION=1.27.4
GARDENER_K8S_VERSION=1.29.3
endif
#Overwrite default kyma cli gardenlinux version because it's not supported.
GARDENER_LINUX_VERSION=1312.3.0

.PHONY: provision-gardener
provision-gardener: kyma ## Provision gardener cluster with latest k8s version
${KYMA} provision gardener ${GARDENER_INFRASTRUCTURE} -c ${GARDENER_SA_PATH} -n test-${GIT_COMMIT_SHA} -p ${GARDENER_PROJECT} -s ${GARDENER_SECRET_NAME} -k ${GARDENER_K8S_VERSION}\
--gardenlinux-version=$(GARDENER_LINUX_VERSION) --hibernation-start="00 ${HIBERNATION_HOUR} * * ?"
provision-gardener: ## Provision gardener cluster with latest k8s version
PROJECT_ROOT=${PROJECT_ROOT} \
GARDENER_SA_PATH=${GARDENER_SA_PATH} \
SHOOT=${SHOOT} PROJECT=${GARDENER_PROJECT} \
GARDENER_K8S_VERSION=${GARDENER_K8S_VERSION} \
GIT_COMMIT_SHA=${GIT_COMMIT_SHA} \
SECRET=${GARDENER_SECRET_NAME} \
${PROJECT_ROOT}/hack/save_kubeconfig.sh

.PHONY: deprovision-gardener
deprovision-gardener: kyma ## Deprovision gardener cluster
Expand Down
21 changes: 21 additions & 0 deletions hack/save_kubeconfig.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/bin/bash

# render and applyshoot template
shoot_template=$(envsubst < ${PROJECT_ROOT}/hack/shoot_template.yaml)

export KUBECONFIG="${GARDENER_SA_PATH}"
echo "$shoot_template" | kubectl apply -f -

echo "waiting fo cluster to be ready..."
kubectl wait --for=condition=EveryNodeReady shoot/${SHOOT} --timeout=17m

# create kubeconfig request, that creates a kubeconfig which is valid for one day
kubectl create \
-f <(printf '{"spec":{"expirationSeconds":86400}}') \
--raw /apis/core.gardener.cloud/v1beta1/namespaces/garden-${PROJECT}/shoots/${SHOOT}/adminkubeconfig | \
jq -r ".status.kubeconfig" | \
base64 -d > ${SHOOT}_kubeconfig.yaml

# replace the default kubeconfig
mkdir -p ~/.kube
mv ${SHOOT}_kubeconfig.yaml ~/.kube/config
41 changes: 41 additions & 0 deletions hack/shoot_template.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
apiVersion: core.gardener.cloud/v1beta1
kind: Shoot
metadata:
name: ${SHOOT}
spec:
secretBindingName: ${SECRET}
cloudProfileName: az
region: westeurope
purpose: evaluation
provider:
type: azure
infrastructureConfig:
apiVersion: azure.provider.extensions.gardener.cloud/v1alpha1
kind: InfrastructureConfig
networks:
vnet:
cidr: 10.250.0.0/16
workers: 10.250.0.0/19
workers:
- name: cpu-worker
minimum: 1
maximum: 2
machine:
type: Standard_A4_v2
volume:
type: Standard_LRS
size: 50Gi
networking:
type: calico
pods: 100.96.0.0/11
nodes: 10.250.0.0/16
services: 100.64.0.0/13
kubernetes:
version: "${GARDENER_K8S_VERSION}"
hibernation:
schedules:
- start: "00 14 * * ?"
location: "Europe/Berlin"
addons:
nginxIngress:
enabled: false