Git Product home page Git Product logo

ansible-kubernetes's Introduction

QuickStart Kubernetes Cluster

调试命令

docker run `
--rm `
-h ansible `
-v $PWD/:/etc/ansible `
-w /etc/ansible/linux `
--entrypoint=bash `
-it registry.cn-qingdao.aliyuncs.com/wod/ansible:2.7.10

项目目标

  • 快速搭建一个Kubernetes集群

限制条件

  • Linux Kernel >= 5.3 , 推荐 Ubuntu 20.04

核心组件

  • 容器引擎: docker-ce 19.3.8
  • 数据库: etcd v3.4
  • 容器平台: kubernetes v1.18.x
  • 网络组件: flannel v0.12.0 , calico v3.13 , kube-router v1.0.0 , cilium v1.7.2
  • 扩展组件: coredns 1.5.2 , dashboard v2.0.0 , traefik v1.17

开始

1.准备主机

确保ansible能通过密钥来登录服务器,修改以下文件
/root/.ssh/authorized_keys

ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAAgQDCJNFRbNc0SsHa/+mWB71z7SLPH9rQpwEqGbRo7q466a97h3bejNav9wc9AKmepHPfRw7DJfSmWO3lGBya0QkXMYXVvtfcWPvZZDlar5JK/ZsC8HGOpwVLdd1uUfyPu2qM0sjRNA/Ty8PDMkS5dSyZAJNlxUAILRpepkYoT8jhrw== ansible@docker

检查每台主机上的时间
时间差距在30s以内,或者装个NTP来同步时间
apt install ntp -y && ntpdate -u time.windows.com

./hosts

[systech]
ubuntu-1 ansible_ssh_host=192.168.1.200 ansible_ssh_port=22 ansible_ssh_user=root ansible_python_interpreter=/opt/bin/python
ubuntu-2 ansible_ssh_host=192.168.1.201 ansible_ssh_port=22 ansible_ssh_user=root ansible_python_interpreter=/opt/bin/python

2.修改配置文件

修改配置文件中的参数
ubuntu-1是Master
./linux/group_vars/systech.yml

# docker
DOCKER_DATA_PATH: /data/docker

# etcd options
ETCD_CLUSTER_ROLE:
  ubuntu-1: etcd

# k8s option
# K8S_ADMIN_TOKEN , 管理员访问Token , 请设置为随机值
# K8S_NETWORK_PLUGIN , 网络插件 , flannel , kube-router , cilium , calico
K8S_ADMIN_TOKEN: "pleasechangeit"
K8S_NETWORK_PLUGIN: cilium
K8S_SERVICE_PORT_RANGE: 1-65535
K8S_CLUSTER_ROLE:
  ubuntu-1: master

# registry options
REGISTRY_LOCAL_HOSTNAME: ubuntu-1
REGISTRY_LOCAL_IP: "{{ hostvars['ubuntu-1']['ansible_default_ipv4']['address'] }}"  
REGISTRY_LOCAL: "registry.cn-qingdao.aliyuncs.com/wod/"
REGISTRY_DATA_PATH: /data/kubernetes/registry
RKT_DATA_PATH: /data/kubernetes/rkt

# single master
K8S_MASTER_IP: "{{ hostvars['ubuntu-1']['ansible_default_ipv4']['address'] }}"  
K8S_MASTER_PORT: "6443"

K8S_DOMAIN: "home.wodcloud.local"

3.开始安装集群

Windows/Linux用户不需要安装ansible,在Docker中运行命令即可

# docker run
docker run `
--rm `
-h ansible `
-v $PWD/:/etc/ansible `
-w /etc/ansible/linux `
--entrypoint=bash `
-it registry.cn-qingdao.aliyuncs.com/wod/ansible:2.7.10

# install kubernetes cluster
ap 4.install-online.yml

# uninstall kubernetes cluster
ap 9.uninstall.yml

4.检查成果

https://k8s.home.wodcloud.local

使用上面设置的<K8S_ADMIN_TOKEN>来登录服务

5.练习视频

B站视频

Youtube

ansible-kubernetes's People

Contributors

bg-bigdata avatar mengkzhaoyun avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.