Zack Williams | 41513bf | 2018-07-07 20:08:35 -0700 | [diff] [blame] | 1 | # Copyright 2017-present Open Networking Foundation |
| 2 | # |
| 3 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | # you may not use this file except in compliance with the License. |
| 5 | # You may obtain a copy of the License at |
| 6 | # |
| 7 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | # |
| 9 | # Unless required by applicable law or agreed to in writing, software |
| 10 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | # See the License for the specific language governing permissions and |
| 13 | # limitations under the License. |
Richard Jankowski | d7921b7 | 2018-02-20 16:55:12 -0500 | [diff] [blame] | 14 | - name: Install Kubernetes dependencies |
| 15 | become: yes |
| 16 | apt: |
| 17 | name: "{{ item }}" |
| 18 | state: latest |
| 19 | with_items: |
| 20 | - apt-transport-https |
| 21 | - jq |
| 22 | |
| 23 | - name: Get apt signing key from Google Cloud |
| 24 | become: yes |
| 25 | apt_key: |
| 26 | url: https://packages.cloud.google.com/apt/doc/apt-key.gpg |
| 27 | state: present |
| 28 | |
| 29 | - name: Add Kubernetes apt repository |
| 30 | become: yes |
| 31 | apt_repository: |
| 32 | repo: 'deb http://apt.kubernetes.io/ kubernetes-xenial main' |
| 33 | filename: kubernetes |
| 34 | state: present |
| 35 | update_cache: yes |
| 36 | |
| 37 | - name: Install Kubernetes |
| 38 | become: yes |
| 39 | apt: |
| 40 | name: "{{ item }}" |
| 41 | state: present |
| 42 | with_items: |
Richard Jankowski | 8f52afb | 2018-03-29 14:19:11 -0400 | [diff] [blame] | 43 | - kubeadm=1.9.3-00 |
| 44 | - kubectl=1.9.3-00 |
| 45 | - kubelet=1.9.3-00 |
Richard Jankowski | d7921b7 | 2018-02-20 16:55:12 -0500 | [diff] [blame] | 46 | - kubernetes-cni=0.6.0-00 |
| 47 | |
| 48 | - name: Initialize node as Kubernetes master |
| 49 | become: yes |
Richard Jankowski | 8f52afb | 2018-03-29 14:19:11 -0400 | [diff] [blame] | 50 | command: "kubeadm init --pod-network-cidr=192.168.0.0/16 --apiserver-advertise-address=10.100.198.220" |
Richard Jankowski | d7921b7 | 2018-02-20 16:55:12 -0500 | [diff] [blame] | 51 | |
| 52 | - name: Create .kube directory under home |
| 53 | become: yes |
| 54 | file: |
| 55 | dest: /home/ubuntu/.kube |
| 56 | mode: 0755 |
| 57 | owner: ubuntu |
| 58 | group: ubuntu |
| 59 | state: directory |
| 60 | |
| 61 | - name: Copy config to home directory |
| 62 | become: yes |
| 63 | command: "sudo cp /etc/kubernetes/admin.conf /home/ubuntu/.kube/config" |
| 64 | |
| 65 | - name: Change ownership of ~/.kube/config |
| 66 | become: yes |
| 67 | file: |
| 68 | path: /home/ubuntu/.kube/config |
| 69 | mode: 0600 |
| 70 | owner: ubuntu |
| 71 | group: ubuntu |
| 72 | |
| 73 | - name: Set proxy-mode flag in kube-proxy daemonset (workaround for https://github.com/kubernetes/kubernetes/issues/34101) |
| 74 | become: yes |
| 75 | shell: "kubectl --kubeconfig=/etc/kubernetes/admin.conf -n kube-system get ds -l 'k8s-app==kube-proxy' -o json | jq '.items[0].spec.template.spec.containers[0].command |= .+ [\"--proxy-mode=userspace\"]' | kubectl --kubeconfig=/etc/kubernetes/admin.conf apply -f - && kubectl --kubeconfig=/etc/kubernetes/admin.conf -n kube-system delete pods -l 'k8s-app==kube-proxy'" |
| 76 | register: proxy |
| 77 | until: proxy.rc == 0 |
| 78 | retries: 60 |
| 79 | delay: 10 |
| 80 | |
| 81 | - name: Allow workloads on Kubernetes master |
| 82 | become: yes |
| 83 | command: "kubectl --kubeconfig=/etc/kubernetes/admin.conf taint nodes --all node-role.kubernetes.io/master-" |
| 84 | |
| 85 | - name: Install pod network |
| 86 | become: yes |
Richard Jankowski | 8f52afb | 2018-03-29 14:19:11 -0400 | [diff] [blame] | 87 | command: "kubectl --kubeconfig=/etc/kubernetes/admin.conf apply -f /cord/incubator/voltha/k8s/calico-1.6.yml" |