Several tests are specified in .travis.yml. They usually follow this layout:
stage: Some Integration Test (--platform=kubernetes)
os: linux
before_script:
# download and install kubectl and setup cluster
script:
- kubectl get nodes || travis_terminate 1
# finally install keptn quality gates
- test/test_install_on_kubernetes.sh
- keptn status
- export PROJECT=musicshop
- test/test_quality_gates_standalone.sh
after_success:
# clean up cluster, etc...
- echo "Tests were successful, cleaning up the cluster now..."
after_failure:
# print some debug info
- echo "Keptn Installation Log:"
- cat ~/.keptn/keptn-installer.log
before_script
: Set upkubectl
,keptn
CLI and create a Kubernetes clusterscript
: Verify connection to the kubernetes cluster, install Keptn (e.g.,test/test_install_kubernetes_quality_gates.sh
), verify connection to Keptn (keptn status
) and run the actual test (e.g.,test/test_quality_gates_standalone.sh
)after_success
: Perform some cleanup (e.g., delete the cluster if necessary)after_failure
: Print some debug output
There are some caveats when creating a Kubernetes cluster on Travis-CI:
- It is possible to create and connect to an external cluster (e.g., GKE, AWS, ...). However, this requires secrets for the cloud provider to be set on Travis-CI, and accessing those secrets only works for commits that are pushed within the current repository. It does not work for Pull Requests from forks.
- It is possible to run docker on Travis-CI.
- It is not possible to create a virtual-machine on Travis-CI. Therefore, setting up K3s, Minishift or Minikube on Travis-CI
only works with some specific settings (e.g.,
minishift start --vm-driver=generic
orminikube start --vm-driver=none
). With this,minishift
andminikube
use the local docker installation of Travis-CI. Please note, with this setup we are limited to 2 vCPUs and 4 GB of memory (see https://docs.travis-ci.com/user/reference/overview/#virtualisation-environment-vs-operating-system for details)
Above limitations lead to the following setup with Keptn's .travis.yml
:
- We test the full installation (
--use-case=continuous-delivery
) onGKE
once per day on the master branch via a Travis-CI cron job. - We test the default installation on Minikube, MicroK8s and Minishift for every push on the master branch (e.g., after merging a pull-request).
- This type of installation is limited to
--gateway=NodePort
- This type of installation is limited to
When running integration tests locally, we recommend using either K3s, Minikube or Minishift.
Starting and setting up K3s is easy:
- Download, install and run K3s (tested with versions 1.16 to 1.18):
curl -sfL https://get.k3s.io | INSTALL_K3S_VERSION=v1.18.3+k3s1 K3S_KUBECONFIG_MODE="644" sh -s - --no-deploy=traefik
- Export the Kubernetes config using:
Please read more about it here.
export KUBECONFIG=/etc/rancher/k3s/k3s.yaml
- Verify that everything has worked using
kubectl get nodes
In case you plan to use Minikube, the following steps are necessary to get Keptn running on Minikube:
-
Download and install Minikube (versions 1.4 to 1.10 should work) from https://github.com/kubernetes/minikube/releases for your operating system.
-
Make sure you create a fresh Minikube cluster (using a VM):
minikube stop # optional minikube delete # optional minikube start [--vm-driver=...] --cpus 2 --memory 4096 # or: minikube start --cpus 6 --memory 12200
Note: In some cases you have to specify
--vm-driver=...
to select virtualbox, kvm, hyperv, etc... - please find out more that the official MiniKube docsNote: On Linux
--vm-driver=docker
should work in most casesNote: For the quality gates use case 2 CPUs and 4096 MB memory is enough, for the full installation we recommend at least 6 CPUs and 12200 MB memory
-
Verify that everything has worked using
kubectl get nodes
In case you plan to use Minishift, the following steps are necessary to get Keptn running on Minishift (1.34.2):
-
Download and install Minishift 1.34.2 (from https://github.com/minishift/minishift/releases) for your operating system
-
Setup Minishift profile, cpu and memory limits:
# make sure you have a profile is set correctly minishift profile set keptn-dev # minimum memory required for the minishift VM minishift config set memory 4GB # Note: use 12 GB for full installation # the minimum required vCpus for the minishift vm minishift config set cpus 2 # Note: use 6 for full installation # Add new user called admin with password admin having role cluster-admin minishift addons enable admin-user # Allow the containers to be run with uid 0 minishift addons enable anyuid
Note: For the quality-gates use-case 2 vCPUs and 4 GB memory is enough. For the full installation you should use more CPUs (e.g., 6) and more memory (e.g., 12 GB)
-
Start Minishift:
minishift start
-
Enable admission WebHooks on your OpenShift master node:
minishift openshift config set --target=kube --patch '{ "admissionConfig": { "pluginConfig": { "ValidatingAdmissionWebhook": { "configuration": { "apiVersion": "apiserver.config.k8s.io/v1alpha1", "kind": "WebhookAdmission", "kubeConfigFile": "/dev/null" } }, "MutatingAdmissionWebhook": { "configuration": { "apiVersion": "apiserver.config.k8s.io/v1alpha1", "kind": "WebhookAdmission", "kubeConfigFile": "/dev/null" } } } } }'
-
Login via
oc
cli (you might need to try a couple of times):oc login -u admin -p admin
Note: It takes a couple of minutes before your Minishift cluster is ready. Expect error messages like
Error from server (InternalError): Internal error occurred: unexpected response: 400
and retry again.
-
Set policies/permissions:
oc adm policy --as system:admin add-cluster-role-to-user cluster-admin admin oc adm policy add-cluster-role-to-user cluster-admin system:serviceaccount:default:default oc adm policy add-cluster-role-to-user cluster-admin system:serviceaccount:kube-system:default
-
Note down the Minishift server URL printed by
oc status
(e.g.,https://192.168.99.101:8443
)
Pre-requisites:
- A K8s cluster (see above)
- 4 GB of free memory (less is possible but you will notice a significant slowdown)
- at least 2 CPU cores on your system (less is possible but you will notice a significant slowdown)
kubectl
keptn
CLI- A local copy of this repository (keptn/keptn)
- Linux, Mac OS or Linux Subsystem for Windows
- Bash
- Dynatrace Tenant with a service that has the tags
FrontEnd
andtestdeploy
- Dynatrace API Token that is allowed to read metrics from the Dynatrace Tenant
- working internet connection
- Setup your Kubernetes cluster (see above)
keptn
CLI available- Verify
kubectl
is configured to the right cluster:kubectl get nodes
- Install Keptn
- K3s
keptn install --verbose
- Minikube
Note: You can use
keptn install --endpoint-service-type=NodePort --verbose
--endpoint-service-type=LoadBalancer
if you runminikube tunnel
- Minishift
keptn install --platform=openshift --verbose
--chart-repo=https://storage.googleapis.com/keptn-installer/latest/keptn-0.1.0.tgz
to install the latest master branch, see master installation docs. - K3s
- Verify the installation has worked
keptn status
- Verify which images have been deployed
kubectl -n keptn get deployments -owide
- Expose Keptn Bridge for better troubleshooting and debugging
keptn configure bridge --action=expose
- Verify accessing Keptn Bridge works
- Configuration for the test:
export PROJECT=easytravel export SERVICE=frontend export STAGE=hardening export QG_INTEGRATION_TEST_DT_TENANT=<INSERT_YOUR_DT_TENANT_HERE> export QG_INTEGRATION_TEST_DT_API_TOKEN=<INSERT_YOUR_DT_API_TOKEN_HERE>
- Run the test
bash ./test/test_quality_gates_standalone.sh
Pre-requisites:
- A K8s cluster (see above)
- 12 GB of free memory (less is possible but you will notice a significant slowdown)
- at least 6 CPU cores on your system (less is possible but you will notice a significant slowdown)
kubectl
keptn
CLI- A local copy of this repository (keptn/keptn)
- Linux, Mac OS or Linux Subsystem for Windows
- Bash
- working internet connection
- Setup your Kubernetes cluster (see above)
- Verify
kubectl
is configured to the right cluster:kubectl get nodes
keptn
CLI available- Install Keptn
- K3s
keptn install --use-case=continuous-delivery --verbose
- Minikube
Note: You can use
keptn install --use-case=continuous-delivery --endpoint-service-type=NodePort --verbose
--endpoint-service-type=LoadBalancer
if you runminikube tunnel
- Minishift
keptn install --use-case=continuous-delivery --platform=openshift --verbose
--chart-repo=https://storage.googleapis.com/keptn-installer/latest/keptn-0.1.0.tgz
to install the latest master branch, see master installation docs. - K3s
- Verify the installation has worked
keptn status
- Verify which images have been deployed
kubectl -n keptn get deployments -owide
- Run tests (e.g., UniformRegistration):
cd test/go-tests && go test -run UniformRegistration -v