天天看點

VMware Tanzu Community Edition 部署非托管叢集

VMware Tanzu Community Edition 是一個功能齊全,易于管理的Kubernetes平台,供學習者和使用者使用。它是一個免費的、社群支援的、開源的VMware Tanzu 發行版,可以在幾分鐘内在您的本地工作站上或您喜歡的雲上安裝和配置。

VMware Tanzu Community Edition 部署非托管叢集

1. 安裝Docker

1.1 修改安裝源

deb http://mirrors.aliyun.com/debian/ bullseye main non-free contrib
deb-src http://mirrors.aliyun.com/debian/ bullseye main non-free contrib
deb http://mirrors.aliyun.com/debian-security/ bullseye-security main
deb-src http://mirrors.aliyun.com/debian-security/ bullseye-security main
deb http://mirrors.aliyun.com/debian/ bullseye-updates main non-free contrib
deb-src http://mirrors.aliyun.com/debian/ bullseye-updates main non-free contrib
deb http://mirrors.aliyun.com/debian/ bullseye-backports main non-free contrib
deb-src http://mirrors.aliyun.com/debian/ bullseye-backports main non-free contrib      

1.2 更新系統

# apt update -y && apt upgrade -y      

1.3 安裝軟體包

# apt-get install -y ca-certificates curl gpg     lsb-release sudo      

1.4 解除安裝舊的docker

# apt-get remove docker docker-engine docker.io containerd runc      

1.5 安裝GPG秘鑰

# curl -fsSL https://mirrors.aliyun.com/docker-ce/linux/debian/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg`      

1.6 添加docker安裝源

# echo \
  "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/debian \
  $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null      

1.7 更新安裝源

# apt-get update      

1.8 安裝docker

# apt-get install -y docker-ce docker-ce-cli containerd.io docker-compose-plugin      

1.9 添加阿裡雲加速器

# mkdir -p /etc/docker
tee /etc/docker/daemon.json <<-'EOF'
{ 
"registry-mirrors": [
"https://lsf7d76k.mirror.aliyuncs.com"
]
}
EOF      

1.10 重新開機docker服務

# systemctl daemon-reload
# systemctl restart docker      

2. 安裝Kubectl

# curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
# sudo install -o root -g root -m 0755 kubectl /usr/local/bin/kubectl      

3. 安裝Tanzu CLI

3.1 下載下傳安裝包

3.2 解壓縮安裝包

# tar xvf tce-linux-amd64-v0.12.0.tar.gz
# cd tce-linux-amd64-v0.12.0/      

3.4 修改 ​

​install.sh​

​,注釋下面内容

#ALLOW_INSTALL_AS_ROOT="${ALLOW_INSTALL_AS_ROOT:-""}"
#if [[ "$EUID" -eq 0 && "${ALLOW_INSTALL_AS_ROOT}" != "true" ]]; then
#  error_exit "Do not run this script as root"
#fi      

3.5 安裝Tanzu CLI

# ./install.sh
+ set +x
====================================
 Installing Tanzu Community Edition
====================================

Installing tanzu cli to /usr/local/bin/tanzu

Checking for required plugins...
Installing plugin 'apps:v0.6.0'
Installing plugin 'builder:v0.11.4'
Installing plugin 'cluster:v0.11.4'
Installing plugin 'codegen:v0.11.4'
Installing plugin 'conformance:v0.12.0'
Installing plugin 'diagnostics:v0.12.0'
Installing plugin 'kubernetes-release:v0.11.4'
Installing plugin 'login:v0.11.4'
Installing plugin 'management-cluster:v0.11.4'
Installing plugin 'package:v0.11.4'
Installing plugin 'pinniped-auth:v0.11.4'
Installing plugin 'secret:v0.11.4'
Installing plugin 'unmanaged-cluster:v0.12.0'
Successfully installed all required plugins
✔  successfully initialized CLI

Installation complete!      

4. 部署非托管叢集

4.1 部署名為 ​

​ww​

​ 的托管叢集

# tanzu unmanaged-cluster create ww      
📁 Created cluster directory

🧲 Resolving and checking Tanzu Kubernetes release (TKr) compatibility file
   projects.registry.vmware.com/tce/compatibility
   Downloaded to: /root/.config/tanzu/tkg/unmanaged/compatibility/projects.registry.vmware.com_tce_compatibility_v8

🔧 Resolving TKr
   projects.registry.vmware.com/tce/tkr:v1.22.7-2
   Downloaded to: /root/.config/tanzu/tkg/unmanaged/bom/projects.registry.vmware.com_tce_tkr_v1.22.7-2
   Rendered Config: /root/.config/tanzu/tkg/unmanaged/ww/config.yaml
   Bootstrap Logs: /root/.config/tanzu/tkg/unmanaged/ww/bootstrap.log

🔧 Processing Tanzu Kubernetes Release

🎨 Selected base image
   projects.registry.vmware.com/tce/kind:v1.22.7

📦 Selected core package repository
   projects.registry.vmware.com/tce/repo-12:0.12.0

📦 Selected additional package repositories
   projects.registry.vmware.com/tce/main:0.12.0

📦 Selected kapp-controller image bundle
   projects.registry.vmware.com/tce/kapp-controller-multi-pkg:v0.30.1

🚀 Creating cluster ww
   Cluster creation using kind!
   ❤️  Checkout this awesome project at https://kind.sigs.k8s.io
   Base image downloaded
   Cluster created
   To troubleshoot, use:

   kubectl ${COMMAND} --kubeconfig /root/.config/tanzu/tkg/unmanaged/ww/kube.conf

📧 Installing kapp-controller
   kapp-controller status: Running

📧 Installing package repositories
   tkg-core-repository package repo status: Reconcile succeeded

🌐 Installing CNI
   calico.community.tanzu.vmware.com:3.22.1

✅ Cluster created

🎮 kubectl context set to ww

View available packages:
   tanzu package available list
View running pods:
   kubectl get po -A
Delete this cluster:
   tanzu unmanaged delete ww      

4.2 常用指令

# kubectl config view --minify
apiVersion: v1
clusters:
- cluster:
    certificate-authority-data: DATA+OMITTED
    server: https://127.0.0.1:34063
  name: kind-ww
contexts:
- context:
    cluster: kind-ww
    user: kind-ww
  name: kind-ww
current-context: kind-ww
kind: Config
preferences: {}
users:
- name: kind-ww
  user:
    client-certificate-data: REDACTED
    client-key-data: REDACTED      
# tanzu package repository list --all-namespaces


  NAME                                          REPOSITORY                                TAG     STATUS               DETAILS  NAMESPACE
  projects.registry.vmware.com-tce-main-0.12.0  projects.registry.vmware.com/tce/main     0.12.0  Reconcile succeeded           tanzu-package-repo-global
  tkg-core-repository                           projects.registry.vmware.com/tce/repo-12  0.12.0  Reconcile succeeded           tkg-system      
# tanzu package available list


  NAME                                                    DISPLAY-NAME                 SHORT-DESCRIPTION                                                                                                                                          LATEST-VERSION
  app-toolkit.community.tanzu.vmware.com                  App-Toolkit package for TCE  Kubernetes-native toolkit to support application lifecycle                                                                                                 0.2.0
  cartographer-catalog.community.tanzu.vmware.com         Cartographer Catalog         Reusable Cartographer blueprints                                                                                                                           0.3.0
  cartographer.community.tanzu.vmware.com                 Cartographer                 Kubernetes native Supply Chain Choreographer.                                                                                                              0.3.0
  cert-injection-webhook.community.tanzu.vmware.com       cert-injection-webhook       The Cert Injection Webhook injects CA certificates and proxy environment variables into pods                                                               0.1.1
  cert-manager.community.tanzu.vmware.com                 cert-manager                 Certificate management                                                                                                                                     1.8.0
  contour.community.tanzu.vmware.com                      contour                      An ingress controller                                                                                                                                      1.20.1
  external-dns.community.tanzu.vmware.com                 external-dns                 This package provides DNS synchronization functionality.                                                                                                   0.10.0
  fluent-bit.community.tanzu.vmware.com                   fluent-bit                   Fluent Bit is a fast Log Processor and Forwarder                                                                                                           1.7.5
  fluxcd-source-controller.community.tanzu.vmware.com     Flux Source Controller       The source-controller is a Kubernetes operator, specialised in artifacts acquisition from external sources such as Git, Helm repositories and S3 buckets.  0.21.5
  gatekeeper.community.tanzu.vmware.com                   gatekeeper                   policy management                                                                                                                                          3.7.1
  grafana.community.tanzu.vmware.com                      grafana                      Visualization and analytics software                                                                                                                       7.5.11
  harbor.community.tanzu.vmware.com                       harbor                       OCI Registry                                                                                                                                               2.4.2
  helm-controller.fluxcd.community.tanzu.vmware.com       Flux Helm Controller         The Helm Controller is a Kubernetes operator, allowing one to declaratively manage Helm chart releases with Kubernetes manifests.                          0.17.2
  knative-serving.community.tanzu.vmware.com              knative-serving              Knative Serving builds on Kubernetes to support deploying and serving of applications and functions as serverless containers                               1.0.0
  kpack-dependencies.community.tanzu.vmware.com           kpack dependencies           Dependencies in the form of Buildpacks and Stacks for the kpack package                                                                                    0.0.27
  kpack.community.tanzu.vmware.com                        kpack                        kpack builds application source code into OCI compliant images using Cloud Native Buildpacks                                                               0.5.3
  kustomize-controller.fluxcd.community.tanzu.vmware.com  Flux Kustomize Controller    Kustomize controller is one of the components in GitOps toolkit.                                                                                           0.21.1
  local-path-storage.community.tanzu.vmware.com           local-path-storage           This package provides local path node storage and primarily supports RWO AccessMode.                                                                       0.0.22
  multus-cni.community.tanzu.vmware.com                   multus-cni                   This package provides the ability for enabling attaching multiple network interfaces to pods in Kubernetes                                                 3.8.0
  prometheus.community.tanzu.vmware.com                   prometheus                   A time series database for your metrics                                                                                                                    2.27.0-1
  velero.community.tanzu.vmware.com                       velero                       Disaster recovery capabilities                                                                                                                             1.8.0
  whereabouts.community.tanzu.vmware.com                  whereabouts                  A CNI IPAM plugin that assigns IP addresses cluster-wide                                                                                                   0.5.1      
# tanzu package available list cert-manager.community.tanzu.vmware.com


  NAME                                     VERSION  RELEASED-AT
  cert-manager.community.tanzu.vmware.com  1.5.4    2021-08-24 01:22:51 +0800 CST
  cert-manager.community.tanzu.vmware.com  1.5.5    2021-08-24 01:22:51 +0800 CST
  cert-manager.community.tanzu.vmware.com  1.6.1    2021-10-29 20:00:00 +0800 CST
  cert-manager.community.tanzu.vmware.com  1.6.3    2021-10-29 20:00:00 +0800 CST
  cert-manager.community.tanzu.vmware.com  1.7.2    2021-10-29 20:00:00 +0800 CST
  cert-manager.community.tanzu.vmware.com  1.8.0    2021-10-29 20:00:00 +0800 CST      
# tanzu package install cert-manager --package-name cert-manager.community.tanzu.vmware.com --version 1.8.0

 Installing package 'cert-manager.community.tanzu.vmware.com'

 Getting package metadata for 'cert-manager.community.tanzu.vmware.com'

 Creating service account 'cert-manager-default-sa'

 Creating cluster admin role 'cert-manager-default-cluster-role'

 Creating cluster role binding 'cert-manager-default-cluster-rolebinding'

 Creating package resource

 Waiting for 'PackageInstall' reconciliation for 'cert-manager'

 'PackageInstall' resource install status: Reconciling

 'PackageInstall' resource install status: ReconcileSucceeded


 Added installed package 'cert-manager'      
# tanzu package installed list


  NAME          PACKAGE-NAME                             PACKAGE-VERSION  STATUS
  cert-manager  cert-manager.community.tanzu.vmware.com  1.8.0            Reconcile succeeded      
# tanzu unmanaged-cluster list
NAME  PROVIDER  STATUS
ww    kind      Running      

繼續閱讀