ansible安装
安装ansible
1 2 3 4
| pip install virtualenv virtualenv --no-site-packages venv source venv/bin/active pip install ansbile
|
ansbile主机配置
1 2
| [test] 127.0.0.1 ansible_ssh_user=aaa ansible_ssh_port=22 ansible_ssh_pass=aaa
|
注释这么配置不好,但初始这样配置,为了之后批量分发,分发后请删除这个账户
ansbile批量推送公钥
1 2
| ssh-keygen ansible-playbook -i hosts ssh.yml
|
推送文件ssh.yml
1 2 3 4 5 6 7 8
| # Using alternate directory locations: - hosts: test user: aaa tasks: - name: ssh-copy authorized_key: user=aaa key="{{ lookup('file', '/home/aaa/.ssh/id_rsa.pub') }}" tags: - sshkey
|
执行代码
1
| ansible test -i ./hosts -m command -a "echo 'aa'"
|
k8s安装(需要翻墙)
1 2 3 4 5 6 7 8
| apt-get update && apt-get install -y apt-transport-https curl curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add - cat <<EOF >/etc/apt/sources.list.d/kubernetes.list deb https://apt.kubernetes.io/ kubernetes-xenial main EOF apt-get update apt-get install -y kubelet kubeadm kubectl kubernetes-cni docker.io apt-mark hold kubelet kubeadm kubectl
|
配置文件
1 2 3 4 5 6 7 8 9 10 11 12
| apiVersion: kubeadm.k8s.io/v1alpha2 kind: MasterConfiguration api: advertiseAddress: 0.0.0.0 networking: podSubnet: 10.244.0.0/16 etcd: image: registry.cn-hangzhou.aliyuncs.com/google_containers/etcd-amd64:3.1.11 kubernetesVersion: v1.12.1 imageRepository: registry.cn-hangzhou.aliyuncs.com/google_containers
imageRepository: registry.cn-hangzhou.aliyuncs.com/google_containers
|
1 2 3 4 5 6 7 8 9 10 11 12
| sudo swapoff -a 1. 为docker服务创建一个内嵌的systemd目录
$ mkdir -p /etc/systemd/system/docker.service.d
2. 创建/etc/systemd/system/docker.service.d/http-proxy.conf文件,并添加HTTP_PROXY环境变量。其中[proxy-addr]和[proxy-port]分别改成实际情况的代理地址和端口: [Service] Environment="HTTP_PROXY=http://[proxy-addr]:[proxy-port]/" "HTTPS_PROXY=http://[proxy-addr]:[proxy-port]/" $ systemctl daemon-reload $ systemctl restart docker sudo kubeadm init --config ./kubeadm.conf
|
1 2
| sudo kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/master/Documentation/k8s-manifests/kube-flannel-legacy.yml 需要安装flannel
|