dxawnw / kube-ansible

Deploy Kubernetes binaries with ansible

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

kube-ansible

Refer to the README.md and group_vars/template.yml files for project configuration

Cloud Support

  • Azure
  • Aws(Apiserver HA use the CLB)
  • GCP(Apiserver HA use the TCP Load balancing)

OS Support

  • CentOS 7.*
  • CentOS 8.*
  • Ubuntu 16.04.6
  • Ubuntu 18.04.6

Kubernetes Support

  • 1.14.x
  • 1.15.x
  • 1.16.x
  • 1.17.x
  • 1.18.x

How to use

Preparation work

Clone code

# ubuntu
apt install git make -y
# centos
yum install git make -y
git clone https://github.com/buxiaomo/kube-ansible.git /usr/local/src/kube-ansible
cd /usr/local/src/kube-ansible

Install ansible

make runtime

Download binaries

if you want to use local package files, reference here.

if you want to download package from nexus, reference here.

Parameter describe Default option
DOWNLOAD_WAY Binary download mode official official or nexus
KUBE_VERSION Kubernetes binary version 1.14.4 N/A
DOCKER_VERSION Docker binary version 19.03.9 N/A
ETCD_VERSION Etcd binary version 3.4.5 N/A
CNI_VERSION CNI binary version 0.8.5 N/A
NEXUS_HTTP_USERNAME Nexus username N/A N/A
NEXUS_HTTP_PASSWORD Nexus password N/A N/A
NEXUS_DOMAIN_NAME Nexus domain name nexus.xiaomo.site N/A
NEXUS_REPOSITORY binary repository name, you can use 'upload-nexus.py' N/A N/A
official download
make download DOWNLOAD_WAY=official
nexus download
make download DOWNLOAD_WAY=nexus \
NEXUS_DOMAIN_NAME=nexus.xiaomo.site \
NEXUS_REPOSITORY=kube-ansible \
NEXUS_HTTP_USERNAME=admin \
NEXUS_HTTP_PASSWORD=admin \
KUBE_VERSION=1.16.8 \
DOCKER_VERSION=19.03.8 \
FLANNEL_VERSION=0.12.0 \
ETCD_VERSION=3.4.5

Kubernetes management

Deploy

asciicast

# default version
make sync
make install

# custom version
make sync KUBE_VERSION=1.14.4
make install KUBE_VERSION=1.14.4 DOCKER_VERSION=19.03.8 FLANNEL_VERSION=0.12.0 ETCD_VERSION=3.4.5

Scale

add node to hosts file.

# default version
make scale

# custom version
make scale KUBE_VERSION=1.16.8 DOCKER_VERSION=19.03.8 FLANNEL_VERSION=0.12.0 ETCD_VERSION=3.4.5

Upgrade

Download new kubernetes binaries, Reference here.

make upgrade KUBE_VERSION=1.18.5

Kubernetes Extended application

This repo only deploy a kubernetes cluster and core application like 'coredns', 'calico', 'canal', 'flannel', not support extended application, like 'jenkins', 'ingress'...

if you want to deploy extended application, please reference here.

about nexus package

create an raw repository, and upload the binaries package.

you can use scripts/upload-nexus.py file

component attributes of directory format:

  • /linux/static/stable/x86_64/docker-${DOCKER_VERSION}.tgz
  • /coreos/flannel/releases/download/${FLANNEL_VERSION}/flannel-v${FLANNEL_VERSION}-linux-amd64.tar.gz
  • /coreos/etcd/releases/download/v${ETCD_VERSION}/etcd-v${ETCD_VERSION}-linux-amd64.tar.gz
  • /kubernetes-release/release/v${KUBE_VERSION}/bin/linux/amd64/kube-apiserver
  • /kubernetes-release/release/v${KUBE_VERSION}/bin/linux/amd64/kube-controller-manager
  • /kubernetes-release/release/v${KUBE_VERSION}/bin/linux/amd64/kube-scheduler
  • /kubernetes-release/release/v${KUBE_VERSION}/bin/linux/amd64/kubectl
  • /kubernetes-release/release/v${KUBE_VERSION}/bin/linux/amd64/kube-proxy
  • /kubernetes-release/release/v${KUBE_VERSION}/bin/linux/amd64/kubelet

use local package

download package save to scripts/src directory.

package name format:

  • docker-${DOCKER_VERSION}.tgz
  • flannel-v${FLANNEL_VERSION}-linux-amd64.tar.gz
  • etcd-v${ETCD_VERSION}-linux-amd64.tar.gz
  • kubernetes-client-linux-amd64.v${KUBE_VERSION}.tar.gz
  • kubernetes-server-linux-amd64.v${KUBE_VERSION}.tar.gz
  • cni-plugins-linux-amd64-v${CNI_VERSION}.tgz

all version please consistent with the makefile or make command

example:

cd scripts/src
KUBE_VERSION=1.14.4
wget https://download.docker.com/linux/static/stable/x86_64/docker-19.03.8.tgz
wget https://github.com/coreos/flannel/releases/download/v0.12.0/flannel-v0.12.0-linux-amd64.tar.gz
wget https://dl.k8s.io/v${KUBE_VERSION}/kubernetes-client-linux-amd64.tar.gz -O kubernetes-client-linux-amd64.v${KUBE_VERSION}.tar.gz
wget https://dl.k8s.io/v${KUBE_VERSION}/kubernetes-server-linux-amd64.tar.gz -O kubernetes-server-linux-amd64.v${KUBE_VERSION}.tar.gz
wget https://github.com/coreos/etcd/releases/download/v3.4.5/etcd-v3.4.5-linux-amd64.tar.gz
wget https://github.com/containernetworking/plugins/releases/download/v0.8.5/cni-plugins-linux-amd64-v0.8.5.tgz

knowledge

About

Deploy Kubernetes binaries with ansible


Languages

Language:Python 98.4%Language:Shell 1.2%Language:Makefile 0.3%Language:Dockerfile 0.2%