使用kubeKey安装kubeSphere

6 篇文章 0 订阅
3 篇文章 0 订阅

使用kubeKey安装kubeSphere

使用kubeKey安装kubeSphere。如果你和作者一样在部署时下载遇到了约束可用参考该文章,该文档主要使用代理方案将包给提前下载了有些脚本更改了代理路径,希望对您有所帮助!

下载安装工具kubeKey

下载脚本

wget https://get-kk.kubesphere.io

编辑脚本替换成代理URL

#!/bin/sh

# Copyright 2020 The KubeSphere Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

ISLINUX=true
OSTYPE="linux"

if [ "x$(uname)" != "xLinux" ]; then
  echo ""
  echo 'Warning: Non-Linux operating systems are not supported! After downloading, please copy the tar.gz file to linux.'  
  ISLINUX=false
fi

# Fetch latest version
if [ "x${VERSION}" = "x" ]; then
  VERSION="$(curl -sL https://ghproxy.com/https://api.github.com/repos/kubesphere/kubekey/releases |
    grep -o 'download/v[0-9]*.[0-9]*.[0-9]*/' |
    sort --version-sort |
    tail -1 | awk -F'/' '{ print $2}')"
  VERSION="${VERSION##*/}"
fi

if [ -z "${ARCH}" ]; then
  case "$(uname -m)" in
  x86_64)
    ARCH=amd64
    ;;
  armv8*)
    ARCH=arm64
    ;;
  aarch64*)
    ARCH=arm64
    ;;
  *)
    echo "${ARCH}, isn't supported"
    exit 1
    ;;
  esac
fi

if [ "x${VERSION}" = "x" ]; then
  echo "Unable to get latest Kubekey version. Set VERSION env var and re-run. For example: export VERSION=v1.0.0"
  echo ""
  exit
fi

DOWNLOAD_URL="https://ghproxy.com/https://github.com/kubesphere/kubekey/releases/download/${VERSION}/kubekey-${VERSION}-${OSTYPE}-${ARCH}.tar.gz"
if [ "x${KKZONE}" = "xcn" ]; then
  DOWNLOAD_URL="https://ghproxy.com/https://kubernetes.pek3b.qingstor.com/kubekey/releases/download/${VERSION}/kubekey-${VERSION}-${OSTYPE}-${ARCH}.tar.gz"
fi

echo ""
echo "Downloading kubekey ${VERSION} from ${DOWNLOAD_URL} ..."
echo ""

curl -fsLO "$DOWNLOAD_URL"
if [ $? -ne 0 ]; then
  echo ""
  echo "Failed to download Kubekey ${VERSION} !"
  echo ""
  echo "Please verify the version you are trying to download."
  echo ""
  exit
fi

if [ ${ISLINUX} = true ]; then
  filename="kubekey-${VERSION}-${OSTYPE}-${ARCH}.tar.gz"
  ret='0'
  command -v tar >/dev/null 2>&1 || { ret='1'; }
  if [ "$ret" -eq 0 ]; then
    tar -xzf "${filename}"
  else
    echo "Kubekey ${VERSION} Download Complete!"
    echo ""
    echo "Try to unpack the ${filename} failed."
    echo "tar: command not found, please unpack the ${filename} manually."
    exit
  fi
fi

echo ""
echo "Kubekey ${VERSION} Download Complete!"
echo ""

执行脚本

export VERSION=v1.1.1 & sh downloadKubekey.sh

使用kk安装k8s集群

./kk create config --with-kubernetes v1.20.4 --with-kubesphere v3.1.1
  • 手动下载
curl -L -o /opt/share/k8s/kubekey/kubekey/v1.20.4/amd64/cni-plugins-linux-amd64-v0.8.6.tgz https://ghproxy.com/https://github.com/containernetworking/plugins/releases/download/v0.8.6/cni-plugins-linux-amd64-v0.8.6.tgz
  • 手动下载nfs 配置类文件
 curl -L -o addons.md https://ghproxy.com/https://raw.githubusercontent.com/kubesphere/kubekey/master/docs/addons.md
  • 配置一下addons
kind: Cluster
metadata:
  name: sample
spec:
  hosts:
  - {name: k8smaster, address: 192.168.122.110, internalAddress: 192.168.122.110, user: root, password:yourServerPassword}
  - {name: k8snode1, address: 192.168.122.111, internalAddress: 192.168.122.111, user: root, password: yourServerPassword}
  - {name: k8snode2, address: 192.168.122.112, internalAddress: 192.168.122.112, user: root, password: yourServerPassword}
  roleGroups:
    etcd:
    - k8smaster
    master:
    - k8smaster
    worker:
    - k8snode1
    - k8snode2
  controlPlaneEndpoint:
    domain: lb.kubesphere.local
    address: ""
    port: 6443
  kubernetes:
    version: v1.20.4
    imageRepo: kubesphere
    clusterName: cluster.local
  network:
    plugin: calico
    kubePodsCIDR: 10.233.64.0/18
    kubeServiceCIDR: 10.233.0.0/18
  registry:
    registryMirrors: []
    insecureRegistries: []
  addons:
  - name: nfs-client
    namespace: kube-system
    sources:
      chart:
        name: nfs-client-provisioner
        repo: https://charts.kubesphere.io/main
        valuesFile: custom-nfs-client-values.yaml  # or https://raw.githubusercontent.com/kubesphere/helm-charts/master/src/main/nfs-client-provisioner/values.yaml
        # values also supports parameter lists
        values:
        - storageClass.defaultClass=true
        - nfs.server=192.168.122.1
        - nfs.path=/home/nfs/k8s

---
apiVersion: installer.kubesphere.io/v1alpha1
kind: ClusterConfiguration
metadata:
  name: ks-installer
  namespace: kubesphere-system
  labels:
    version: v3.1.1
spec:
  persistence:
    storageClass: ""
  authentication:
    jwtSecret: ""
  zone: ""
  local_registry: ""
  etcd:
    monitoring: true
    endpointIps: localhost
    port: 2379
    tlsEnable: true
  common:
    redis:
      enabled: true
    redisVolumSize: 2Gi
    openldap:
      enabled: true
    openldapVolumeSize: 2Gi
    minioVolumeSize: 20Gi
    monitoring:
      endpoint: http://prometheus-operated.kubesphere-monitoring-system.svc:9090
    es:
      elasticsearchMasterVolumeSize: 4Gi
      elasticsearchDataVolumeSize: 20Gi
      logMaxAge: 7
      elkPrefix: logstash
      basicAuth:
        enabled: false
        username: ""
        password: ""
      externalElasticsearchUrl: ""
      externalElasticsearchPort: ""
  console:
    enableMultiLogin: true
    port: 30880
  alerting:
    enabled: true
    # thanosruler:
    #   replicas: 1
    #   resources: {}
  auditing:
    enabled: true
  devops:
    enabled: true
    jenkinsMemoryLim: 2Gi
    jenkinsMemoryReq: 1500Mi
    jenkinsVolumeSize: 8Gi
    jenkinsJavaOpts_Xms: 512m
    jenkinsJavaOpts_Xmx: 512m
    jenkinsJavaOpts_MaxRAM: 2g
  events:
    enabled: true
    ruler:
      enabled: true
      replicas: 2
  logging:
    enabled: true
    logsidecar:
      enabled: true
      replicas: 2
  metrics_server:
    enabled: true
  monitoring:
    storageClass: ""
    prometheusMemoryRequest: 400Mi
    prometheusVolumeSize: 20Gi
  multicluster:
    clusterRole: host
  network:
    networkpolicy:
      enabled: true
    ippool:
      type: none
    topology:
      type: none
  openpitrix:
    store:
      enabled: true
  servicemesh:
    enabled: true
  kubeedge:
    enabled: true
    cloudCore:
      nodeSelector: {"node-role.kubernetes.io/worker": ""}
      tolerations: []
      cloudhubPort: "10000"
      cloudhubQuicPort: "10001"
      cloudhubHttpsPort: "10002"
      cloudstreamPort: "10003"
      tunnelPort: "10004"
      cloudHub:
        advertiseAddress:
          - ""
        nodeLimit: "100"
      service:
        cloudhubNodePort: "30000"
        cloudhubQuicNodePort: "30001"
        cloudhubHttpsNodePort: "30002"
        cloudstreamNodePort: "30003"
        tunnelNodePort: "30004"
    edgeWatcher:
      nodeSelector: {"node-role.kubernetes.io/worker": ""}
      tolerations: []
      edgeWatcherAgent:
        nodeSelector: {"node-role.kubernetes.io/worker": ""}
        tolerations: []

  • 部署k8s集群
./kk create cluster -f config-sample.yaml
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
KubeKey是一个基于Ansible的Kubernetes集群自动化安装工具,支持快速、简单地创建生产级别的Kubernetes集群。以下是使用KubeKey安装Kubernetes集群的具体步骤: 1. 安装Ansible 在执行KubeKey之前,需要安装Ansible。可以使用以下命令安装: ``` sudo yum install epel-release -y sudo yum install ansible -y ``` 2. 下载KubeKeyKubeSphere官网下载最新版本的KubeKey,下载地址为:https://github.com/kubesphere/kubekey/releases 下载完成后,将文件解压到一个合适的位置,例如:/opt/kubekey。 3. 配置hosts文件 在安装Kubernetes之前,需要在所有节点上配置hosts文件。可以使用以下命令编辑hosts文件: ``` sudo vi /etc/hosts ``` 在hosts文件中添加所有节点的IP地址和主机名,例如: ``` 192.168.1.100 node1 192.168.1.101 node2 192.168.1.102 node3 ``` 4. 配置Kubernetes集群 在KubeKey目录下,有一个config-sample.yaml文件,可以使用该文件作为模板创建一个新的配置文件。 可以使用以下命令创建一个新的配置文件: ``` cd /opt/kubekey cp config-sample.yaml config.yaml ``` 然后使用编辑器打开config.yaml文件,按照需要修改配置,例如修改集群名称、Master节点和Worker节点的IP地址等信息。 5. 安装Kubernetes集群 使用以下命令开始安装Kubernetes集群: ``` cd /opt/kubekey ansible-playbook -i inventory/mycluster/hosts.yaml cluster.yml -b ``` 该命令会使用Ansible在所有节点上安装Kubernetes组件,包括kube-apiserver、kube-controller-manager、kube-scheduler、kubelet、kube-proxy等组件。在安装过程中,可能需要输入sudo密码。 安装完成后,可以使用以下命令验证Kubernetes集群是否正常: ``` kubectl get nodes ``` 该命令应该会输出所有节点的信息,表示Kubernetes集群已经安装成功。 以上就是使用KubeKey安装Kubernetes集群的具体步骤。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值