首页 > 其他分享 >基于kubeasz的Kubernetes部署最佳实践

基于kubeasz的Kubernetes部署最佳实践

时间:2023-02-21 16:58:21浏览次数:35  
标签:node 01 nodename Kubernetes kubeasz 最佳 172.16 k8s

一、环境准备

  1、三台8核/16G内存/500G高速硬盘服务器和三台16核/32G内存/500G高速硬盘服务器   2、CentOS 7   3、关闭selinux和关闭防火墙   4、升级系统内核(参考:https://www.cnblogs.com/a120608yby/p/10169364.html)   二、配置免密登录
# 创建密钥对
ssh-keygen

复制密钥到所有节点包括自身
ssh-copy-id 所有节点的IP地址
  三、部署   1、下载源码、二进制文件或离线镜像
export release=3.5.2
wget https://github.com/easzlab/kubeasz/releases/download/${release}/ezdown
chmod +x ./ezdown

  2、下载kubeasz代码、二进制、默认容器镜像

# 国内环境
./ezdown -D

# 海外环境
./ezdown -D -m standard

  3、创建集群

# 容器化运行kubeasz
./ezdown -S

# 创建新集群 k8s-01
docker exec -it kubeasz ezctl new k8s-01

# 配置/etc/kubeasz/clusters/k8s-01/hosts和/etc/kubeasz/clusters/k8s-01/config.yml
# vim hosts
# 'etcd' cluster should have odd member(s) (1,3,5,...)
[etcd]
172.16.0.1
172.16.0.2
172.16.0.3

# master node(s), set unique 'k8s_nodename' for each node
# CAUTION: 'k8s_nodename' must consist of lower case alphanumeric characters, '-' or '.',
# and must start and end with an alphanumeric character
[kube_master]
172.16.0.1 k8s_nodename='master-01'
172.16.0.2 k8s_nodename='master-02'
172.16.0.3 k8s_nodename='master-03'

# work node(s), set unique 'k8s_nodename' for each node
# CAUTION: 'k8s_nodename' must consist of lower case alphanumeric characters, '-' or '.',
# and must start and end with an alphanumeric character
[kube_node]
172.16.0.4 k8s_nodename='worker-01'
172.16.0.5 k8s_nodename='worker-02'
172.16.0.6 k8s_nodename='worker-03'

# [optional] harbor server, a private docker registry
# 'NEW_INSTALL': 'true' to install a harbor server; 'false' to integrate with existed one
[harbor]
#192.168.1.8 NEW_INSTALL=false

# [optional] loadbalance for accessing k8s from outside
[ex_lb]
#192.168.1.6 LB_ROLE=backup EX_APISERVER_VIP=192.168.1.250 EX_APISERVER_PORT=8443
#192.168.1.7 LB_ROLE=master EX_APISERVER_VIP=192.168.1.250 EX_APISERVER_PORT=8443

# [optional] ntp server for the cluster
[chrony]
#192.168.1.1

[all:vars]
# --------- Main Variables ---------------
# Secure port for apiservers
SECURE_PORT="6443"

# Cluster container-runtime supported: docker, containerd
# if k8s version >= 1.24, docker is not supported
CONTAINER_RUNTIME="containerd"

# Network plugins supported: calico, flannel, kube-router, cilium, kube-ovn
CLUSTER_NETWORK="calico"

# Service proxy mode of kube-proxy: 'iptables' or 'ipvs'
PROXY_MODE="ipvs"

# K8S Service CIDR, not overlap with node(host) networking
SERVICE_CIDR="10.68.0.0/16"

# Cluster CIDR (Pod CIDR), not overlap with node(host) networking
CLUSTER_CIDR="10.20.0.0/16"

# NodePort Range
NODE_PORT_RANGE="30000-32767"

# Cluster DNS Domain
CLUSTER_DNS_DOMAIN="cluster.local"

# -------- Additional Variables (don't change the default value right now) ---
# Binaries Directory
bin_dir="/opt/kube/bin"

# Deploy Directory (kubeasz workspace)
base_dir="/etc/kubeasz"

# Directory for a specific cluster
cluster_dir="{{ base_dir }}/clusters/k8s-01"

# CA and other components cert/key Directory
ca_dir="/etc/kubernetes/ssl"

# Default 'k8s_nodename' is empty
k8s_nodename=''

  4、安装集群

# 一键安装
docker exec -it kubeasz ezctl setup k8s-01 all

参考:https://github.com/easzlab/kubeasz

标签:node,01,nodename,Kubernetes,kubeasz,最佳,172.16,k8s
From: https://www.cnblogs.com/a120608yby/p/17141560.html

相关文章

  • Kubernetes 网络策略 networkpolicy
     网络策略 在 IP 地址或端口层面(OSI 第 3 层或第 4 层)控制网络流量,为集群中特定应用使用 Kubernetes 网络策略(NetworkPolicy);Pod 可以通信的 Pod 是通过......
  • Kubernetes-yaml详解
    目录:Yaml语法格式查看api资源版本标签deployment模板service模板查询帮助和格式指令Pod模板写yaml太累怎么办yaml文件的学习方法deployment.yaml文件详解Servi......
  • 基于minikube快速搭建kubernetes单节点环境
    一、说明本文主要介绍在Centos7环境下基于Minikube来快速部署Kubernetes单节点集群环境,并在浏览器上访问部署在k8s上的dashboard服务。 二、Minikube介绍......
  • 容器化构建最佳实践
    在我们的开发过程中,少不了与容器打交道,几乎所有常用的应用的都会提供构建好的容器镜像以便用户快速体验。特别是越来越多的团队使用k8s作为容器平台,在应用部署的过程中也就......
  • kubeadm方式部署Kubernetes集群
    目录初始化准备安装kubeadm初始化Master集群将新的Node节点加入集群部署CNI网络插件其他配置初始化准备1、关闭防火墙Centos7默认启动了防火墙,而Kubernetes的Master与N......
  • 【算法训练营day49】LeetCode121. 买卖股票的最佳时机 LeetCode122. 买卖股票的最佳时
    LeetCode121.买卖股票的最佳时机题目链接:121.买卖股票的最佳时机独上高楼,望尽天涯路感觉贪心会更简单,动态规划反而搞复杂了对于这道题。慕然回首,灯火阑珊处第一次看......
  • [kubernetes]集群中部署CoreDNS服务
    前言从k8s1.11版本开始,k8s集群的dns服务由CoreDNS提供。之前已经使用二进制文件部署了一个三master三node的k8s集群,现在需要在集群内部部署DNS服务。环境信息IP......
  • Kubernetes集群部署Prometheus和Grafana
    一、环境规划K8S集群角色Ip主机名控制节点192.168.84.155master1工作节点192.168.84.156node1工作节点192.168.84.157node......
  • Kubernetes(七)
    一、日志收集案例-容器内置日志收集容器内置日志收集架构应用程序以tomcat为例,实现方法如下:1.1构建镜像1.1.1准备基础tomcat镜像tomcat基础镜像构建参考:5.1.2tom......
  • 【云原生kubernetes】k8s service使用详解
    一、什么是服务service?在k8s里面,每个Pod都会被分配一个单独的IP地址,但这个IP地址会随着Pod的销毁而消失,重启pod的ip地址会发生变化,此时客户如果访问原先的ip地址则会报错;S......