From 13c5c3690e829eda62970c7f5ade5746bbb2cd07 Mon Sep 17 00:00:00 2001 From: Melissa Lee <43827333+halim-lee@users.noreply.github.com> Date: Wed, 1 Dec 2021 14:30:08 -0500 Subject: [PATCH] e2e testing for Minikube (#288) * e2e testing for Minikube * Ingress certificate test edit --- .../scorecard/kuttl/probe/00-assert.yaml | 29 ++-- .../scorecard/kuttl/probe/01-assert.yaml | 29 ++-- .../scorecard/kuttl/probe/02-errors.yaml | 34 +++-- .../ingress-certificate/00-assert.yaml | 10 ++ .../ingress-certificate/00-secret.yaml | 14 ++ .../ingress-certificate/01-assert.yaml | 24 ++++ .../ingress-certificate/01-rc-with-cert.yaml | 16 +++ .../ingress-certificate/02-assert.yaml | 8 ++ .../ingress-certificate/02-delete-route.yaml | 10 ++ .../ingress-certificate/02-errors.yaml | 4 + .../ingress-certificate/03-delete-secret.yaml | 9 ++ .../minikube-kuttl/ingress/00-assert.yaml | 21 +++ .../minikube-kuttl/ingress/00-ingress.yaml | 13 ++ .../minikube-kuttl/ingress/01-assert.yaml | 8 ++ .../ingress/01-delete-ingress.yaml | 10 ++ .../minikube-kuttl/ingress/01-errors.yaml | 4 + config/rbac/minikube-kuttl-rbac.yaml | 110 +++++++++++++++ .../base/runtime-component-operator.yaml | 7 +- scripts/e2e-minikube.sh | 132 ++++++++++++++++++ scripts/installers/install-minikube.sh | 51 +++++-- 20 files changed, 481 insertions(+), 62 deletions(-) create mode 100644 bundle/tests/scorecard/minikube-kuttl/ingress-certificate/00-assert.yaml create mode 100644 bundle/tests/scorecard/minikube-kuttl/ingress-certificate/00-secret.yaml create mode 100644 bundle/tests/scorecard/minikube-kuttl/ingress-certificate/01-assert.yaml create mode 100644 bundle/tests/scorecard/minikube-kuttl/ingress-certificate/01-rc-with-cert.yaml create mode 100644 bundle/tests/scorecard/minikube-kuttl/ingress-certificate/02-assert.yaml create mode 100644 bundle/tests/scorecard/minikube-kuttl/ingress-certificate/02-delete-route.yaml create mode 100644 bundle/tests/scorecard/minikube-kuttl/ingress-certificate/02-errors.yaml create mode 100644 bundle/tests/scorecard/minikube-kuttl/ingress-certificate/03-delete-secret.yaml create mode 100644 bundle/tests/scorecard/minikube-kuttl/ingress/00-assert.yaml create mode 100644 bundle/tests/scorecard/minikube-kuttl/ingress/00-ingress.yaml create mode 100644 bundle/tests/scorecard/minikube-kuttl/ingress/01-assert.yaml create mode 100644 bundle/tests/scorecard/minikube-kuttl/ingress/01-delete-ingress.yaml create mode 100644 bundle/tests/scorecard/minikube-kuttl/ingress/01-errors.yaml create mode 100644 config/rbac/minikube-kuttl-rbac.yaml create mode 100755 scripts/e2e-minikube.sh diff --git a/bundle/tests/scorecard/kuttl/probe/00-assert.yaml b/bundle/tests/scorecard/kuttl/probe/00-assert.yaml index 627414be1..4c96fc06a 100644 --- a/bundle/tests/scorecard/kuttl/probe/00-assert.yaml +++ b/bundle/tests/scorecard/kuttl/probe/00-assert.yaml @@ -6,22 +6,21 @@ apiVersion: apps/v1 kind: Deployment metadata: name: probes-rc +spec: + selector: + matchLabels: + app.kubernetes.io/instance: probes-rc + template: + spec: + containers: + - readinessProbe: + initialDelaySeconds: 1 + livenessProbe: + initialDelaySeconds: 4 + startupProbe: + failureThreshold: 10 + periodSeconds: 5 status: replicas: 1 readyReplicas: 1 updatedReplicas: 1 ---- -apiVersion: v1 -kind: Pod -spec: - containers: - - startupProbe: - failureThreshold: 10 - periodSeconds: 5 - readinessProbe: - initialDelaySeconds: 1 - livenessProbe: - initialDelaySeconds: 4 -metadata: - labels: - app.kubernetes.io/instance: probes-rc diff --git a/bundle/tests/scorecard/kuttl/probe/01-assert.yaml b/bundle/tests/scorecard/kuttl/probe/01-assert.yaml index 53381ad66..48be6c0d8 100644 --- a/bundle/tests/scorecard/kuttl/probe/01-assert.yaml +++ b/bundle/tests/scorecard/kuttl/probe/01-assert.yaml @@ -6,22 +6,21 @@ apiVersion: apps/v1 kind: Deployment metadata: name: probes-rc +spec: + selector: + matchLabels: + app.kubernetes.io/instance: probes-rc + template: + spec: + containers: + - readinessProbe: + initialDelaySeconds: 3 + livenessProbe: + initialDelaySeconds: 6 + startupProbe: + failureThreshold: 20 + periodSeconds: 10 status: replicas: 1 readyReplicas: 1 updatedReplicas: 1 ---- -apiVersion: v1 -kind: Pod -spec: - containers: - - readinessProbe: - initialDelaySeconds: 3 - livenessProbe: - initialDelaySeconds: 6 - startupProbe: - failureThreshold: 20 - periodSeconds: 10 -metadata: - labels: - app.kubernetes.io/instance: probes-rc diff --git a/bundle/tests/scorecard/kuttl/probe/02-errors.yaml b/bundle/tests/scorecard/kuttl/probe/02-errors.yaml index 7e2b969fc..ba9d4fd7e 100644 --- a/bundle/tests/scorecard/kuttl/probe/02-errors.yaml +++ b/bundle/tests/scorecard/kuttl/probe/02-errors.yaml @@ -1,14 +1,22 @@ -apiVersion: v1 -kind: Pod -spec: - containers: - - readinessProbe: - initialDelaySeconds: 3 - livenessProbe: - initialDelaySeconds: 6 - startupProbe: - failureThreshold: 20 - periodSeconds: 10 +apiVersion: apps/v1 +kind: Deployment metadata: - labels: - app.kubernetes.io/instance: probes-rc + name: probes-rc +spec: + selector: + matchLabels: + app.kubernetes.io/instance: probes-rc + template: + spec: + containers: + - readinessProbe: + initialDelaySeconds: 3 + livenessProbe: + initialDelaySeconds: 6 + startupProbe: + failureThreshold: 20 + periodSeconds: 10 +status: + replicas: 1 + readyReplicas: 1 + updatedReplicas: 1 \ No newline at end of file diff --git a/bundle/tests/scorecard/minikube-kuttl/ingress-certificate/00-assert.yaml b/bundle/tests/scorecard/minikube-kuttl/ingress-certificate/00-assert.yaml new file mode 100644 index 000000000..3c30523e4 --- /dev/null +++ b/bundle/tests/scorecard/minikube-kuttl/ingress-certificate/00-assert.yaml @@ -0,0 +1,10 @@ +apiVersion: v1 +kind: Secret +type: kubernetes.io/tls +metadata: + name: ingress-tls-secret +data: + ca.crt: Y2FjcnQK + destCA.crt: ZGVzdENBY3J0Cg== + tls.crt: dGxzY3J0Cg== + tls.key: dGxza2V5Cg== diff --git a/bundle/tests/scorecard/minikube-kuttl/ingress-certificate/00-secret.yaml b/bundle/tests/scorecard/minikube-kuttl/ingress-certificate/00-secret.yaml new file mode 100644 index 000000000..3ca51e383 --- /dev/null +++ b/bundle/tests/scorecard/minikube-kuttl/ingress-certificate/00-secret.yaml @@ -0,0 +1,14 @@ +apiVersion: v1 +kind: Secret +metadata: + name: ingress-tls-secret +type: kubernetes.io/tls +data: + # 'tlscrt' + tls.crt: dGxzY3J0Cg== + # 'tlskey' + tls.key: dGxza2V5Cg== + # 'cacrt' + ca.crt: Y2FjcnQK + # 'destCAcrt' + destCA.crt: ZGVzdENBY3J0Cg== diff --git a/bundle/tests/scorecard/minikube-kuttl/ingress-certificate/01-assert.yaml b/bundle/tests/scorecard/minikube-kuttl/ingress-certificate/01-assert.yaml new file mode 100644 index 000000000..d9ad0730a --- /dev/null +++ b/bundle/tests/scorecard/minikube-kuttl/ingress-certificate/01-assert.yaml @@ -0,0 +1,24 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: ingress-with-cert-rc +status: + replicas: 1 + readyReplicas: 1 + updatedReplicas: 1 +--- +kind: Ingress +apiVersion: extensions/v1beta1 +metadata: + name: ingress-with-cert-rc +spec: + tls: + - hosts: + - myapp.mycompany.com + secretName: ingress-tls-secret + rules: + - host: myapp.mycompany.com + http: + paths: + - path: / + pathType: Prefix diff --git a/bundle/tests/scorecard/minikube-kuttl/ingress-certificate/01-rc-with-cert.yaml b/bundle/tests/scorecard/minikube-kuttl/ingress-certificate/01-rc-with-cert.yaml new file mode 100644 index 000000000..e40a33c8d --- /dev/null +++ b/bundle/tests/scorecard/minikube-kuttl/ingress-certificate/01-rc-with-cert.yaml @@ -0,0 +1,16 @@ +apiVersion: rc.app.stacks/v1beta2 +kind: RuntimeComponent +metadata: + name: ingress-with-cert-rc +spec: + # Add fields here + applicationImage: 'k8s.gcr.io/pause:2.0' + replicas: 1 + expose: true + route: + host: myapp.mycompany.com + path: "/" + pathType: Prefix + certificateSecretRef: ingress-tls-secret + termination: reencrypt + diff --git a/bundle/tests/scorecard/minikube-kuttl/ingress-certificate/02-assert.yaml b/bundle/tests/scorecard/minikube-kuttl/ingress-certificate/02-assert.yaml new file mode 100644 index 000000000..27d90be55 --- /dev/null +++ b/bundle/tests/scorecard/minikube-kuttl/ingress-certificate/02-assert.yaml @@ -0,0 +1,8 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: ingress-with-cert-rc +status: + replicas: 1 + readyReplicas: 1 + updatedReplicas: 1 diff --git a/bundle/tests/scorecard/minikube-kuttl/ingress-certificate/02-delete-route.yaml b/bundle/tests/scorecard/minikube-kuttl/ingress-certificate/02-delete-route.yaml new file mode 100644 index 000000000..d9aeb3bab --- /dev/null +++ b/bundle/tests/scorecard/minikube-kuttl/ingress-certificate/02-delete-route.yaml @@ -0,0 +1,10 @@ +apiVersion: rc.app.stacks/v1beta2 +kind: RuntimeComponent +metadata: + name: ingress-with-cert-rc +spec: + # Add fields here + applicationImage: 'k8s.gcr.io/pause:2.0' + replicas: 1 + expose: false + diff --git a/bundle/tests/scorecard/minikube-kuttl/ingress-certificate/02-errors.yaml b/bundle/tests/scorecard/minikube-kuttl/ingress-certificate/02-errors.yaml new file mode 100644 index 000000000..cc4e06719 --- /dev/null +++ b/bundle/tests/scorecard/minikube-kuttl/ingress-certificate/02-errors.yaml @@ -0,0 +1,4 @@ +kind: Ingress +apiVersion: extensions/v1beta1 +metadata: + name: ingress-with-cert-rc diff --git a/bundle/tests/scorecard/minikube-kuttl/ingress-certificate/03-delete-secret.yaml b/bundle/tests/scorecard/minikube-kuttl/ingress-certificate/03-delete-secret.yaml new file mode 100644 index 000000000..309fd6c45 --- /dev/null +++ b/bundle/tests/scorecard/minikube-kuttl/ingress-certificate/03-delete-secret.yaml @@ -0,0 +1,9 @@ +apiVersion: kuttl.dev/v1beta1 +kind: TestStep +delete: +- apiVersion: rc.app.stacks/v1beta2 + kind: RuntimeComponent +- apiVersion: v1 + kind: Secret + name: ingress-tls-secret + diff --git a/bundle/tests/scorecard/minikube-kuttl/ingress/00-assert.yaml b/bundle/tests/scorecard/minikube-kuttl/ingress/00-assert.yaml new file mode 100644 index 000000000..d0b747a71 --- /dev/null +++ b/bundle/tests/scorecard/minikube-kuttl/ingress/00-assert.yaml @@ -0,0 +1,21 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: ingress +status: + replicas: 1 + readyReplicas: 1 + updatedReplicas: 1 +--- +apiVersion: extensions/v1beta1 +kind: Ingress +metadata: + name: ingress +spec: + rules: + - host: myapp.mycompany.com + http: + paths: + - path: / + pathType: Prefix + diff --git a/bundle/tests/scorecard/minikube-kuttl/ingress/00-ingress.yaml b/bundle/tests/scorecard/minikube-kuttl/ingress/00-ingress.yaml new file mode 100644 index 000000000..d303879b0 --- /dev/null +++ b/bundle/tests/scorecard/minikube-kuttl/ingress/00-ingress.yaml @@ -0,0 +1,13 @@ +apiVersion: rc.app.stacks/v1beta2 +kind: RuntimeComponent +metadata: + name: ingress +spec: + # Add fields here + applicationImage: 'k8s.gcr.io/pause:2.0' + replicas: 1 + expose: true + route: + host: myapp.mycompany.com + path: "/" + pathType: Prefix diff --git a/bundle/tests/scorecard/minikube-kuttl/ingress/01-assert.yaml b/bundle/tests/scorecard/minikube-kuttl/ingress/01-assert.yaml new file mode 100644 index 000000000..8902dd486 --- /dev/null +++ b/bundle/tests/scorecard/minikube-kuttl/ingress/01-assert.yaml @@ -0,0 +1,8 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: ingress +status: + replicas: 1 + readyReplicas: 1 + updatedReplicas: 1 diff --git a/bundle/tests/scorecard/minikube-kuttl/ingress/01-delete-ingress.yaml b/bundle/tests/scorecard/minikube-kuttl/ingress/01-delete-ingress.yaml new file mode 100644 index 000000000..fc2bbf21e --- /dev/null +++ b/bundle/tests/scorecard/minikube-kuttl/ingress/01-delete-ingress.yaml @@ -0,0 +1,10 @@ +apiVersion: rc.app.stacks/v1beta2 +kind: RuntimeComponent +metadata: + name: ingress +spec: + # Add fields here + applicationImage: 'k8s.gcr.io/pause:2.0' + replicas: 1 + expose: false + diff --git a/bundle/tests/scorecard/minikube-kuttl/ingress/01-errors.yaml b/bundle/tests/scorecard/minikube-kuttl/ingress/01-errors.yaml new file mode 100644 index 000000000..2d98cf8b3 --- /dev/null +++ b/bundle/tests/scorecard/minikube-kuttl/ingress/01-errors.yaml @@ -0,0 +1,4 @@ +apiVersion: extensions/v1beta1 +kind: Ingress +metadata: + name: ingress diff --git a/config/rbac/minikube-kuttl-rbac.yaml b/config/rbac/minikube-kuttl-rbac.yaml new file mode 100644 index 000000000..fb40fa107 --- /dev/null +++ b/config/rbac/minikube-kuttl-rbac.yaml @@ -0,0 +1,110 @@ +apiVersion: v1 +kind: ServiceAccount +metadata: + name: scorecard-kuttl +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: RoleBinding +metadata: + name: scorecard-kuttl +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: Role + name: scorecard-kuttl +subjects: +- kind: ServiceAccount + name: scorecard-kuttl +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: Role +metadata: + name: scorecard-kuttl +rules: +- apiGroups: + - "" + resources: + - secrets + verbs: + - get + - list + - create + - delete +- apiGroups: + - "" + resources: + - namespaces + - pods + - services + - routes + verbs: + - get + - list +- apiGroups: + - apps + resources: + - deployments + - statefulsets + verbs: + - get +- apiGroups: + - autoscaling + resources: + - horizontalpodautoscalers + verbs: + - get +- apiGroups: + - monitoring.coreos.com + resources: + - servicemonitors + verbs: + - get +- apiGroups: + - image.openshift.io + resources: + - imagestreams + verbs: + - get + - list + - create + - patch + - delete +- apiGroups: + - events.k8s.io + resources: + - events + verbs: + - get + - list +- apiGroups: + - serving.knative.dev + resources: + - services + verbs: + - get +- apiGroups: + - rc.app.stacks + resources: + - runtimecomponents + - runtimeoperations + verbs: + - get + - list + - create + - patch + - delete +- apiGroups: + - route.openshift.io + resources: + - routes + verbs: + - get + - list + - delete +- apiGroups: + - extensions + resources: + - ingresses + verbs: + - get + - list + - delete diff --git a/deploy/kustomize/daily/base/runtime-component-operator.yaml b/deploy/kustomize/daily/base/runtime-component-operator.yaml index aa9e448fc..c0d829f3f 100644 --- a/deploy/kustomize/daily/base/runtime-component-operator.yaml +++ b/deploy/kustomize/daily/base/runtime-component-operator.yaml @@ -222,10 +222,9 @@ spec: fieldRef: fieldPath: metadata.namespace - name: WATCH_NAMESPACE - value: default -# valueFrom: -# fieldRef: -# fieldPath: metadata.annotations['olm.targetNamespaces'] + valueFrom: + fieldRef: + fieldPath: metadata.namespace image: applicationstacks/operator:daily imagePullPolicy: Always name: manager diff --git a/scripts/e2e-minikube.sh b/scripts/e2e-minikube.sh new file mode 100755 index 000000000..f6a1abf1e --- /dev/null +++ b/scripts/e2e-minikube.sh @@ -0,0 +1,132 @@ +#!/bin/bash + +readonly usage="Usage: e2e-minikube.sh -n " +readonly SERVICE_ACCOUNT="travis-tests" + +# setup_env: Download kubectl cli and Minikube, start Minikube, and create a test project +setup_env() { + # Install Minikube and Start a cluster + echo "****** Installing and starting Minikube" + scripts/installers/install-minikube.sh + + echo "****** Creating test namespace: ${TEST_NAMESPACE}" + kubectl create namespace "${TEST_NAMESPACE}" + kubectl config set-context $(kubectl config current-context) --namespace="${TEST_NAMESPACE}" + + ## Create service account for Kuttl tests + kubectl apply -f config/rbac/minikube-kuttl-rbac.yaml + + ## Add label to node for affinity test + kubectl label node "minikube" kuttlTest=test1 +} + +# install_rco: Kustomize and install Runtime-Component-Operator +install_rco() { + echo "****** Installing RCO in namespace: ${TEST_NAMESPACE}" + kubectl apply -f bundle/manifests/rc.app.stacks_runtimecomponents.yaml + kubectl apply -f bundle/manifests/rc.app.stacks_runtimeoperations.yaml + kubectl apply -f deploy/kustomize/daily/base/runtime-component-operator.yaml -n ${TEST_NAMESPACE} +} + +function install_tools() { + echo "****** Installing Prometheus" + kubectl apply -f https://raw.githubusercontent.com/prometheus-operator/prometheus-operator/main/bundle.yaml + + echo "****** Installing Knative" + minikube addons enable registry + kubectl apply -f https://github.com/knative/serving/releases/download/v0.24.0/serving-crds.yaml + kubectl apply -f https://github.com/knative/eventing/releases/download/v0.24.0/eventing-crds.yaml + + echo "****** Enabling Ingress" + minikube addons enable ingress +} + +## cleanup_env : Delete generated resources that are not bound to a test TEST_NAMESPACE. +cleanup_env() { + kubectl delete namespace "${TEST_NAMESPACE}" + minikube stop && minikube delete +} + +function setup_test() { + echo "****** Installing kuttl" + mkdir krew && cd krew + curl -OL https://github.com/kubernetes-sigs/krew/releases/latest/download/krew-linux_amd64.tar.gz \ + && tar -xvzf krew-linux_amd64.tar.gz \ + && ./krew-linux_amd64 install krew + cd .. && rm -rf krew + export PATH="$HOME/.krew/bin:$PATH" + kubectl krew install kuttl + + ## Add tests for minikube + mv bundle/tests/scorecard/minikube-kuttl/ingress bundle/tests/scorecard/kuttl/ + mv bundle/tests/scorecard/minikube-kuttl/ingress-certificate bundle/tests/scorecard/kuttl/ + + ## Remove tests that do not apply for minikube + mv bundle/tests/scorecard/kuttl/routes bundle/tests/scorecard/minikube-kuttl/ + mv bundle/tests/scorecard/kuttl/route-certificate bundle/tests/scorecard/minikube-kuttl/ + mv bundle/tests/scorecard/kuttl/stream bundle/tests/scorecard/minikube-kuttl/ +} + +function cleanup_test() { + ## Restore tests + mv bundle/tests/scorecard/kuttl/ingress bundle/tests/scorecard/minikube-kuttl/ + mv bundle/tests/scorecard/kuttl/ingress-certificate bundle/tests/scorecard/minikube-kuttl/ + + mv bundle/tests/scorecard/minikube-kuttl/routes bundle/tests/scorecard/kuttl/ + mv bundle/tests/scorecard/minikube-kuttl/route-certificate bundle/tests/scorecard/kuttl/ + mv bundle/tests/scorecard/minikube-kuttl/stream bundle/tests/scorecard/kuttl/ +} + +main() { + parse_args "$@" + + if [[ -z "${TEST_NAMESPACE}" ]]; then + echo "****** Missing test namespace, see usage" + echo "${usage}" + exit 1 + fi + + echo "****** Setting up test environment..." + setup_env + install_rco + install_tools + + # Wait for operator deployment to be ready + while [[ $(kubectl get deploy rco-controller-manager -o jsonpath='{ .status.readyReplicas }') -ne "1" ]]; do + echo "****** Waiting for rco-controller-manager to be ready..." + sleep 10 + done + echo "****** rco-controller-manager deployment is ready..." + + setup_test + + echo "****** Starting minikube scorecard tests..." + operator-sdk scorecard --verbose --selector=suite=kuttlsuite --namespace "${TEST_NAMESPACE}" --service-account scorecard-kuttl --wait-time 30m ./bundle || { + echo "****** Scorecard tests failed..." + } + result=$? + + cleanup_test + + echo "****** Cleaning up test environment..." + cleanup_env +} + +parse_args() { + while [ $# -gt 0 ]; do + case "$1" in + -n) + shift + readonly TEST_NAMESPACE="${1}" + ;; + *) + echo "Error: Invalid argument - $1" + echo "$usage" + exit 1 + ;; + esac + shift + done +} + +main "$@" diff --git a/scripts/installers/install-minikube.sh b/scripts/installers/install-minikube.sh index 7027dd1fe..381223ae7 100755 --- a/scripts/installers/install-minikube.sh +++ b/scripts/installers/install-minikube.sh @@ -3,51 +3,72 @@ set -e ## Some minikube job specific ENV variables -export CHANGE_MINIKUBE_NONE_USER=true export MINIKUBE_WANTUPDATENOTIFICATION=false export MINIKUBE_HOME=$HOME -export CHANGE_MINIKUBE_NONE_USER=true export KUBECONFIG=$HOME/.kube/config function main () { - echo "****** Installing minikube..." install_minikube echo "****** Verifying installation..." kubectl cluster-info wait_for_kube - ## Run tests below - echo "Minikube enabled job is running..." + + echo "****** Minikube enabled job is running..." } function install_minikube() { sudo apt-get update -y sudo apt-get -qq -y install conntrack + sudo apt install make + ## get kubectl - curl -Lo kubectl https://storage.googleapis.com/kubernetes-release/release/v1.18.1/bin/linux/amd64/kubectl \ - && chmod +x kubectl \ - && sudo mv kubectl /usr/local/bin/ + echo "****** Installing kubectl v1.19.4..." + curl -Lo kubectl https://storage.googleapis.com/kubernetes-release/release/v1.19.4/bin/linux/amd64/kubectl \ + && chmod +x kubectl \ + && sudo mv kubectl /usr/local/bin/ + ## Download minikube - curl -Lo minikube https://storage.googleapis.com/minikube/releases/v1.8.1/minikube-linux-amd64 \ - && chmod +x minikube \ - && sudo mv minikube /usr/local/bin/ + echo "****** Installing Minikube v1.21.0..." + curl -Lo minikube https://storage.googleapis.com/minikube/releases/v1.21.0/minikube-linux-amd64 \ + && chmod +x minikube \ + && sudo mv minikube /usr/local/bin/ + + ## Download docker + echo "****** Installing Docker..." + if test -f "/usr/share/keyrings/docker-archive-keyring.gpg"; then + rm /usr/share/keyrings/docker-archive-keyring.gpg + fi + curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg + echo \ + "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu \ + $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null + sudo apt-get update -y + sudo apt-get install -y docker-ce docker-ce-cli containerd.io + + ## Download operator-sdk + echo "****** Installing operator-sdk..." + make setup mkdir -p $HOME/.kube $HOME/.minikube touch $KUBECONFIG - sudo minikube start --profile=minikube --vm-driver=none --kubernetes-version=v1.18.1 + minikube start --profile=minikube --kubernetes-version=v1.19.4 --driver=docker --force minikube update-context --profile=minikube eval "$(minikube docker-env --profile=minikube)" && export DOCKER_CLI='docker' } + function wait_for_kube() { local json_path='{range .items[*]}{@.metadata.name}:{range @.status.conditions[*]}{@.type}={@.status};{end}{end}' + echo "****** Waiting for kube-controller-manager to be available..." - until kubectl -n kube-system get pods -l k8s-app=kube-dns -o jsonpath="$json_path" 2>&1 | grep -q "Ready=True"; do - sleep 5;echo "waiting for kube-dns to be available" - kubectl get pods --all-namespaces + until kubectl -n kube-system get pods -l component=kube-controller-manager -o jsonpath="$json_path" 2>&1 | grep -q "Ready=True"; do + sleep 5; done + + kubectl get pods --all-namespaces } main "$@"