kubernetes 멀티 테넌시를 구현하며 vcluster 에 대해 공부한 내용에 대해 정리합니다.
1. vCluster 개요
- vcluster 는 가상 Kubernetes 클러스터를 생성할 때 사용할 수 있다.
- 각 vcluster 는 k8s 클러스터의 namespace 내에서 실행되며, 별도의 완전한 클러스터를 생성하는것보다 비용이 저렴하다.
- 일반 namespace 보다 더 나은 multi-tenancy 와 격리성을 제공한다.
- 가상 클러스터를 통해 사용자는 CRD(CustomResourceDefinitions), 네임스페이스, Cluster Roles 등을 사용할 수 있음
- vcluster 를 통해 단일 클러스터 내에서 동시에 여러 버전의 오퍼레이터를 설치할 수 있다.
2. Why use Virtual Kubernetes Clusters?
3. vCluster Quick start
Download vcluster CLI
참고 | https://github.com/loft-sh/vcluster
# Mac(Intel/ADM)
curl -L -o vcluster "https://github.com/loft-sh/vcluster/releases/latest/download/vcluster-darwin-amd64" && sudo install -c -m 0755 vcluster /usr/local/bin
# Mac (Silicon/ARM)
curl -L -o vcluster "https://github.com/loft-sh/vcluster/releases/latest/download/vcluster-darwin-arm64" && sudo install -c -m 0755 vcluster /usr/local/bin
# Linux(AMD)
curl -L -o vcluster "https://github.com/loft-sh/vcluster/releases/latest/download/vcluster-linux-amd64" && sudo install -c -m 0755 vcluster /usr/local/bin
# Linux (ARM)
curl -L -o vcluster "https://github.com/loft-sh/vcluster/releases/latest/download/vcluster-linux-arm64" && sudo install -c -m 0755 vcluster /usr/local/bin
Create a vcluster
- vCluster 는 vcluster cli , helm , kubectl 로 생성할 수 있다.
- vcluster name 규칙
- vcluster prefix + 사용자가 입력한 vcluster name 으로 vcluster 가 생성된다.
- vcluster-{사용자가 입력한 vcluster name}
vcluster 배포 (vcluster cli)
# vcluster-my-vcluster namespace 에 vcluster 생성
vcluster create my-vcluster
# OR: Use --expose 외부에서 액세스할 수 있는 LoadBalancer 가 있는 원격 클러스터에 vcluster 배포
vcluster create my-vcluster --expose
# OR: Use -f 추가 helm values.yaml을 사용하여 vcluster를 배포
vcluster create my-vcluster -f values.yaml
# OR: Use --distro 가상 클러스터로 k0s 또는 Vanilla k8s 지정
vcluster create my-vcluster --distro k8s
# OR: Use --isolate vcluster 워크로드를 위한 격리된 환경 생성
vcluster create my-vcluster --isolate
vcluster 를 배포할때 클러스터 관리자 권한은 필요하지 않다.
하나의 특정 namespace 에만 애플리케이션을 배포할 수 있는 권한만 있다면 가상 클러스터를 생성 할 수 있다.
vcluster 배포 (helm)
vcluster.yaml (helm file)
# vi vcluster.yaml
vcluster:
image: rancher/k3s:v1.23.5-k3s1 # Choose k3s version
helm command
$ helm upgrade --install my-vcluster vcluster \
--values vcluster.yaml \
--repo https://charts.loft.sh \
--namespace vcluster-my-vcluster \
--repository-config=''
# -----------------------
Release "my-vcluster" does not exist. Installing it now.
NAME: my-vcluster
LAST DEPLOYED: Sun Jul 9 22:11:04 2023
NAMESPACE: vcluster-my-vcluster
STATUS: deployed
REVISION: 1
TEST SUITE: None
NOTES:
Thank you for installing vcluster.
Your vcluster is named my-vcluster in namespace vcluster-my-vcluster.
To connect to the vcluster, use vcluster CLI (https://www.vcluster.com/docs/getting-started/setup):
$ vcluster connect my-vcluster -n vcluster-my-vcluster
$ vcluster connect my-vcluster -n vcluster-my-vcluster -- kubectl get ns
For more information, please take a look at the vcluster docs at https://www.vcluster.com/docs
Use the vcluster
# Run any kubectl, helm, etc. command in your vcluster
kubectl get namespace
kubectl get pods -n kube-system
kubectl create namespace demo-nginx
kubectl create deployment nginx-deployment -n demo-nginx --image=nginx
kubectl get pods -n demo-nginx
Cleanup
vcluster delete my-vcluster
참고
- vcluster - https://github.com/loft-sh/vcluster
- vcluster - https://www.vcluster.com
- CNCF vcluster
- Helm example APP
- vcluster TLS 솔루션
'Kubernetes' 카테고리의 다른 글
Nginx Ingress Rewirte & AWS Load Balancer Controller (0) | 2023.09.12 |
---|---|
[kubectl] krew - Kubernetes Plugin Manager (0) | 2023.07.10 |
[kubectl] kubectx + kubens 설정 및 자동 완성 (0) | 2023.07.09 |
nginx ingress controller tcp 설정 (0) | 2022.12.26 |
k3d & nginx igress - 로컬 PC 에 쿠버네티스 설치 (0) | 2022.12.26 |