kk工具快速搭建k8s集群+Kubesphere容器平台!

您所在的位置:网站首页 k8s安装kubesphere kk工具快速搭建k8s集群+Kubesphere容器平台!

kk工具快速搭建k8s集群+Kubesphere容器平台!

2023-11-28 01:32| 来源: 网络整理| 查看: 265

文章目录 kk( KubeKey)工具安装-多节点模式步骤一:基础环境配置步骤二:安装环境依赖步骤三:安装kk工具步骤四:创建集群步骤五:查看安装结果 参考资料

kk( KubeKey)工具安装-多节点模式 步骤一:基础环境配置

说明:

​ 以下步骤,需要在Master结点与工作结点均执行

1.关闭防火墙或开放必要端口

systemctl stop firewalld # 停止防火墙服务 systemctl disable firewalld # 禁用防火墙服务

说明:结果

查看防火墙状态

systemctl status firewalld

在这里插入图片描述

当看到防火墙服务处于未激活状态表示关闭成功

若不关闭防火墙,可根据如下图关闭所需端口

在这里插入图片描述

2.确保结点互相通信

ping 10.13.167.28 ping 10.13.167.102

说明:结果

在这里插入图片描述

确保结点之间能够互相通信,以便搭建集群

3.设置时区

timedatectl set-timezone Asia/Shanghai

说明:

查看时区

timedatectl

在这里插入图片描述

设置时区为上海时区 步骤二:安装环境依赖

说明:

​ 以下步骤,需要在Master结点与工作结点均执行

1.安装依赖

yum install -y socat conntrack ebtables ipset

说明:

ebtables: ebtables 是一个用于以太网桥的过滤器,它允许在 Linux 内核中操作以太网桥的数据包过滤规则。它可以用于控制网络流量、设置网络策略等。socat: socat 是一个功能强大的网络工具,用于建立各种类型的连接,如 TCP、UDP、UNIX 套接字等。它可以用于端口转发、代理、网络调试等任务。ipset: ipset 是一个用于管理 IP 地址集合的工具。它允许你创建和操作 IP 地址的集合,提供高效的 IP 地址匹配和过滤功能。ipset 可以用于防火墙配置、访问控制列表等。conntrack: conntrack 是一个连接跟踪工具,用于在 Linux 内核中跟踪网络连接的状态。它可以用于查看和操作活动连接、连接跟踪表等。conntrack 在网络安全和网络分析中很有用。

2.安装时间同步服务

yum install chrony -y # 安装时间同步服务 systemctl enable chronyd.service # 启用时间同步服务 systemctl start chronyd.service # 开启时间同步服务

说明:结果

查看chrony状态

systemctl status chronyd.service

在这里插入图片描述

查看 chronyc 源

chronyc sources

在这里插入图片描述

所有节点都出现此服务表示成功

查看各个结点时间的状态

timedatectl status

在这里插入图片描述

说明:

​ chrony 是一个用于计算机时间同步的工具,它提供了精确的时钟同步和时间调整功能。在安装k8s时安装时间同步服务,切换时区为亚洲、上海,而不是UTC。

步骤三:安装kk工具

说明:

​ 一下操作仅在Master结点执行

1.修改默认kk地区

export KKZONE=cn

说明:

​ 若访问Github受限,则可加入静态变量,否则跳过

2.下载KubKey工具

curl -sfL https://get-kk.kubesphere.io | VERSION=v3.0.7 sh -

说明:

查看安装结果

ls

在这里插入图片描述

3.为kk工具添加权限

chmod +x kk 步骤四:创建集群

1.创建配置文件

./kk create config --with-kubernetes v1.22.12 --with-kubesphere v3.3.2

说明:

查看结果

在这里插入图片描述

补充:参数解释

config:创建配置文件--with-kubernetes :安装k8s,并使用最新版。指定版本时,可指定安装k8s版本--with-kubesphere:安装kubesphere,并使用最新版。指定版本时,可安装指定版本的kubesphere

注意:

一般来说,对于 All-in-One 安装,您无需更改任何配置。KubeKey 会默认安装 OpenEBS 为开发和测试环境提供 LocalPV 以方便新用户。对于其他存储类型,请参见持久化存储配置。安装 KubeSphere 3.3 的建议 Kubernetes 版本:v1.20.x、v1.21.x、* v1.22.x、* v1.23.x 和 * v1.24.x。带星号的版本可能出现边缘节点部分功能不可用的情况。因此,如需使用边缘节点,推荐安装 v1.21.x。如果不指定 Kubernetes 版本,KubeKey 将默认安装 Kubernetes v1.23.10。有关受支持的 Kubernetes 版本的更多信息,请参见支持矩阵。

2.编辑配置文件

apiVersion: kubekey.kubesphere.io/v1alpha2 kind: Cluster metadata: name: sample spec: # 指定主机列表,每个主机有名称、地址、内部地址、用户名和密码等属性。 hosts: - {name: master, address: 10.13.167.28, internalAddress: 10.13.167.28, user: root, password: "123456"} # 每个主机列表中的账户密码需要与本机真实用户密码对应 - {name: node1, address: 10.13.167.102, internalAddress: 10.13.167.102, user: root, password: "123456"} roleGroups: # 指定角色组 etcd: # 责存储集群的配置数据、状态信息和元数据。 - master # etcd 节点名称 control-plane: # 主节点名称 - master worker: # 工作节点名称 - node1 controlPlaneEndpoint: # 指定控制平面的终结点信息,包括域名、地址和端口号。 ## Internal loadbalancer for apiservers # internalLoadbalancer: haproxy domain: lb.kubesphere.local address: "" port: 6443 kubernetes: # :指定Kubernetes的版本和集群名称等参数 version: v1.22.12 clusterName: cluster.local autoRenewCerts: true containerManager: docker etcd: type: kubekey network: # 指定网络配置,包括网络插件和Pods和服务的CIDR等参数 plugin: calico kubePodsCIDR: 10.233.64.0/18 # 注意,网络地址不要与真实的Ip地址冲突 kubeServiceCIDR: 10.233.0.0/18 ## multus support. https://github.com/k8snetworkplumbingwg/multus-cni multusCNI: enabled: false registry: privateRegistry: "" namespaceOverride: "" registryMirrors: [] insecureRegistries: [] addons: [] --- apiVersion: installer.kubesphere.io/v1alpha1 kind: ClusterConfiguration metadata: name: ks-installer namespace: kubesphere-system labels: version: v3.3.2 spec: persistence: storageClass: "" authentication: jwtSecret: "" zone: "" local_registry: "" namespace_override: "" # dev_tag: "" etcd: # 指定Etcd的监控配置和端点信息 monitoring: false endpointIps: localhost port: 2379 tlsEnable: true common: # 指定通用配置,包括核心组件、Redis、OpenLDAP等参数 core: console: enableMultiLogin: true port: 30880 type: NodePort # apiserver: # resources: {} # controllerManager: # resources: {} redis: enabled: false volumeSize: 2Gi openldap: enabled: false volumeSize: 2Gi minio: volumeSize: 20Gi monitoring: # 指定监控配置,包括Prometheus的终结点信息和GPU监控等参数 # type: external endpoint: http://prometheus-operated.kubesphere-monitoring-system.svc:9090 GPUMonitoring: enabled: false gpu: kinds: - resourceName: "nvidia.com/gpu" resourceType: "GPU" default: true es: # master: # volumeSize: 4Gi # replicas: 1 # resources: {} # data: # volumeSize: 20Gi # replicas: 1 # resources: {} logMaxAge: 7 elkPrefix: logstash basicAuth: enabled: false username: "" password: "" externalElasticsearchHost: "" externalElasticsearchPort: "" alerting: enabled: false # thanosruler: # replicas: 1 # resources: {} auditing: enabled: false # operator: # resources: {} # webhook: # resources: {} devops: enabled: false # resources: {} jenkinsMemoryLim: 8Gi jenkinsMemoryReq: 4Gi jenkinsVolumeSize: 8Gi events: enabled: false # operator: # resources: {} # exporter: # resources: {} # ruler: # enabled: true # replicas: 2 # resources: {} logging: # 指定日志配置,包括日志边车的副本数等参数 enabled: false logsidecar: enabled: true replicas: 2 # resources: {} metrics_server: enabled: false monitoring: storageClass: "" node_exporter: port: 9100 # resources: {} # kube_rbac_proxy: # resources: {} # kube_state_metrics: # resources: {} # prometheus: # replicas: 1 # volumeSize: 20Gi # resources: {} # operator: # resources: {} # alertmanager: # replicas: 1 # resources: {} # notification_manager: # resources: {} # operator: # resources: {} # proxy: # resources: {} gpu: nvidia_dcgm_exporter: enabled: false # resources: {} multicluster: clusterRole: none network: networkpolicy: enabled: false ippool: type: none topology: type: none openpitrix: store: enabled: false servicemesh: enabled: false istio: components: ingressGateways: - name: istio-ingressgateway enabled: false cni: enabled: false edgeruntime: enabled: false kubeedge: enabled: false cloudCore: cloudHub: advertiseAddress: - "" service: cloudhubNodePort: "30000" cloudhubQuicNodePort: "30001" cloudhubHttpsNodePort: "30002" cloudstreamNodePort: "30003" tunnelNodePort: "30004" # resources: {} # hostNetWork: false iptables-manager: enabled: true mode: "external" # resources: {} # edgeService: # resources: {} terminal: timeout: 600

说明:结果

​ 若要自定义 Kubernetes 相关参数,请参考 Kubernetes 集群配置。

3.开始安装

./kk create cluster -f config-sample.yaml

说明:

使用kk工具安装k8s集群

步骤五:查看安装结果

1.查看节点安装日志

kubectl logs -n kubesphere-system $(kubectl get pod -n kubesphere-system -l 'app in (ks-install, ks-installer)' -o jsonpath='{.items[0].metadata.name}') -f

说明:

Your Kubernetes control-plane has initialized successfully! To start using your cluster, you need to run the following as a regular user: mkdir -p $HOME/.kube sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config sudo chown $(id -u):$(id -g) $HOME/.kube/config Alternatively, if you are the root user, you can run: export KUBECONFIG=/etc/kubernetes/admin.conf You should now deploy a pod network to the cluster. Run "kubectl apply -f [podnetwork].yaml" with one of the options listed at: https://kubernetes.io/docs/concepts/cluster-administration/addons/ You can now join any number of control-plane nodes by copying certificate authorities and service account keys on each node and then running the following as root: kubeadm join lb.kubesphere.local:6443 --token 6yfn1e.9dh0m2p3erl9wj72 \ --discovery-token-ca-cert-hash sha256:0f0ab4fec32eccb17d21ff0dc71e894a7d73475526cea630ee68b460058820fc \ --control-plane

2.检查 KubeSphere 相关组件的运行状况

kubectl get pod --all-namespaces

3.访问Kubesphere

查看结果 在这里插入图片描述 参考资料

k8s官网:Kubernetes 文档 | Kubernetes

KubeSphere官网:产品介绍 (kubesphere.io)



【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3