-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy path.travis.yml
73 lines (64 loc) · 3.85 KB
/
.travis.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
sudo: required
# We need the systemd for the kubeadm and it's default from 16.04+
dist: bionic
env:
global:
- CHANGE_MINIKUBE_NONE_USER=true
- MINIKUBE_WANTUPDATENOTIFICATION=false
- MINIKUBE_WANTREPORTERRORPROMPT=false
- MINIKUBE_HOME=$HOME
- CHANGE_MINIKUBE_NONE_USER=true
- KUBECONFIG=$HOME/.kube/config
- CRICTL_VERSION="v1.24.2"
before_install:
- sudo apt-get -qq -y install conntrack
before_script:
# Download kubectl, which is a requirement for using minikube.
- curl -Lo kubectl https://storage.googleapis.com/kubernetes-release/release/v1.25.1/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.26.1/minikube-linux-amd64 && chmod +x minikube && sudo mv minikube /usr/local/bin/
- mkdir -p $HOME/.kube $HOME/.minikube
- touch $KUBECONFIG
# Need recent/latest golang
- sudo wget https://storage.googleapis.com/golang/getgo/installer_linux
- sudo chmod +x ./installer_linux
- sudo ./installer_linux
# We want this go found before any older go installed by Travis
# hence, we can't just source the .bash_profile that the installer updated
- export PATH=/home/travis/.go/bin:$PATH
- export GOROOT="/home/travis/.go/"
- go version
# Now install cri-dockerd source, build it and install as root to /usr/bin (needed by sudo)
- git clone https://github.com/Mirantis/cri-dockerd.git
- cd cri-dockerd && mkdir bin && go build -o bin/cri-dockerd
- sudo mkdir -p /usr/local/bin
- sudo install -o root -g root -m 0755 bin/cri-dockerd /usr/bin/cri-dockerd
- sudo cp -a packaging/systemd/* /etc/systemd/system
- sudo systemctl daemon-reload
- sudo systemctl enable cri-docker.service
- sudo systemctl enable --now cri-docker.socket
- cd ..
# Make sure crictl is in /usr/bin for it to be found by sudo
- curl -L https://github.com/kubernetes-sigs/cri-tools/releases/download/${CRICTL_VERSION}/crictl-${CRICTL_VERSION}-linux-amd64.tar.gz --output crictl-${CRICTL_VERSION}-linux-amd64.tar.gz
- sudo tar zxvf crictl-${CRICTL_VERSION}-linux-amd64.tar.gz -C /usr/bin
- rm -f crictl-${CRICTL_VERSION}-linux-amd64.tar.gz
- sudo cp crictl.yaml /etc/crictl.yaml
- crictl ps
# Now startup minikube using the docker driver, can't use none driver anymore since kubernetes stopped using dockershim
- minikube start --profile=minikube --vm-driver=docker --kubernetes-version=v1.24.1
- minikube update-context --profile=minikube
- "sudo chown -R travis: /home/travis/.minikube/"
- eval "$(minikube docker-env --profile=minikube)" && export DOCKER_CLI='docker'
- echo "Note for now, even though we're setting docker-env, you may still need to run minikube image load and minikube image tag in your build steps"
# Minikube based on Docker driver can sometimes have MTU mistmach issues, causing external http fetches to fail
# This iptables workaround fixes that
- sudo iptables -t mangle -A POSTROUTING -p tcp --tcp-flags SYN,RST SYN -j TCPMSS --clamp-mss-to-pmtu
script:
# Following is just to demo that the kubernetes cluster works.
- kubectl cluster-info
# Wait for kube-dns to be ready.
- JSONPATH='{range .items[*]}{@.metadata.name}:{range @.status.conditions[*]}{@.type}={@.status};{end}{end}'; until kubectl -n kube-system get pods -lk8s-app=kube-dns -o jsonpath="$JSONPATH" 2>&1 | grep -q "Ready=True"; do sleep 1;echo "waiting for kube-dns to be available"; kubectl get pods --all-namespaces; done
# Create example Redis deployment on Kubernetes.
- kubectl run travis-example --image=redis --labels="app=travis-example"
# Make sure created pod is scheduled and running.
- JSONPATH='{range .items[*]}{@.metadata.name}:{range @.status.conditions[*]}{@.type}={@.status};{end}{end}'; until kubectl -n default get pods -lapp=travis-example -o jsonpath="$JSONPATH" 2>&1 | grep -q "Ready=True"; do sleep 1;echo "waiting for travis-example deployment to be available"; kubectl get pods -n default; done