[Kubernetes] Install Kubernetes using Kubekey(v3.0.7) on VirtualBox

script 다운로드 #

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

Binary Downloads #

Build Binary from Source Code #

1git clone https://github.com/kubesphere/kubekey.git
2cd kubekey
3make kk

Quick Install Cluster #

1./kk create cluster [--with-kubernetes versio] [--with-kubesphere version]
  • Create a Kubernetes cluster with a specified version.

    1./kk create cluster --with-kubernetes v1.24.1 --container-manager containerd
  • Create a Kubernetes cluster with KubeSphere installed.

    1./kk create cluster --with-kubesphere v3.2.1

Custom Install Cluster #

세부 설정을 위한 Create Config #

1./kk create config [--with-kubernetes version] [--with-kubesphere version] [(-f | --filename) path]

다른 파일 이름이나 다른 폴더에 있는 파일을 지정할 수도 있다.

1./kk create config [--with-kubernetes version] [(-f | --file) path]
  • Examples
    1./kk create config --with-kubernetes v1.20.4

{: .prompt-info }

  • 파일 작성

    1vi config-sample.yaml
     1apiVersion: kubekey.kubesphere.io/v1alpha1
     2kind: Cluster
     3metadata:
     4  name: sample
     5spec:
     6  hosts:
     7  - {name: master, address: 192.168.0.1, internalAddress: 192.168.0.1, privateKeyPath: "~/.ssh/id_rsa"}
     8
     9  - {name: master, address: 192.168.0.1, internalAddress: 192.168.0.1, user: root, password: Testing123}
    10  - {name: worker1, address: 192.168.0.2, internalAddress: 192.168.0.2, user: root, password: Testing123}
    11  - {name: worker2, address: 192.168.0.3, internalAddress: 192.168.0.3, user: root, password: Testing123}
    12  roleGroups:
    13    etcd:
    14    - master
    15    master:
    16    - master
    17    worker:
    18    - worker1
    19    - worker2
    20  controlPlaneEndpoint:
    21    domain: lb.kubesphere.local
    22    address: ""
    23    port: "6443"
    24  kubernetes:
    25    version: v1.17.9
    26    imageRepo: kubesphere
    27    clusterName: cluster.local
    28  network:
    29    plugin: calico
    30    kubePodsCIDR: 10.233.64.0/18
    31    kubeServiceCIDR: 10.233.0.0/18
    32  registry:
    33    registryMirrors: []
    34    insecureRegistries: []
    35  addons: []

Install Cluster #

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

Cluster 설치하면서 log 확인 #

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

Kubernetes 일반 유저 일 때 #

1mkdir -p $HOME/.kube
2sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
3sudo chown $(id -u):$(id -g) $HOME/.kube/config

만약 일반 계정에서 아래와 sudo 명령어 없이 kubectl 명령어 사용시 아래와 같은 오류가 발생하면

  • [ERROR] error loading config file /etc/kubernetes/admin.conf: open /etc/kubernetes/admin.conf: permission denied
    • 아래 명령어를 입력하면 sudo 없이 사용 가능하다.
      1export KUBECONFIG=$HOME/.kube/config

{: .prompt-danger }

[ERROR] error making pod data directories: mkdir /var/lib/kubelet/pods/86cfe394-ba32-4a9f-ad65-1fb21f98a4ba: read-only file system

1chown -R kubelet:kubelet /var/lib/kubelet/pods
2chmod 750 /var/lib/kubelet/pods
3systemctl restart kubelet

{: .prompt-danger }

Advertisement