Deploy Kubernetes with official aansible

Source: Internet
Author: User
Tags ansible playbook

First, the deployment environment

Reference article: Through the official Ansible deployment Kubernetes

Note: Because the installation of software needs to download the external network, so this document is only suitable for use in the extranet environment of the host, that can access: Google's host

1. Installation Host

This deployment uses exsi6.7 virtual machine CENTOS7, which is configured as table:

IP Address Host CPU Memory
192.168.123.121 Master1 1 2G
192.168.123.122 Node1 1 2G
192.168.123.123 Node2 1 2G
2, set the host free-secret settings node name and add hosts:

Modify the/etc/hostname name and add node information in the/etc/hosts, respectively, in each host.

#修改为master1vim /etc/hostname#添加节点信息vim /etc/hosts192.168.123.121 master1192.168.123.122 node1192.168.123.123 node2
Add a free-secret setting

Add the encryption key pair to each host individually:

ssh-keygen -t rsa

Use Master1 as the publisher to make the other hosts free of secret settings:

ssh master1 "cat  >> ~/.ssh/authorized_keys" < ~/.ssh/id_rsa.pub
3, deploy Kubernetes Configuration installation environment, install the necessary software
yum install -y epel-releaseyum install -y ansible python-netaddr git
Download Kubernetes official Ansible Playbook Code
git clone "https://github.com/kubernetes/contrib.git"cd contrib/ansible
Configuring Ansible Playbook

Create a new Hosts file in the Inventory folder, and add the following:

[masters]master1[etcd:children]masters[nodes]node[1:2]

Use ansible to check if the nodes are connected:

ansible -i inventory/hosts all -m pingmaster1 | SUCCESS => {    "changed": false,     "ping": "pong"}node2 | SUCCESS => {    "changed": false,     "ping": "pong"}node1 | SUCCESS => {    "changed": false,     "ping": "pong"

Edit the Inventory/group_vars/all.yml file. Modify the following as follows:

source_type: packageManagercluster_name: cluster.kairennetworking: flannelcluster_logging: truecluster_monitoring: truekube_dash: truedns_setup: truedns_replicas: 1

Modify the Roles/flannel/defaults/main.yaml file as follows:

flannel_options: --iface=enp0s8

After the modification is complete, go to the Scripts directory and execute the following command to start the deployment:

INVENTORY=../inventory/hosts ./deploy-cluster.sh

Deployment takes a while, during the deployment process, the Ansible service will continue to report the installation process, we can know in real-time the installation to the specific step.

After the installation is complete, you can use Kubectl to view the node information:

kubectl get nodesNAME      STATUS    AGEnode1     Ready     41mnode2     Ready     41m

To view pod and SVC information:

kubectl get svc  --all-namespacesNAMESPACE     NAME                    CLUSTER-IP       EXTERNAL-IP   PORT(S)             AGEdefault       kubernetes              10.254.0.1       <none>        443/TCP             48mkube-system   elasticsearch-logging   10.254.195.56    <none>        9200/TCP            35mkube-system   heapster                10.254.184.180   <none>        80/TCP              35mkube-system   kibana-logging          10.254.154.10    <none>        5601/TCP            35mkube-system   kube-dns                10.254.0.10      <none>        53/UDP,53/TCP       35mkube-system   monitoring-grafana      10.254.192.97    <none>        80/TCP              35mkube-system   monitoring-influxdb     10.254.6.37      <none>        8083/TCP,8086/TCP   35m

Deploy Kubernetes with official aansible

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.