Skip to content

Commit

Permalink
chore: deprecate kyma provision gardener (#572)
Browse files Browse the repository at this point in the history
* Deprecate kyma provision gardener

* remove unused env
  • Loading branch information
halamix2 authored May 23, 2024
1 parent 778ec26 commit cc82d63
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 21 deletions.
2 changes: 1 addition & 1 deletion hack/ci/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ wait-api-gateway-cr-ready:

.PHONY: provision-gardener-cluster
provision-gardener-cluster:
GARDENER_CLUSTER_VERSION="${GARDENER_KUBE_VERSION}" PROJECT_ROOT="${PROJECT_ROOT}" KYMA_CLI="${KYMA_CLI}" ${PROJECT_ROOT}/scripts/gardener/aws/provision.sh
GARDENER_CLUSTER_VERSION="${GARDENER_KUBE_VERSION}" PROJECT_ROOT="${PROJECT_ROOT}" ${PROJECT_ROOT}/scripts/gardener/aws/provision.sh

.PHONY: deprovision-gardener-cluster
deprovision-gardener-cluster:
Expand Down
82 changes: 62 additions & 20 deletions scripts/gardener/aws/provision.sh
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,6 @@ gardener::validate_and_default() {
export GARDENER_CLUSTER_VERSION=$(kubectl --kubeconfig="${GARDENER_KUBECONFIG}" get cloudprofiles.core.gardener.cloud aws -o go-template='{{range .spec.kubernetes.versions}}{{if eq .classification "supported"}}{{.version}}{{break}}{{end}}{{end}}')
fi

# Detect supported linux version.
GARDEN_LINUX_VERSION=$(kubectl --kubeconfig="${GARDENER_KUBECONFIG}" get cloudprofiles.core.gardener.cloud aws -o go-template='{{range .spec.machineImages}}{{if eq .name "gardenlinux"}}{{range .versions}}{{if eq .classification "supported"}}{{.version}}{{end}}{{end}}{{end}}{{end}}')

# print configurations for debugging purposes:
log::banner "Configurations:"
echo "CLUSTER_NAME: ${CLUSTER_NAME}"
Expand All @@ -75,28 +72,73 @@ gardener::validate_and_default() {
echo "SCALER_MAX: ${SCALER_MAX}"
echo "GARDENER_CLUSTER_VERSION: ${GARDENER_CLUSTER_VERSION}"
echo "RETRY_ATTEMPTS ${RETRY_ATTEMPTS}"
echo "GARDEN_LINUX_VERSION ${GARDEN_LINUX_VERSION}"
}

gardener::provision_cluster() {
log::banner "Provision cluster: \"${CLUSTER_NAME}\""

# decreasing attempts to 2 because we will try to create new cluster from scratch on exit code other than 0
${KYMA_CLI} provision gardener aws \
--secret "${GARDENER_PROVIDER_SECRET_NAME}" \
--name "${CLUSTER_NAME}" \
--project "${GARDENER_PROJECT_NAME}" \
--credentials "${GARDENER_KUBECONFIG}" \
--region "${GARDENER_REGION}" \
--zones "${GARDENER_ZONES}" \
--type "${MACHINE_TYPE}" \
--scaler-min ${SCALER_MIN} \
--scaler-max ${SCALER_MAX} \
--kube-version="${GARDENER_CLUSTER_VERSION}" \
--gardenlinux-version "${GARDEN_LINUX_VERSION}" \
--attempts ${RETRY_ATTEMPTS} \
--verbose \
--hibernation-start ""
cat << EOF | kubectl apply --kubeconfig="${GARDENER_KUBECONFIG}" -f -
apiVersion: core.gardener.cloud/v1beta1
kind: Shoot
metadata:
name: ${CLUSTER_NAME}
spec:
secretBindingName: ${GARDENER_PROVIDER_SECRET_NAME}
cloudProfileName: aws
region: ${GARDENER_REGION}
purpose: evaluation
provider:
type: aws
infrastructureConfig:
apiVersion: aws.provider.extensions.gardener.cloud/v1alpha1
kind: InfrastructureConfig
networks:
vpc:
cidr: 10.250.0.0/16
zones:
- name: ${GARDENER_REGION}a
internal: 10.250.112.0/22
public: 10.250.96.0/22
workers: 10.250.0.0/19
workers:
- name: cpu-worker
minimum: ${SCALER_MIN}
maximum: ${SCALER_MAX}
machine:
type: ${MACHINE_TYPE}
volume:
type: gp2
size: 50Gi
zones:
- ${GARDENER_REGION}a
networking:
type: calico
pods: 100.96.0.0/11
nodes: 10.250.0.0/16
services: 100.64.0.0/13
kubernetes:
version: ${GARDENER_CLUSTER_VERSION}
hibernation:
enabled: false
addons:
nginxIngress:
enabled: false
EOF

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

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

# merge with the existing kubeconfig settings
mkdir -p ~/.kube
KUBECONFIG="~/.kube/config:${CLUSTER_NAME}_kubeconfig.yaml" kubectl config view --merge > merged_kubeconfig.yaml
mv merged_kubeconfig.yaml ~/.kube/config
}

## MAIN Logic
Expand Down

0 comments on commit cc82d63

Please sign in to comment.