github.com/mirantis/virtlet@v1.5.2-0.20191204181327-1659b8a48e9b/examples/k8s.yaml (about) 1 --- 2 apiVersion: v1 3 kind: Service 4 metadata: 5 name: k8s 6 labels: 7 app: k8s 8 spec: 9 ports: 10 - port: 22 11 name: ssh 12 clusterIP: None 13 selector: 14 app: inner-k8s 15 --- 16 apiVersion: apps/v1 17 kind: StatefulSet 18 metadata: 19 name: k8s 20 spec: 21 serviceName: k8s 22 replicas: 3 23 selector: 24 matchLabels: 25 app: inner-k8s 26 template: 27 metadata: 28 labels: 29 app: inner-k8s 30 annotations: 31 kubernetes.io/target-runtime: virtlet.cloud 32 # set root volume size 33 VirtletRootVolumeSize: 4Gi 34 VirtletVCPUCount: "2" 35 VirtletCloudInitUserData: | 36 write_files: 37 - path: /etc/systemd/system/docker.service.d/env.conf 38 permissions: "0644" 39 owner: root 40 content: | 41 [Service] 42 Environment="DOCKER_OPTS=--storage-driver=overlay" 43 - path: /etc/apt/sources.list.d/kubernetes.list 44 permissions: "0644" 45 owner: root 46 content: | 47 deb http://apt.kubernetes.io/ kubernetes-xenial main 48 - path: /usr/local/bin/provision.sh 49 permissions: "0755" 50 owner: root 51 content: | 52 #!/bin/bash 53 set -u -e 54 set -o pipefail 55 curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add - 56 apt-get update 57 apt-get install -y docker.io kubelet kubeadm kubectl kubernetes-cni 58 sed -i 's/--cluster-dns=10\.96\.0\.10/--cluster-dns=10.97.0.10/' /etc/systemd/system/kubelet.service.d/10-kubeadm.conf 59 systemctl daemon-reload 60 if [[ $(hostname) =~ -0$ ]]; then 61 # master node 62 kubeadm init --token adcb82.4eae29627dc4c5a6 --pod-network-cidr=10.200.0.0/16 --service-cidr=10.97.0.0/16 --apiserver-cert-extra-sans=127.0.0.1,localhost 63 export KUBECONFIG=/etc/kubernetes/admin.conf 64 export kubever=$(kubectl version | base64 | tr -d '\n') 65 kubectl apply -f "https://cloud.weave.works/k8s/net?k8s-version=$kubever" 66 while ! kubectl get pods -n kube-system -l k8s-app=kube-dns|grep ' 1/1'; do 67 sleep 1 68 done 69 mkdir -p /root/.kube 70 chmod 700 /root/.kube 71 cp "${KUBECONFIG}" /root/.kube/config 72 echo "Master setup complete." >&2 73 else 74 # worker node 75 kubeadm join --token adcb82.4eae29627dc4c5a6 --discovery-token-unsafe-skip-ca-verification k8s-0.k8s:6443 76 echo "Node setup complete." >&2 77 fi 78 users: 79 - name: root 80 # VirtletSSHKeys only affects 'ubuntu' user for this image, but we want root access 81 ssh-authorized-keys: 82 - ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCaJEcFDXEK2ZbX0ZLS1EIYFZRbDAcRfuVjpstSc0De8+sV1aiu+dePxdkuDRwqFtCyk6dEZkssjOkBXtri00MECLkir6FcH3kKOJtbJ6vy3uaJc9w1ERo+wyl6SkAh/+JTJkp7QRXj8oylW5E20LsbnA/dIwWzAF51PPwF7A7FtNg9DnwPqMkxFo1Th/buOMKbP5ZA1mmNNtmzbMpMfJATvVyiv3ccsSJKOiyQr6UG+j7sc/7jMVz5Xk34Vd0l8GwcB0334MchHckmqDB142h/NCWTr8oLakDNvkfC1YneAfAO41hDkUbxPtVBG5M/o7P4fxoqiHEX+ZLfRxDtHB53 me@localhost 83 runcmd: 84 - /usr/local/bin/provision.sh 85 spec: 86 nodeSelector: 87 extraRuntime: virtlet 88 containers: 89 - name: ubuntu-vm 90 image: virtlet.cloud/cloud-images.ubuntu.com/xenial/current/xenial-server-cloudimg-amd64-disk1.img 91 imagePullPolicy: IfNotPresent 92 # tty and stdin required for `kubectl attach -t` to work 93 tty: true 94 stdin: true 95 readinessProbe: 96 tcpSocket: 97 port: 22 98 initialDelaySeconds: 5