VMware Tanzu Community Edition 是一个功能齐全,易于管理的Kubernetes平台,供学习者和用户使用。它是一个免费的、社区支持的、开源的VMware Tanzu 发行版,可以在几分钟内在您的本地工作站上或您喜欢的云上安装和配置。

VMware Tanzu Community Edition 部署非托管集群_k8s

1. 安装Docker

1.1 修改安装源

文件 /etc/apt/sources.list 改为以下内容

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 下载安装包

​https://github.com/vmware-tanzu/community-edition/releases​

3.2 解压缩安装包

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

3.4 修改 ​​install.sh​​,注释下面内容

安装脚本建议不要以root运行docker,此处注释跳过了该项检查,请根据实际需要操作

#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