-
-
Save anjilinux/d3d5361412e723468094bf3e931da4d2 to your computer and use it in GitHub Desktop.
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
| --- | |
| # tasks file for master | |
| - name: Add repository for kubeadm | |
| yum_repository: | |
| name: Kubernetes | |
| description: YUM repo for kubeadm | |
| baseurl: https://packages.cloud.google.com/yum/repos/kubernetes-el7-$basearch | |
| enabled: yes | |
| gpgcheck: no | |
| - name: Add repository for docker | |
| yum_repository: | |
| name: docker-repo | |
| description: repo for docker | |
| baseurl: https://download.docker.com/linux/centos/7/x86_64/stable/ | |
| enabled: yes | |
| gpgcheck: no | |
| - name: Installing the docker software for k8s Cluster | |
| command: yum install docker-ce --nobest -y | |
| - name: Installing the Prerequisite software for k8s Cluster | |
| package: | |
| name: "{{ item }}" | |
| state: present | |
| loop: | |
| - iproute-tc | |
| - kubeadm | |
| - name: Starting the Docker & Kubelet Services | |
| service: | |
| name: "{{ item }}" | |
| state: started | |
| enabled: yes | |
| loop: | |
| - docker | |
| - kubelet | |
| - name: Changing the Docker Cgroup Driver | |
| copy: | |
| dest: /etc/docker/daemon.json | |
| content: | | |
| { | |
| "exec-opts": ["native.cgroupdriver=systemd"] | |
| } | |
| - name: Restarting the Docker Services | |
| service: | |
| name: docker | |
| state: restarted | |
| - name: stopping firewall service | |
| command: systemctl stop firewalld | |
| - name: Download All Docker Images for k8s Cluster | |
| shell: "kubeadm config images pull" | |
| - name: Updating the iptables | |
| copy: | |
| dest: /etc/sysctl.d/k8s.conf | |
| content: | | |
| net.bridge.bridge-nf-call-ip6tables = 1 | |
| net.bridge.bridge-nf-call-iptables = 1 | |
| - name: Change the value to ipv4 tables | |
| shell: "echo net.ipv4.ip_forward = 1 >> /etc/sysctl.conf" | |
| - name: Enable the ipv4 tables | |
| shell: "sudo sysctl -p /etc/sysctl.conf" | |
| - name: Loading the iptables | |
| shell: "sysctl --system" | |
| - name: Initializng k8s Master Node | |
| shell: "kubeadm init --pod-network-cidr=10.244.0.0/16 --ignore-preflight-errors=NumCPU --ignore-preflight-errors=Mem" | |
| - name: Creating a Directory for kubectl config file | |
| shell: "mkdir -p $HOME/.kube" | |
| - name: Copying the config file to workspace | |
| shell: "cp -i /etc/kubernetes/admin.conf $HOME/.kube/config" | |
| - name: Changing the Ownership | |
| shell: "chown $(id -u):$(id -g) $HOME/.kube/config" | |
| ignore_errors: yes | |
| - name: Setting up Overlay Network with CNI Plugin Flannel | |
| shell: "kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/master/Documentation/kube-flannel.yml" | |
| - name: Generate the token | |
| shell: "kubeadm token create --print-join-command" | |
| register: token | |
| - name: Print the token | |
| debug: | |
| var: token.stdout_lines |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment