Task 23 | Launching frontend & Backend Application Multi-Node Kubernetes Cluster Using Ansible | ARTH


Task Description

  • Automate Kubernetes Cluster Using Ansible
  • Launch ec2-instances on AWS Cloud eg. for master and slave.
  • Create roles that will configure master node and slave node seperately.
  • Launch a wordpress and mysql database connected to it in the respectine slaves.
  • Expose the wordpress pod and client able hit the wordpress ip with its respective port.


  • Kubernetes is an open-source COE(Container Orchestration Engine) used for automating container apps deployment, scaling, and monitor/management.
  • Ansible is a automation tool used mostly for provisioning, configuration management, we can write infrastructure as code.


  • First we create role For launching Master & Slave with there tags.
  • Next we create roles for slave & master node & using join command we join slave to the master & create kubernates cluster.
  • So above steps are for creating Kubernates cluster now we are going to launch two pods in the cluster so for that we need create yml files for the pods & copied them to master node.
  • Next we run kubectl create command & create the nodes.
  • I have already included expose resource in the wppod.yml file, so we don’t need to run kubectl expose command separately.
  • Now we create debug tasks for retrieving the “exposed port” & “Database host IP”.
  • Master-Node
  • Pods YAML files
  • But first need host IP & exposed port
  • For accessing the wordpress, use below URL:
  • Now login to the Wordpress


Mistakes & learning

  • First time I failed to run the kubectl command in the respective directory. So for switching the directory we can use “chdir” parameter.
  • So this one mistake done by me unintentionally during the task is that when I launch the cluster, the IP range & flannel’s network range are different.
    By default flannel’s network range is “", so we have two option-
    1. Use pod-network-cidr= “” in kubeadm command.
    2. Edit flannel network range:-
    # kubectl edit configmap kube-flannel-cfg -n kube-system

    net-conf.json: |
    “Network”: “”,

    And then delete all the flannel pods
    # kubectl delete pods -l app=flannel -n kube-system




Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store