Post

Running Kubernetes on AppVeyor with minikube

Running Kubernetes on AppVeyor with minikube

Original post from linux.xvx.cz

When I was playing with Kubernetes I made a lot of notes on how to do things. Then I realized it may be handy to put those notes to Github and let them go through some CI to be sure they are correct.

I was looking for a way to run Kubernetes via minikube in Travis CI and there are “some” ways: Running Kubernetes on Travis CI with minikube

Unfortunately I didn’t have much luck with the latest minikube (0.26) and the latest Kubernetes (1.10) when I tried to make it work on Travis. It looks like there are some problems with running the latest stuff on Travis and people are using older Kubernetes/minikube versions (like here: https://github.com/LiliC/travis-minikube/blob/master/.travis.yml).

Instead of troubleshooting Travis CI - I decided to use AppVeyor.

AppVeyor Kubernetes build screenshot

It’s another free service like Travis doing basically the same, but it has some advantages:

AppVeyor was mainly focused on Windows builds, but recently they announced the Linux build support (which is now in beta phase). Anyway, the possibility of using Ubuntu Xenial 16.04 (compared to old Ubuntu Trusty 14.04 in Travis) and SSH access to the VM makes it really interesting for CI.

I decided to try to use minikube with AppVeyor - so here is .appveyor.yml sample:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
image: ubuntu

build_script:
  # Download and install minikube
  # Download kubectl, which is a requirement for using minikube
  - curl -sL https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl -o kubectl
  - chmod +x kubectl
  - sudo mv kubectl /usr/local/bin/
  # Download minikube
  - curl -sL https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64 -o minikube
  - chmod +x minikube
  - sudo mv minikube /usr/local/bin/
  - sudo CHANGE_MINIKUBE_NONE_USER=true minikube start --vm-driver=none --memory=4096
  # Wait for Kubernetes to be up and ready (https://web.archive.org/web/20171213061419/https://blog.travis-ci.com/2017-10-26-running-kubernetes-on-travis-ci-with-minikube)
  - 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
  # Run commands
  - kubectl get nodes
  - kubectl get pods --all-namespaces

Real example:

Maybe if you need to test some Kubernetes commands / scripts / etc… you can use minikube and AppVeyor…

Enjoy :-)

This post is licensed under CC BY 4.0 by the author.