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
| # {{ ansible_managed }} | |
| [Unit] | |
| Description=etcd | |
| Documentation=https://github.com/coreos | |
| [Service] | |
| ExecStart=/usr/bin/etcd --name {{ inventory_hostname }} \ | |
| --cert-file=/etc/etcd/kubernetes.pem \ | |
| --key-file=/etc/etcd/kubernetes-key.pem \ | |
| --peer-cert-file=/etc/etcd/kubernetes.pem \ |
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
| # Expects `kubernetes_api_endpoint` as `--extra-vars "kubernetes_api_endpoint=xxxx"` | |
| - hosts: 127.0.0.1 | |
| connection: local | |
| tasks: | |
| - name: Set kubectl endpoint | |
| shell: "kubectl config set-cluster {{ cluster_name }} --certificate-authority={{ playbook_dir }}/../cert/ca.pem --embed-certs=true --server=https://{{ kubernetes_api_endpoint }}:6443" | |
| - name: Set kubectl credentials | |
| shell: "kubectl config set-credentials {{ user }} --token {{ token }}" |
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
| $ kubectl get nodes --output=jsonpath='{range .items[*]}{.status.addresses[?(@.type=="InternalIP")].address}{.spec.podCIDR}{"\n"}{end}' | |
| 10.43.0.30 10.200.2.0/24 | |
| 10.43.0.31 10.200.0.0/24 | |
| 10.43.0.32 10.200.1.0/24 |
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
| $ sudo route add -net 10.200.2.0 netmask 255.255.255.0 gw 10.43.0.30 metric 1 | |
| $ sudo route add -net 10.200.0.0 netmask 255.255.255.0 gw 10.43.0.31 metric 1 | |
| $ sudo route add -net 10.200.1.0 netmask 255.255.255.0 gw 10.43.0.32 metric 1 |
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
| $ sudo iptables -t nat -A POSTROUTING ! -d 10.0.0.0/8 -o eth0 -j MASQUERADE |
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
| PLAY RECAP **************************************************************************** | |
| master : ok=13 changed=12 unreachable=0 failed=0 | |
| worker1 : ok=13 changed=12 unreachable=0 failed=0 | |
| worker2 : ok=13 changed=12 unreachable=0 failed=0 |
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
| - hosts: masters | |
| become: yes | |
| tasks: | |
| - name: initialize the cluster | |
| shell: kubeadm init --pod-network-cidr=10.244.0.0/16 | |
| args: | |
| chdir: $HOME | |
| creates: cluster_initialized.txt | |
| - name: create .kube directory |
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
| $ kubectl get nodes | |
| NAME STATUS ROLES AGE VERSION | |
| kube01.test.local Ready control-plane,master 13m v1.20.1 |
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
| $ kubectl get nodes | |
| NAME STATUS ROLES AGE VERSION | |
| kube02.test.local Ready <none> 80s v1.20.1 | |
| kube01.test.local Ready control-plane,master 22m v1.20.1 | |
| kube03.test.local Ready <none> 69s v1.20.1 |
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
| resource "google_project_service" "compute" { | |
| service = "[compute.googleapis.com](http://compute.googleapis.com/)" | |
| depends_on = [google_project.project] | |
| } |