k8s部署 (进行中)

makoooo 2021-02-23 17:45:24
docker yml ansible


一.安装要求

1、准备环境

#系统centos7
#硬件:1个CPU,2G内存       
#可以访问外网,禁用swap
#提前安装docker环境

2、准备三台linux服务器(这里使用centos7虚拟机)

3、初始化系统环境,以下命令三台服务器全部执行

3.1、关闭防火墙

         # systemctl stop firewalld
        # systemctl disable firewalld

3.2、关闭selinux和swap

         # sed  -i 's/enforcing/disabled'  /etc/selinux/config
        # setenforce 0
       # swapoff -a  #临时关闭,永久关闭需要写入fatab

3.3、修改主机名

        # vim /etc/hostname

      192.168.37.74        K8S-master
      192.168.37.75        K8S-node01
      192.168.37.76        K8S-mast02

4、mac上配置Ansible

4.1、在Ansible服务器上的/etc/hosts文件中添加k8s服务器节点信息

               192.168.37.74 K8S-master
               192.168.37.75 K8S-node01
               192.168.37.76 K8S-node02

4.2、在Ansible服务器上的/etc/ansible/hosts文件中添加k8s服务器节点

[k8s-all]
K8S-master
K8S-node01
K8S-node02
[k8s-master]
K8S-master
[k8s-nodes]
K8S-node01
K8S-node02

4.3、修改k8s集群各节点/etc/hosts(非必须)

           修改所有主机/etc/hosts文件,添加IP/主机名映射,方便通过主机名ssh访问

      (1)创建playbook文件(参考 set_hosts_playbook.yml)

vim set_hosts_playbook.yml
---
- hosts: k8s-all
remote_user: root
tasks:
- name: backup /etc/hosts
shell: mv /etc/hosts /etc/hosts_bak
- name: copy local hosts file to remote
copy: src=/etc/hosts dest=/etc/ owner=root group=root mode=0644 

       (2)执行ansible-playbook

ansible-playbook set_hosts_playbook.yml

5、安装docker

在所有主机安装docker

5.1、创建playbook文件(参考 install_docker_playbook.yml)      

   $ vim install_docker_playbook.yml

- hosts: k8s-all
remote_user: root
vars:
docker_version: 18.09.2
tasks:
- name: install dependencies
#shell: yum install -y yum-utils device-mapper-persistent-data lvm2 
yum: name={{item}} state=present
with_items:
- yum-utils
- device-mapper-persistent-data
- lvm2
- name: config yum repo
shell: yum-config-manager --add-repo https://mirrors.ustc.edu.cn/docker-ce/linux/centos/docker-ce.repo
- name: install docker
yum: name=docker-ce-{{docker_version}} state=present
- name: start docker
shell: systemctl enable docker && systemctl start docker

5.2、执行ansible-playbook

ansible-playbook install_docker_playbook.yml

执行报错,国内无法连接docker默认的境外地址,把镜像地址换成 http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo再试一次。

版权声明
本文为[makoooo]所创,转载请带上原文链接,感谢
https://my.oschina.net/u/4673247/blog/4960866

  1. 开源办公开发平台丨Mysql5.7两套四节点主从结构环境搭建教程(二)
  2. 开源办公开发平台丨Mysql5.7两套四节点主从结构环境搭建教程(一)
  3. Open source office development platform mysql5.7 two sets of four node master-slave structure environment building tutorial (2)
  4. HTTP的“无状态”和REST的“状态转换”
  5. Open source office development platform mysql5.7 two sets of four node master-slave structure environment building tutorial (1)
  6. 【大数据哔哔集20210128】使用Hive计算环比和同比
  7. 【大数据哔哔集20210125】Kafka将逐步弃用对zookeeper的依赖
  8. 【大数据哔哔集20210124】有人问我Kafka Leader选举?我真没慌
  9. 【大数据哔哔集20210123】别问,问就是Kafka高可靠
  10. Spring 事务、异步和循环依赖有什么关系?
  11. Spring 动态代理时是如何解决循环依赖的?为什么要使用三级缓存?
  12. "Stateless" of HTTP and "state transition" of rest
  13. [big data bibiji 20210128] use hive to calculate month on month and year on year
  14. [big data bibiji 20210125] Kafka will gradually abandon its dependence on zookeeper
  15. [big data beeps 20210124] someone asked me about Kafka leader election? I'm not in a panic
  16. [big data bibiji 20210123] don't ask, ask is Kafka highly reliable
  17. jQuery Gantt Package 在Visual Studio中创建一个新的ASP.NET项目
  18. What is the relationship between spring transactions, asynchrony, and circular dependencies?
  19. How to solve circular dependency in spring dynamic proxy? Why use level 3 caching?
  20. Unicode码的二进制转换(Java)
  21. JAVA的函数式接口
  22. JAVA里的元祖类
  23. JQuery Gantt package to create a new ASP.NET project
  24. Binary conversion of Unicode code (Java)
  25. The functional interface of Java
  26. Yuanzu class in Java
  27. Java中的CPU占用高和内存占用高的问题排查
  28. HashMap连环问你能答出几道?
  29. IntelliJ IDEA 还能画思维导图,果然最强 IDE!
  30. java中的反射和代理
  31. Troubleshooting of high CPU and memory usage in Java
  32. How many questions can you answer?
  33. IntelliJ idea can also draw mind maps. It's really the strongest ide!
  34. Reflection and proxy in Java
  35. Java中的CPU占用高和内存占用高的问题排查
  36. Linux OOM(out of memory)
  37. mysql 自定义函数因参数名称报错
  38. Troubleshooting of high CPU and memory usage in Java
  39. Linux OOM(out of memory)
  40. MySQL user defined function error due to parameter name
  41. echarts-gl 3D 地图柱状图可视化GDP
  42. Visualization of histogram of ecarts GL 3D map
  43. 金三银四如何应对Redis面试,一文深入Redis实战实践!
  44. 阿里资深架构师定制金三银四面试整理出来的一份Java核心知识点.pdf
  45. 为什么Java开发工程师工资高,却很多人想转行?
  46. How to deal with the interview of redis!
  47. Ali senior architect customizes a Java core knowledge point sorted out in the interview of golden, silver and four.pdf
  48. Why do java development engineers have high salaries, but many people want to change careers?
  49. 用注解开发SpringMVC
  50. Developing spring MVC with annotations
  51. 编译redis报错/deps/hiredis/libhiredis.a解决
  52. Compile redis report error / DEPs / hirredis / libhirredis. A solution
  53. 用注解开发SpringMVC
  54. Developing spring MVC with annotations
  55. Spring学习笔记-01
  56. Centos安装和卸载docker
  57. Spring learning notes-01
  58. Installing and uninstalling docker in CentOS
  59. Java基础-异常
  60. Java基础-反射