Created
August 8, 2018 19:38
-
-
Save fabianvf/d9dd381cbda84b57e8d47487a5f2d58f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| language: go | |
| sudo: required | |
| go_import_path: github.com/water-hole/ansible-operator | |
| env: | |
| - CHANGE_MINIKUBE_NONE_USER=true | |
| before_script: | |
| # setup minikube | |
| - curl -Lo kubectl https://storage.googleapis.com/kubernetes-release/release/v1.9.0/bin/linux/amd64/kubectl && chmod +x kubectl && sudo mv kubectl /usr/local/bin/ | |
| - curl -Lo minikube https://storage.googleapis.com/minikube/releases/v0.25.2/minikube-linux-amd64 && chmod +x minikube && sudo mv minikube /usr/local/bin/ | |
| - sudo minikube start --vm-driver=none --kubernetes-version=v1.9.0 | |
| - minikube update-context | |
| # Wait until node is ready | |
| - JSONPATH='{range .items[*]}{@.metadata.name}:{range @.status.conditions[*]}{@.type}={@.status};{end}{end}'; until kubectl get nodes -o jsonpath="$JSONPATH" 2>&1 | grep -q "Ready=True"; do sleep 1; done | |
| install: | |
| # setup operator-sdk | |
| - go get github.com/golang/dep/cmd/dep | |
| - mkdir -p $GOPATH/src/github.com/operator-framework | |
| - cd $GOPATH/src/github.com/operator-framework | |
| - git clone https://github.com/operator-framework/operator-sdk | |
| - cd operator-sdk | |
| - git checkout master | |
| - make dep | |
| - make install | |
| script: | |
| # test builds work | |
| - cd $GOPATH/src/github.com/water-hole/ansible-operator | |
| - operator-sdk build quay.io/water-hole/ansible-operator | |
| # create example CRD and operator | |
| - pushd example | |
| - kubectl create -f deploy/rbac.yaml | |
| - kubectl create -f deploy/crd.yaml | |
| - kubectl create -f deploy/operator.yaml | |
| # wait for operator pod to run | |
| - pod=$(kubectl get pods | grep ansible-operator) | |
| - | | |
| while [[ "${pod}" != *"Running"* ]]; do | |
| kubectl get pods | |
| pod=$(kubectl get pods | grep ansible-operator) | |
| done | |
| - pod=$(echo $pod | awk '{print $1}') | |
| - kubectl logs $pod | |
| # set a test string, build example operator from previously built base image | |
| - sed -i s/hello\ world/travis\ test/g busybox/defaults/main.yml | |
| - docker build -t busybox-ansible-operator-test:test . | |
| - kubectl patch deployment ansible-operator -p '{"spec":{"template":{"spec":{"containers":[{"name":"ansible-operator","imagePullPolicy":"Never"}]}}}}' | |
| - kubectl set image deployment/ansible-operator *=busybox-ansible-operator-test:test | |
| # wait for new operator pod | |
| - kubectl get pods | |
| - sleep 5 | |
| - pod=$(kubectl get pods | grep ansible-operator) | |
| - | | |
| while [[ "${pod}" != *"Running"* ]]; do | |
| kubectl get pods | |
| pod=$(kubectl get pods | grep ansible-operator) | |
| done | |
| - pod=$(echo $pod | awk '{print $1}') | |
| - kubectl logs $pod | |
| # deploy example resource and check for test string | |
| - kubectl create -f deploy/cr.yaml | |
| - pod=$(kubectl get pods | grep example-busybox || true) | |
| - echo $pod | |
| - | | |
| while [[ "${pod}" != *"Running"* ]]; do | |
| kubectl get pods | |
| pod=$(kubectl get pods | grep example-busybox) | |
| done | |
| - kubectl get pods | |
| - pod=$(echo $pod | awk '{print $1}') | |
| - kubectl logs $pod | grep "travis test" | |
| jobs: | |
| include: | |
| - stage: deploy | |
| script: | |
| - bash echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin | |
| - docker push quay.io/water-hole/ansible-operator | |
| - docker tag busybox-ansible-operator-test:test quay.io/water-hole/busybox-ansible-operator | |
| - docker push quay.io/water-hole/busybox-ansible-operator | |
| stages: | |
| - test | |
| - name: deploy | |
| if: branch = master |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment