Skip to content
This repository was archived by the owner on Aug 6, 2021. It is now read-only.

Commit

Permalink
Gardener support (#32)
Browse files Browse the repository at this point in the history
* Gardener support
* Manual workflow
* Uninstall script
  • Loading branch information
pbochynski authored Nov 4, 2020
1 parent 45df20f commit 5c6d0ac
Show file tree
Hide file tree
Showing 9 changed files with 193 additions and 9 deletions.
59 changes: 59 additions & 0 deletions .github/workflows/app-connector-e2e-gardener.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: Tests on Gardener

on:
workflow_dispatch:
inputs:
repository:
description: 'Repository'
required: true
default: 'kyma-project/kyma'
branch:
description: 'Branch'
required: true
default: 'master'
shoot:
description: 'Shoot cluster name'
required: true
default: 'ci'
schedule:
- cron: '0 * * * *' # every hour

jobs:
build:
runs-on: ubuntu-latest
timeout-minutes: 25
steps:
- uses: actions/checkout@v2
# - name: Setup tmate session
# uses: mxschmitt/action-tmate@v3
- name: Create cluster, install helm
env:
GARDEN_KUBECONFIG: ${{ secrets.GARDEN_KUBECONFIG }}
SHOOT_NAME: ${{ github.event.inputs.shoot }}
run: |
./create-cluster-gardener.sh
echo "Installing helm"
curl -s https://raw.githubusercontent.com/helm/helm/master/scripts/get-helm-3 | bash
while [[ $(kubectl get nodes -o 'jsonpath={..status.conditions[?(@.type=="Ready")].status}') != "True" ]]; do echo "Waiting for cluster nodes to be ready"; sleep 2; done
- name: Install Istio
run: |
./install-istio.sh -f config-istio.yaml
- name: Install Kyma
env:
SKIP_MODULES: apiserver-proxy,helm-broker,console,cluster-users,apiserver-proxy,logging,tracing
run: |
./download-kyma-charts.sh ${{ github.event.inputs.repository }} ${{ github.event.inputs.branch }}
./install-kyma-gardener.sh
- name: Install Commerce Mock
run: |
./commerce-mock.sh
- name: Run End To End Test
run: |
./app-connector-example.sh
- name: Uninstall Kyma
env:
SHOOT_NAME: ${{ github.event.inputs.shoot }}
run: |
./uninstall-kyma.sh
kubectl --kubeconfig ./garden-kubeconfig.yaml delete shoot $SHOOT_NAME
4 changes: 4 additions & 0 deletions .github/workflows/app-connector-e2e-kind.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,12 @@ name: Tests on kind

on:
push:
branches:
- main
pull_request:
types: [opened, synchronize, reopened]
branches:
- main
schedule:
- cron: '0 * * * *' # every hour

Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/app-connector-e2e-minikube.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,12 @@ name: Tests on minikube

on:
push:
branches:
- main
pull_request:
types: [opened, synchronize, reopened]
branches:
- main
schedule:
- cron: '0 * * * *' # every hour

Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ coredns-patch.yaml
kyma.crt
istioctl
istio-*
kubeconfig-*
21 changes: 13 additions & 8 deletions app-connector-example.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
MOCK_HOST=""
while [[ -z $MOCK_HOST ]]; do echo "waiting for mock host"; MOCK_HOST=$(kubectl get virtualservice -n mocks -ojsonpath='{.items[0].spec.hosts[0]}'); sleep 1; done

DOMAIN=${MOCK_HOST/commerce./}

cat <<EOF | kubectl apply -f -
apiVersion: applicationconnector.kyma-project.io/v1alpha1
kind: Application
Expand Down Expand Up @@ -91,18 +96,18 @@ EOF
TOKEN=""
while [[ -z $TOKEN ]] ; do TOKEN=$(kubectl get tokenrequest.applicationconnector.kyma-project.io commerce -ojsonpath='{.status.token}'); echo "waiting for token"; sleep 2; done

curl -k 'https://commerce.local.kyma.dev/connection' \
curl -k "https://$MOCK_HOST/connection" \
-H 'content-type: application/json' \
--data-binary '{"token":"https://connector-service.local.kyma.dev/v1/applications/signingRequests/info?token='$TOKEN'","baseUrl":"https://commerce.local.kyma.dev","insecure":true}' \
--data-binary '{"token":"https://connector-service.'$DOMAIN'/v1/applications/signingRequests/info?token='$TOKEN'","baseUrl":"https://'$MOCK_HOST'","insecure":true}' \
--compressed


COMMERCE_WEBSERVICES_ID=""
while [[ -z $COMMERCE_WEBSERVICES_ID ]];
do
echo "registering commerce webservices";
curl -sk 'https://commerce.local.kyma.dev/local/apis/Commerce%20Webservices/register' -H 'content-type: application/json' -H 'origin: https://commerce.local.kyma.dev' -d '{}'
COMMERCE_WEBSERVICES_ID=$(curl -sk 'https://commerce.local.kyma.dev/remote/apis' | jq -r '.[]|select(.name|test("Commerce Webservices"))|.id')
curl -sk "https://$MOCK_HOST/local/apis/Commerce%20Webservices/register" -H 'content-type: application/json' -H 'origin: https://'$MOCK_HOST -d '{}'
COMMERCE_WEBSERVICES_ID=$(curl -sk "https://$MOCK_HOST/remote/apis" | jq -r '.[]|select(.name|test("Commerce Webservices"))|.id')
echo "COMMERCE_WEBSERVICES_ID=$COMMERCE_WEBSERVICES_ID"
sleep 2
done
Expand All @@ -111,8 +116,8 @@ COMMERCE_EVENTS_ID=""
while [[ -z $COMMERCE_EVENTS_ID ]];
do
echo "registering commerce events";
curl -sk 'https://commerce.local.kyma.dev/local/apis/Events/register' -H 'content-type: application/json' -H 'origin: https://commerce.local.kyma.dev' -d '{}'
COMMERCE_EVENTS_ID=$(curl -sk 'https://commerce.local.kyma.dev/remote/apis' | jq -r '.[]|select(.name|test("Events"))|.id')
curl -sk "https://$MOCK_HOST/local/apis/Events/register" -H 'content-type: application/json' -H 'origin: https://'$MOCK_HOST -d '{}'
COMMERCE_EVENTS_ID=$(curl -sk "https://$MOCK_HOST/remote/apis" | jq -r '.[]|select(.name|test("Events"))|.id')
echo "COMMERCE_EVENTS_ID=$COMMERCE_EVENTS_ID"
sleep 2
done
Expand Down Expand Up @@ -167,11 +172,11 @@ EOF
PRICE=""
while [[ -z $PRICE ]]
do
curl -sk 'https://commerce.local.kyma.dev/events' \
curl -sk "https://$MOCK_HOST/events" \
-H 'content-type: application/json' \
-d '{"event-type": "order.created", "event-type-version": "v1", "event-time": "2020-09-28T14:47:16.491Z", "data": { "orderCode": "123" }, "event-tracing": true}' >/dev/null
sleep 1;
RESPONSE=$(curl -sk https://lastorder.local.kyma.dev)
RESPONSE=$(curl -sk https://lastorder.$DOMAIN)
PRICE=$(echo "$RESPONSE" | jq -r 'select(.orderId=="123")| .totalPriceWithTax.value')
echo "waiting for last order price, response: $RESPONSE"
done
6 changes: 5 additions & 1 deletion commerce-mock.sh
Original file line number Diff line number Diff line change
Expand Up @@ -85,5 +85,9 @@ spec:
name: commerce-mock
port: 10000
EOF

MOCK_HOST=""
while [[ -z $MOCK_HOST ]]; do echo "waiting for mock host"; MOCK_HOST=$(kubectl get virtualservice -n mocks -ojsonpath='{.items[0].spec.hosts[0]}'); sleep 3; done

MOCK_PROVIDER=""
while [[ -z $MOCK_PROVIDER ]]; do echo "waiting for commerce mock to be ready"; MOCK_PROVIDER=$(curl -sk https://commerce.local.kyma.dev/local/apis |jq -r '.[0].provider'); curl -ik "https://commerce.local.kyma.dev/local/apis" ; sleep 5; done
while [[ -z $MOCK_PROVIDER ]]; do echo "waiting for commerce mock to be ready"; MOCK_PROVIDER=$(curl -sk https://$MOCK_HOST/local/apis |jq -r '.[0].provider') ; sleep 5; done
70 changes: 70 additions & 0 deletions create-cluster-gardener.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
#!/bin/bash

echo $GARDEN_KUBECONFIG | base64 --decode > ./garden-kubeconfig.yaml
export SHOOT_NAME=${SHOOT_NAME:-c$(date +"%d%H%M%S")}

cat <<EOF | kubectl --kubeconfig ./garden-kubeconfig.yaml apply -f -
kind: Shoot
apiVersion: core.gardener.cloud/v1beta1
metadata:
name: $SHOOT_NAME
spec:
provider:
type: gcp
infrastructureConfig:
apiVersion: gcp.provider.extensions.gardener.cloud/v1alpha1
kind: InfrastructureConfig
networks:
workers: 10.250.0.0/16
controlPlaneConfig:
apiVersion: gcp.provider.extensions.gardener.cloud/v1alpha1
kind: ControlPlaneConfig
zone: europe-west1-c
workers:
- name: worker-np1s8
minimum: 1
maximum: 1
maxSurge: 1
machine:
type: n1-standard-4
image:
name: gardenlinux
version: 184.0.0
zones:
- europe-west1-c
volume:
type: pd-standard
size: 50Gi
networking:
type: calico
nodes: 10.250.0.0/16
cloudProfileName: gcp
region: europe-west1
secretBindingName: trial-secretbinding-gcp
kubernetes:
version: 1.18.9
purpose: evaluation
addons:
kubernetesDashboard:
enabled: false
nginxIngress:
enabled: false
maintenance:
timeWindow:
begin: 220000+0000
end: 230000+0000
autoUpdate:
kubernetesVersion: true
machineImageVersion: true
hibernation:
schedules: []
EOF

STATUS="False"
while [[ $STATUS != "True" ]]; do
STATUS=$(kubectl --kubeconfig ./garden-kubeconfig.yaml get shoot $SHOOT_NAME -ojson | jq -r '.status.conditions[] | select(.type=="EveryNodeReady") | .status')
echo "Waiting for shoot $SHOOT_NAME nodes to be ready: $(kubectl --kubeconfig ./garden-kubeconfig.yaml get shoot $SHOOT_NAME -ojsonpath='{.status.lastOperation.description}')"
sleep 5
done

kubectl --kubeconfig ./garden-kubeconfig.yaml get secret $SHOOT_NAME.kubeconfig -ojsonpath='{.data.kubeconfig}' | base64 --decode > ~/.kube/config
3 changes: 3 additions & 0 deletions install-kyma.sh
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,9 @@ helm_install knative-provisioner-natss resources/knative-provisioner-natss knati
helm_install nats-streaming resources/nats-streaming natss &
helm_install event-sources resources/event-sources kyma-system &

# helm_install kiali resources/kiali kyma-system --set global.ingress.domainName=$DOMAIN &
# helm_install monitoring resources/monitoring kyma-system --set global.ingress.domainName=$DOMAIN &

# Create installer deployment scaled to 0 to get console running:
kubectl apply -f installer-local.yaml &

Expand Down
34 changes: 34 additions & 0 deletions uninstall-kyma.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/bin/bash

SECONDS=0

# Wait until number of background jobs is less than $1, try every $2 second(s)
function waitForJobs() {
while (( (( JOBS_COUNT=$(jobs -p | wc -l) )) > $1 )); do echo "Waiting for $JOBS_COUNT command(s) executed in the background, elapsed time: $(( $SECONDS/60 )) min $(( $SECONDS % 60 )) sec"; jobs >/dev/null ; sleep $2; done
}
kubectl delete ValidatingWebhookConfiguration config.webhook.eventing.knative.dev
kubectl delete ValidatingWebhookConfiguration validation.webhook.eventing.knative.dev
kubectl delete MutatingWebhookConfiguration webhook.eventing.knative.dev
kubectl delete MutatingWebhookConfiguration legacysinkbindings.webhook.sources.knative.dev
kubectl delete MutatingWebhookConfiguration sinkbindings.webhook.sources.knative.dev

kubectl delete apirules --all -A
kubectl delete rules.oathkeeper.ory.sh --all -A
kubectl delete secret -n istio-system kyma-gateway-certs-cacert

helm ls -A -ojson | jq -r '.[] | "helm delete \(.name) -n \(.namespace)"' | while read -r line; do bash -c "$line &" ; done

# Wait for jobs - helm commands executed in the background
waitForJobs 0 5

kubectl delete -f resources/cluster-essentials/files -n kyma-system

# Delete namespaces
kubectl delete ns kyma-system
kubectl delete ns kyma-integration
kubectl delete ns knative-eventing
kubectl delete ns natss
kubectl delete ns mocks


echo "Kyma uninstalled in $(( $SECONDS/60 )) min $(( $SECONDS % 60 )) sec"

0 comments on commit 5c6d0ac

Please sign in to comment.