Monthly Archives: June 2025

Nutanix NKP Authentication With LDAP

เตรียม nkp service user โดยเข้าไปที่เมนู Active Directory Users and Computers

Click Users เลือก New และ User

ตั้งชื่อ ตัวอย่างนี้ใช้ nkpsvc

หลังจากสร้าง user ใหม่แล้วเก็บ DN ไว้สำหรับใช้ในการ setup ใน NKP โดย click ที่ user เลือก Advanced Feature

click ที่ nkpsvc และเลือก Properties

click เลือก Attribute Editor และ copy ค่า distinguishedName สำหรับใช้ในการ config ที่ nkp

เปิดหน้า nkp-dashboard และเข้าไปที่เมนู Identity Providers

click Add Identity Provider และเลือก LDAP จากนั้นเลือก Workspace ที่ต้องการจะให้ Identity Provider นี้ถูกนำไปใช้ เลือก All Workspace หมายถึง Identity Provider นี้จะถูกใช้กับทุกๆ Workspace

หาค่า User Search Base DN โดย click ที่ Users เลือก Properties

ไปที่ Attribute Editor แล้วเลื่อนหา distinguishedName และทำการ copy ค่านี้เพื่อใช้สำหรับ User Search Base DN

ค่า User Search Username โดย click ที่ user nkpsvc เลือก Properties ไปที่ Attribute Editor แล้วเลื่อนไปที่ sAMAccountName

นำค่าที่ได้กรอกใน User Search Base DN และ User Search Username

กรอกค่าอื่นๆ ตามตัวอย่าง

จากนั้นกด save เพื่อบันทึก

ทำการสร้าง group เพื่อ authentication เข้ามายัง nkp platform จากนั้นสร้าง user และ assign ให้เข้ามาเป็น member ของ group ที่สร้างขึ้น

จากนั้นสร้าง Groups โดยเข้าไปที่เมนู Identity Providers และ click Add Identity Provider

ตั้งชื่อ group name และ group โดยต้องขึ้นต้นด้วย oidc: ตามด้วย group name ที่สร้างใน ldap

เข้าไปที่เมนู Access Control เพื่อให้ group NKP Admins มีสิทธิ์​เป็น Platform Admin ของระบบ NKP ที่สามารถเข้าถึงและจัดการ NKP Management Cluster และ NKP workload clusters ที่อยู่ในะรบบ

เลือก Cluster Role Bindings เลือก Add Roles ที่ group NKP Admins จากนั้น assign role Cluster Admin Role และ dkp-kommander-admin

Log out จากระบบ หน้า Log in จะมี option ให้เลือก login ได้มากกว่าหนึ่งช่องทาง ทดสอบ login ด้วย LDAP โดยเลือกที่ Log in with ntnxlab.local.AD

ตัวอย่างการสร้าง Role อื่นๆ เช่น

Workspace Admin มีสิทธิ์ Adminstrator สำหรับ NKP Workload Cluster โดยสามารถเข้าถึง NKP UI และเข้าถึง workspace ที่ถูก assign ให้เข้าถึงเท่านั้น โดยจะต้อง assign role “Workspace Admin Role” และ “Kommander Workspace Admin Role”

Project Deployer ที่มีสิทธิ์อยู่ภายใต้ namespace ของ NKP workload cluster และเข้าถึง kubernetes dashboad ได้ซึ่งตรงกับความต้องการพื้นฐานของทีม DevOps โดยจะต้อง assign role “App Deployer”

โครงสร้างการสร้าง NKP, Workspace และ Project

Nutanix NKP Installation

ขั้นตอนการติดตั้ง NKP ระบบจะสร้าง kubernetes ชั่วคราวสำหรับการติดตั้งเฉพาะ (bootstrap cluster) โดยจะ load package ที่จำเป็นคือ cluster-api ทำงานใน kubernetes ชั่วคราว อยู่ภายใต้ package ที่ชื่อว่า convoy โดย cluster-api จะสร้าง nkp management cluster ที่ infra platform ปลายทางจากข้อมูลที่ได้จาก NKP cli

cluster-api เป็น controller ที่ทำงานบน kubernetes ทำ infra auto provisioning ไปยัง platform ต่างๆ เนื่องจากการ provision kubernetes บน platform ที่แตกต่างกันจะต้องอาศัย api ที่แตกต่างกัน การใช้ kubernetes api จึงเป็นวิธีการที่ทำให้ไม่ว่า platform อะไรก็สามารถเรียกใช้ได้ด้วย api เดียวกัน cluster-api จึงเป็น standard ในการสร้าง kubernetes บน platform ที่แตกต่างกันได้ โดยมี vendor จากค่ายต่างๆ เข้าร่วมพัฒนาการเชื่อมต่อไปยัง platform ตัวเองจำนวนมาก เช่น nutanix, vmware, aws, google, azure เป็นต้น ทำให้ทำการสร้าง kubernetes เป็นเรื่องง่าย โดยไม่ต้องพัฒนาส่วนการเชื่อมต่อกับ platform ปลายทางเอง เพียงแค่ระบุรูปแบบ kubernetes cluster (yaml) จากนั้น cluster-api จะสร้าง kubernetes บน platform ปลายทางให้

การติดตั้ง Nutanix NKP จะต้องเตรียม docker และ kubectl ที่เครื่อง jumphost หรือเครื่องที่จะใช้ในการติดตั้ง ตัวอย่างนี้จะเป็นการติดตั้งโดยไม่ access internet และใช้ Rocky Linux

ตรวจสอบ docker ที่เครื่องที่ใช้ในการติดตั้ง สามารถทำได้ตามขั้นตอน Harbor Container Registry Installation

[nutanix@harbor nkp]$ docker version
Client: Docker Engine - Community
 Version:           28.3.0
 API version:       1.51
 Go version:        go1.24.4
 Git commit:        38b7060
 Built:             Tue Jun 24 15:45:22 2025
 OS/Arch:           linux/amd64
 Context:           default

Server: Docker Engine - Community
 Engine:
  Version:          28.3.0
  API version:      1.51 (minimum version 1.24)
  Go version:       go1.24.4
  Git commit:       265f709
  Built:            Tue Jun 24 15:43:38 2025
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          1.7.27
  GitCommit:        05044ec0a9a75232cad458027ca83437aae3f4da
 runc:
  Version:          1.2.5
  GitCommit:        v1.2.5-0-g59923ef
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0

การติดตั้งจำเป็นต้องมี Container Registry ที่มี package bundle ของ nkp ขั้นตอนนี้ทำการทดสอบ login จากเครื่องที่ใช้ในการติดตั้ง

[nutanix@harbor nkp]$ docker login 10.55.10.75
Username: admin
Password:

WARNING! Your credentials are stored unencrypted in '/home/nutanix/.docker/config.json'.
Configure a credential helper to remove this warning. See
https://docs.docker.com/go/credential-store/

Login Succeeded

ติดตั้ง kubectl สำหรับเข้าถึง kubernetes

[nutanix@harbor nkp-v2.14.0]$ sudo curl -Lo /usr/local/bin/kubectl https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 53.7M  100 53.7M    0     0  74.2M      0 --:--:-- --:--:-- --:--:-- 74.3M
[nutanix@harbor nkp-v2.14.0]$ sudo chmod +x /usr/local/bin/kubectl

ติดตั้ง nkp cliโดย copy Download Link จาก nutanix portal จากหน้า download software

ขั้นตอนการติดตั้ง nkp cli

curl -fsSL https://raw.githubusercontent.com/nutanixdev/nkp-quickstart/main/scripts/get-nkp-cli | bash

#When prompted, enter the copy Downloadd Link

[nutanix@harbor nkp]$ curl -fsSL https://raw.githubusercontent.com/nutanixdev/nkp-quickstart/main/get-nkp-cli | bash
Enter 'NKP for Linux' download link: https://download.nutanix.com/downloads/nkp/v2.14.0/nkp_v2.14.0_linux_amd64.tar.gz?Expires=1751224588&Key-Pair-Id=APKAJTTNCWPEI42QKMSA&Signature=HcZFo-J4aqVeBFxBH-6x4zsKbD-EYdEzg-zPylsLxOBbIQ6j5XmExGFEV~fCR8UyPwEpN4xw0TY~4D2MybSgcJfQ4Hm-uB-mIP2IaJ3xDmSaHcQTg-9pR5bg36HbRf~bscjnuMe7feKPj5getHXcFA3jpeMukz9KqID5ZAaDrI76KM~uv4oklIoHTIAZ2JoOb3nbmRZlGMblhB8AGTvrg8lMIozvqEYZdiqU9icpBL~uDEOFrfPFJo~jveT7dymHdmD33j--wzNNS9hPZMO1snMja6iObh~6q2G3J4STx9f6~cwXaCQE2nzXNn74eTPWi9GeZ9F~GdWpLcFZ5ARepQ__
NKP CLI installed successfully!
[nutanix@harbor nkp]$ nkp version
diagnose: v0.10.1
imagebuilder: v0.22.3
kommander: v2.14.0
konvoy: v2.14.0
mindthegap: v1.16.0
nkp: v2.14.0

Download NKP Airgapped Bundle สำหรับการติดตั้ง โดยการ copy Download Link จากหน้า nutanix portal

ขั้นตอนการ Download ผ่าน curl cli

[nutanix@harbor nkp]$ curl -o nkp-air-gapped-bundle_v2.14.0_linux_amd64.tar.gz "https://download.nutanix.com/downloads/nkp/v2.14.0/nkp-air-gapped-bundle_v2.14.0_linux_amd64.tar.gz?Expires=1751229414&Key-Pair-Id=APKAJTTNCWPEI42QKMSA&Signature=FPMLrX1BDFrqGfpMk6haH8TFwSoRkgMH27U9J6QtLO7kbldjss6UcIYtr0sngnT4AvxeX7j4T0B-1TsMXFgdNFyNpvycNCJEp1z-nG-7VcJfm9K2ZNdcsp-ZqLD42RuhRx~uS0UR7kw3ugwcxKgu9vcBNlDq1gh6VRVH8b9QtA6fp16DKQT6CiHyptVqqL-X1wRHPM7ti3LxMNaNhlrndF9D4v89ajxWfaNAICPRpbLjpLGxoviendqjd~sRd2ZsJUdKs6f78YMWCXHhGUH5Y0U38GwVFolQethXmQfvoDF5QvreOPKa6E1bZhQbVDcb3BfVqyPj0x-Zn7rl8Ww5wA__"
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 15.4G  100 15.4G    0     0  42.0M      0  0:06:17  0:06:17 --:--:-- 38.7M

Download Konvoy Image โดยการ Copy Download Link จาก nutanix portal

ขั้นตอนการ download จาก curl cli

[nutanix@harbor nkp]$ curl -o konvoy-image-bundle-v2.23.2_linux_amd64.tar.gz "https://download.nutanix.com/downloads/nkp/v2.14.0/konvoy-image-bundle-v2.22.2_linux_amd64.tar.gz?Expires=1751229375&Key-Pair-Id=APKAJTTNCWPEI42QKMSA&Signature=MvjKv3bi87AHpof4rmTgCoAmcR1qxs6y-y5C9Yhd7QvxJFDM8PuemyKdfV7hfObO5Q60e1vo9P9LPgI59gzCgrGa5OZp3df13d6N86drQpThuORkI7uD6LUMF30hqki9XEW8jDRIgn00QrTE3VWoD5KXfunoKCtLGlbDMSJt46w5pjspmFy0237qSobbgo9NfDOORnFiRqi8mBknrH122op8YzZ-kjk0zbHAFdSxouGRZBUEOXlqQ5MavLb9wzZq9PulvHCw9eDMx5L-TmYbXifMlyuh4TKvoqjRxKYCNh5ntPOYdSpgLsHN3Uh3YU1yW175fjsvZquK~YHRcjS~hw__"
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  330M  100  330M    0     0  83.2M      0  0:00:03  0:00:03 --:--:-- 83.2M

File ที่ download จากขั้นต้น

[nutanix@harbor nkp]$ ll
total 16674272
-rw-r--r--. 1 nutanix nutanix   346426397 Jun 29 10:36 konvoy-image-bundle-v2.23.2_linux_amd64.tar.gz
-rw-r--r--. 1 nutanix nutanix 16633123312 Jun 29 10:43 nkp-air-gapped-bundle_v2.14.0_linux_amd64.tar.gz

ทำการ unzip file nkp-air-gapped-bunndle และทำการ load docker image เข้าไปยังระบบ docker ของเครื่อง จากนั้นทำการ upload image ไปยัง docker registry ที่เตรียมไว้ด้วย nkp cli

[nutanix@harbor nkp]$ tar -xvf nkp-air-gapped-bundle_v2.14.0_linux_amd64.tar.gz

[nutanix@harbor nkp]$ cd nkp-v2.14.0/
[nutanix@harbor nkp-v2.14.0]$ docker load -i konvoy-bootstrap-image-v2.14.0.tar
[nutanix@harbor nkp-v2.14.0]$ docker image ls | grep konvoy-bootstrap
mesosphere/konvoy-bootstrap   v2.14.0   6692d49a959f   3 months ago   2.08GB

[nutanix@harbor nkp-v2.14.0]$ nkp push bundle --bundle ./container-images/konvoy-image-bundle-v2.14.0.tar --to-registry=10.55.10.75/mirror --to-registry-username=admin --to-registry-password=Harbor12345 --to-registry-insecure-skip-tls-verify

[nutanix@harbor nkp-v2.14.0]$ nkp push bundle --bundle ./container-images/kommander-image-bundle-v2.14.0.tar --to-registry=10.55.10.75/mirror --to-registry-username=admin --to-registry-password=Harbor12345 --to-registry-insecure-skip-tls-verify

สร้าง ssh key สำหรับ access VM ที่สร้างขึ้นโดยระบบ

[nutanix@harbor ~]$ ssh-keygen -t ed25519
Generating public/private ed25519 key pair.
Enter file in which to save the key (/home/nutanix/.ssh/id_ed25519):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/nutanix/.ssh/id_ed25519
Your public key has been saved in /home/nutanix/.ssh/id_ed25519.pub
The key fingerprint is:
SHA256://XGZ4k3rrFq2BC+QWmPk3NJNt972vQ5vHrnSuOyTm0 nutanix@harbor.local
The key's randomart image is:
+--[ED25519 256]--+
|                 |
|                 |
|          .      |
|         = +     |
|        S B + .  |
|         X + o . |
|          @ ..E.+|
|         o =.*o&X|
|          .o=*XX%|
+----[SHA256]-----+

ตัวอย่างนี้ใช้ ed25519 สำหรับการสร้าง key ซึ่งมีข้อดีดังนี้

Ed25519 offers several key advantages over RSA:

Performance: Ed25519 is significantly faster for both signing and verification operations. It uses elliptic curve cryptography which requires less computational overhead than RSA’s integer factorization approach.

Key size: Ed25519 uses 256-bit keys that provide security equivalent to 3072-bit RSA keys. This means much smaller key sizes for the same security level, reducing storage and transmission overhead.

Security design: Ed25519 was designed from the ground up to avoid many implementation pitfalls that have plagued RSA. It’s resistant to timing attacks, doesn’t require careful random number generation during signing (unlike RSA), and uses deterministic signatures.

Simplicity: The algorithm has fewer parameters and configuration options, reducing the chance of implementation errors. RSA requires choosing padding schemes, key sizes, and other parameters that can introduce vulnerabilities if done incorrectly.

Side-channel resistance: Ed25519 is designed to be resistant to side-channel attacks like timing and power analysis attacks, whereas RSA implementations often leak information through timing variations.

Future-proofing: While both are considered secure today, Ed25519’s elliptic curve foundation generally scales better as security requirements increase over time.

The main trade-off is that RSA is more widely supported in legacy systems, but for new applications, Ed25519 is generally the better choice due to its superior performance and security characteristics.

ติดตั้ง NKP ด้วย cli โดยจะต้อง export user และ password variable ก่อนจะ run nkp command

[nutanix@harbor nkp-v2.14.0]$ export NUTANIX_USER="admin"
export NUTANIX_PASSWORD='nx2Tech581!'
[nutanix@harbor nkp-v2.14.0]$ nkp create cluster nutanix --cluster-name nkp-at-next \
--control-plane-prism-element-cluster DM3-POC010 \
--worker-prism-element-cluster DM3-POC010 \
--control-plane-subnets primary-DM3-POC010 \
--worker-subnets primary-DM3-POC010 \
--control-plane-endpoint-ip 10.55.10.10 \
--csi-storage-container default \
--endpoint https://10.55.10.7:9440 \
--control-plane-vm-image nkp-rocky-9.5-release-1.31.4-20250214003015.qcow2 \
--worker-vm-image nkp-rocky-9.5-release-1.31.4-20250214003015.qcow2 \
--kubernetes-service-load-balancer-ip-range 10.55.10.11-10.55.10.14 \
--registry-mirror-url https://10.55.10.75/mirror \
--registry-mirror-username admin \
--registry-mirror-password Harbor12345 \
--registry-mirror-cacert /home/nutanix/harbor.crt \
--ssh-public-key-file /home/nutanix/.ssh/id_ed25519.pub \
--ssh-username nutanix \
--airgapped \
--insecure \
--verbose 5 \
--timeout 0 \
--self-managed

กรณี airgap ต้องระบุ registry mirror เพื่อใช้ในการติดตั้ง ตามขั้นตอน upload konvoy และ kommander image ในขั้นตอนก่อนหน้า

ข้อมูล harbor.crt ได้มาจากขั้นตอนการสร้าง harbor หรือ สามารถ export ได้ด้วย cli

openssl s_client -connect 10.55.10.75:443 -showcerts </dev/null 2>/dev/null | openssl x509 -outform PEM > /home/nutanix/harbor.crt

กรณีที่การติดตั้งสามารถ access internet ได้ไม่จำเป็นต้องใช้ option –airgapped และระบบจะทำการติดตั้งโดยใช้ค่า default ถ้าไม่ระบุใน cli เช่น ขนาดของ VM และจำนวน VM เช่น Control plane จำนวน 3 VMs และ Worker จำนวน 4 VMs ดังตัวอย่าง options อื่นๆ ดังนี้

𝗘𝗡𝗩𝗜𝗥𝗢𝗡𝗠𝗘𝗡𝗧 𝗩𝗔𝗥𝗜𝗔𝗕𝗟𝗘𝗦
export CLUSTER_NAME="wskn-mgmt-ag" # Name of the Kubernetes cluster
export NUTANIX_PC_FQDN_ENDPOINT_WITH_PORT="https://10.168.100.4:9440" # Nutanix Prism Central endpoint URL with port
export CONTROL_PLANE_IP="10.168.102.30" # IP address for the Kubernetes control plane
export IMAGE_NAME="nkp-rocky-9.4-release-1.29.6-20240816215147" # Name of the VM image to use for cluster nodes
export PRISM_ELEMENT_CLUSTER_NAME="wskn-nongpu" # Name of the Nutanix Prism Element cluster
export SUBNET_NAME="non-gpu-airgap" # Name of the subnet to use for cluster nodes
export PROJECT_NAME="default" # Name of the Nutanix project
export CONTROL_PLANE_REPLICAS="3" # Number of control plane replicas
export CONTROL_PLANE_VCPUS="4" # Number of vCPUs for control plane nodes
export CONTROL_PLANE_CORES_PER_VCPU="1" # Number of cores per vCPU for control plane nodes
export CONTROL_PLANE_MEMORY_GIB="16" # Memory in GiB for control plane nodes
export WORKER_REPLICAS="3" # Number of worker node replicas
export WORKER_VCPUS="8" # Number of vCPUs for worker nodes
export WORKER_CORES_PER_VCPU="1" # Number of cores per vCPU for worker nodes
export WORKER_MEMORY_GIB="32" # Memory in GiB for worker nodes
export NUTANIX_STORAGE_CONTAINER_NAME="default-container-xxx" # Name of the Nutanix storage container
export CSI_FILESYSTEM="ext4" # Filesystem type for CSI volumes
export CSI_HYPERVISOR_ATTACHED="true" # Whether to use hypervisor-attached volumes for CSI
export LB_IP_RANGE="10.168.102.31-10.168.102.31" # IP range for load balancer services
export SSH_KEY_FILE="/root/.ssh/id_rsa.pub" # Path to the SSH public key file
export NUTANIX_USER="admin" # Nutanix PrismCentral username (left blank for security)
export NUTANIX_PASSWORD="" # Nutanix PrismCentral password (left blank for security)
export REGISTRY_URL="https://registry.wskn-ag.local/library" # URL for the private container registry
export REGISTRY_USERNAME="admin" # Username for authenticating with the private registry (left blank for security)
export REGISTRY_PASSWORD="" # Password for authenticating with the private registry (left blank for security)
export REGISTRY_CA="/root/wskn-ag-certs/server.crt" # Path to the CA certificate for the private registry

𝗜𝗡𝗦𝗧𝗔𝗟𝗟𝗔𝗧𝗜𝗢𝗡 𝗖𝗢𝗠𝗠𝗔𝗡𝗗
nkp create cluster nutanix --cluster-name $CLUSTER_NAME \
    --endpoint $NUTANIX_PC_FQDN_ENDPOINT_WITH_PORT\
    --control-plane-endpoint-ip $CONTROL_PLANE_IP \
    --control-plane-vm-image $IMAGE_NAME \
    --control-plane-prism-element-cluster $PRISM_ELEMENT_CLUSTER_NAME \
    --control-plane-subnets $SUBNET_NAME \
    --control-plane-pc-project $PROJECT_NAME \
    --control-plane-replicas $CONTROL_PLANE_REPLICAS \
    --control-plane-vcpus $CONTROL_PLANE_VCPUS \
    --control-plane-cores-per-vcpu $CONTROL_PLANE_CORES_PER_VCPU \
    --control-plane-memory $CONTROL_PLANE_MEMORY_GIB \
    --worker-vm-image $IMAGE_NAME \
    --worker-prism-element-cluster $PRISM_ELEMENT_CLUSTER_NAME \
    --worker-subnets $SUBNET_NAME \
    --worker-pc-project $PROJECT_NAME \
    --worker-replicas $WORKER_REPLICAS \
    --worker-vcpus $WORKER_VCPUS \
    --worker-cores-per-vcpu $WORKER_CORES_PER_VCPU \
    --worker-memory $WORKER_MEMORY_GIB \
    --ssh-public-key-file $SSH_KEY_FILE \
    --csi-storage-container $NUTANIX_STORAGE_CONTAINER_NAME \
    --csi-file-system $CSI_FILESYSTEM \
    --csi-hypervisor-attached-volumes=$CSI_HYPERVISOR_ATTACHED \
    --kubernetes-service-load-balancer-ip-range $LB_IP_RANGE \
    --insecure \
    --self-managed \
    --airgapped \
    --registry-mirror-url $REGISTRY_URL \
    --registry-mirror-cacert $REGISTRY_CA \
    --registry-mirror-username=$REGISTRY_USERNAME \
    --registry-mirror-password=$REGISTRY_PASSWORD

หลังจาก nkp cli ทำงาน ระบบจะสร้าง kubernetes ชั่วคราวโดยใช้ KIND (kubernetes in docker) โดย load package ที่ได้จาก konvoy-bootstrap-image ระบบจะสร้าง kubeconfig ตาม format ชื่อ cluster สามารถใช้ access KIND cluster เพื่อตรวจสอบสถานะการทำงานได้ดังนี้

[nutanix@harbor nkp-v2.14.0]$ export KUBECONFIG=nkp-at-next-bootstrap.conf

ทำการ list logs ระหว่างการติดตั้งได้จาก container capx-controller-manager สำหรับ nutanix platform สำหรับ platform อื่นๆ สังเกตุจาก digit ที่ 4 คือ x = nutanix, a=aws, g=google, pp = preprovision, v=vmware, vcd=vmware cloud director, z=azure

[nutanix@harbor nkp-v2.14.0]$ kubectl logs -f capx-controller-manager-745948468d-dkjf5 -n capx-system

ตรวจสอบว่ามี container อะไรบ้างที่ถูกใช้ในการติดตั้ง

[nutanix@harbor nkp-v2.14.0]$ kubectl get pods -A -o yaml | grep image: | sort -h | uniq
      image: docker.io/kindest/kindnetd:v20240813-c6f155d6
      image: docker.io/kindest/local-path-provisioner:v20240813-c6f155d6
      image: docker.io/mesosphere/cluster-api-preprovisioned-controller:v0.34.2
      image: docker.io/mesosphere/kommander2-runtime-extension:v1.2.0
      image: ghcr.io/mesosphere/cluster-api-addon-provider-helm/cluster-api-helm-controller:v0.2.4-d2iq.0
      image: ghcr.io/mesosphere/cluster-api-controller:v1.9.3-d2iq.1
      image: ghcr.io/mesosphere/kubeadm-bootstrap-controller:v1.9.3-d2iq.1
      image: ghcr.io/mesosphere/kubeadm-control-plane-controller:v1.9.3-d2iq.1
      image: ghcr.io/mesosphere/mindthegap:v1.17.0
      image: ghcr.io/nutanix-cloud-native/cluster-api-provider-nutanix/controller:v1.5.3
      image: ghcr.io/nutanix-cloud-native/cluster-api-runtime-extensions-helm-chart-bundle-initializer:v0.27.4
      image: ghcr.io/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix:v0.27.4
      image: mcr.microsoft.com/k8s/azureserviceoperator:v2.8.0
      image: quay.io/jetstack/cert-manager-cainjector:v1.16.1
      image: quay.io/jetstack/cert-manager-controller:v1.16.1
      image: quay.io/jetstack/cert-manager-webhook:v1.16.1
      image: registry.k8s.io/cluster-api-aws/cluster-api-aws-controller:v2.7.1
      image: registry.k8s.io/cluster-api-azure/cluster-api-azure-controller:v1.17.2
      image: registry.k8s.io/cluster-api-gcp/cluster-api-gcp-controller:v1.8.1
      image: registry.k8s.io/cluster-api-vsphere/cluster-api-vsphere-controller:v1.12.0
      image: registry.k8s.io/coredns/coredns:v1.11.3
      image: registry.k8s.io/etcd:3.5.15-0
      image: registry.k8s.io/kube-apiserver-amd64:v1.31.4
      image: registry.k8s.io/kube-apiserver:v1.31.4
      image: registry.k8s.io/kube-controller-manager-amd64:v1.31.4
      image: registry.k8s.io/kube-controller-manager:v1.31.4
      image: registry.k8s.io/kube-proxy-amd64:v1.31.4
      image: registry.k8s.io/kube-proxy:v1.31.4
      image: registry.k8s.io/kube-scheduler-amd64:v1.31.4
      image: registry.k8s.io/kube-scheduler:v1.31.4

รอจนกว่าระบบจะติดตั้งสมบูรณ์ โดยขั้นตอนการติดตั้งระบบจะลบ KIND และย้าย configuration ไปยัง cluster ปลายทาง โดยจะสร้าง kubeconfig ไว้ให้เพื่อ access ไปยัง cluster ที่สร้างขึ้นใหม่ ใช้เวลาประมาณ 10-20 นาที

Cluster default/nkp-at-next kubeconfig was written to to the filesystem.
You can now view resources in the new cluster by using the --kubeconfig flag with kubectl.
For example: kubectl --kubeconfig="/home/nutanix/nkp/nkp-v2.14.0/nkp-at-next.conf" get nodes

Starting kommander installation
 ✓ Deploying Flux
 ✓ Deploying Ingress certificate
 ✓ Creating kommander-overrides ConfigMap
 ✓ Deploying Git Operator
 ✓ Creating GitClaim for management GitRepository
 ✓ Creating GitClaimUser for accessing management GitRepository
 ✓ Configuring HelmRepositories for airgapped environment
 ✓ Deploying Flux configuration
 ✓ Deploying Kommander Operator
 ✓ Creating KommanderCore resource
 ✓ Cleaning up kommander bootstrap resources
Got a Retry-After 1s response for attempt 1 to https://10.55.10.10:6443/apis/dkp.d2iq.io/v1alpha1/kommandercores?watch=true
 ✓ Deploying ChartMuseum
 ✓ Deploying Gatekeeper
 ✓ Deploying Kommander AppManagement
 ✓ Creating Core AppDeployments
 ✓ 4 out of 13 core applications have been installed (waiting for dex, dex-k8s-authenticator and 7 more)
 ✓ 6 out of 13 core applications have been installed (waiting for dex-k8s-authenticator, kommander and 5 more)
 ✓ 7 out of 13 core applications have been installed (waiting for dex-k8s-authenticator, kommander and 4 more)
 ✓ 8 out of 13 core applications have been installed (waiting for dex-k8s-authenticator, kommander and 3 more)
 ✓ 9 out of 13 core applications have been installed (waiting for dex-k8s-authenticator, kommander-ui and 2 more)
 ✓ 10 out of 13 core applications have been installed (waiting for dex-k8s-authenticator, kubefed and 1 more)
 ✓ 11 out of 13 core applications have been installed (waiting for dex-k8s-authenticator, traefik-forward-auth-mgmt)
 ✓ 12 out of 13 core applications have been installed (waiting for traefik-forward-auth-mgmt)
 ✓ Creating cluster-admin credentials

Cluster was created successfully! Get the dashboard details with:
nkp get dashboard --kubeconfig="/home/nutanix/nkp/nkp-v2.14.0/nkp-at-next.conf"

login ไปยัง nkp management platform โดยใช้ nkp cli เพื่อ generate user และ password รวมถึง dashboard url

[nutanix@harbor nkp-v2.14.0]$ nkp get dashboard --kubeconfig="/home/nutanix/nkp/nkp-v2.14.0/nkp-at-next.conf"
Username: happy_gauss
Password: PuK76Q4AUKRCEALcrU9mAW1SNMsMMxelIexQv8Ngw3ONAQ4dPTNzEl5xBcAr4Uln
URL: https://10.55.10.11/dkp/kommander/dashboard

Access dashboard ตามข้อมูลที่ได้

Harbor Container Registry Installation

Harbor เป็น container registry ที่ได้รับความนิยมมากในปัจจุบัน เนื่องจากมีความสามารถที่ช่วยให้เก็บ container image ไว้ภายในองค์กรแล้วยังมีความสามารถอื่นๆ เช่น การทำ proxy ไปยัง container registry ภายนอกเช่น docker hub เพื่อลดจำนวน request ไม่ให้ติดปัญหา request limit ของ docker hub การทำ replication ระหว่าง Harbor ด้วยกันกรณี DC/DR use case และ integrate กับ container scanning เช่น Trivy, Clair และ Notary สำหรับการทำ image signed เพื่อป้องกันการแก้ไขเปลี่ยนแปลง image

ในการติดตั้ง Harbor ต้องการ Docker และ Docker Compose ขั้นตอนการ install docker ขึ้นอยู่กับ OS โดยตัวอย่างนี้ติดตั้งบน Linux Rocky

#!/bin/bash
# Docker Installation Script for Rocky Linux

# 1. Update system packages
sudo dnf update -y

# 2. Install required packages
sudo dnf install -y dnf-utils device-mapper-persistent-data lvm2

# 3. Add Docker's official repository
sudo dnf config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo

# 4. Install Docker Engine
sudo dnf install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin

# 5. Start and enable Docker service
sudo systemctl start docker
sudo systemctl enable docker

# 6. Add current user to docker group (to run docker without sudo)
sudo usermod -aG docker $USER

# 7. Verify Docker installation
sudo docker --version
sudo docker run hello-world

# 8. Check Docker service status
sudo systemctl status docker

# 9. Optional: Install Docker Compose (if not using plugin version)
# sudo curl -L "https://github.com/docker/compose/releases/latest/download/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
# sudo chmod +x /usr/local/bin/docker-compose

echo "Docker installation completed!"
echo "Please log out and log back in for group changes to take effect."
echo "Then you can run 'docker ps' without sudo."

กรณีที่ enable firewall จะต้องทำการ allow service docker ด้วย

# Open Docker ports if firewall is enabled
sudo firewall-cmd --permanent --add-service=docker
sudo firewall-cmd --reload

กรณีนี้ติดตั้งด้วยการใช้ self-signed certificate จำเป็นต้องสร้างไฟล์​ daemon.json และใส่ค่า insecure โดยระบุทั้ง host name, host domain และ IP ถ้าไม่ได้สร้าง record บน DSN server

[nutanix@harbor harbor]$ more /etc/docker/daemon.json
{
    "insecure-registries": ["harbor.local", "10.55.10.75"]
}

ต้อง restart docker หลังจากสร้างไฟล์​ daemon.json เพื่อให้ค่า configuration ถูกนำไปใช้

[nutanix@harbor harbor]$ sudo systemctl restart docker

ทำการ download harbor installation binary และสร้างไฟล์ที่เกี่ยวข้อง

[nutanix@harbor harbor]$ HARBOR_VERSION=$(curl -s https://api.github.com/repos/goharbor/harbor/releases/latest | grep 'tag_name' | cut -d\" -f4)

[nutanix@harbor harbor]$ echo $HARBOR_VERSION
v2.13.1

[nutanix@harbor harbor]$ wget "https://github.com/goharbor/harbor/releases/download/${HARBOR_VERSION}/harbor-offline-installer-${HARBOR_VERSION}.tgz"

[nutanix@harbor harbor]$ tar xvf harbor-offline-installer-${HARBOR_VERSION}.tgz

[nutanix@harbor harbor]$ cd harbor
[nutanix@harbor harbor]$ cp harbor.yml.tmpl harbor.yml

[nutanix@harbor harbor]$ mkdir certs
[nutanix@harbor harbor]$ mkdir data
[nutanix@harbor harbor]$ mkdir generate-cert

ทำการ generate certificate สำหรับ Harbor ตัวอย่างนี้จะตั้ง host name เป็น harbor.local โดยเป็น self-signed certificate


# Generate CA Key
[nutanix@harbor harbor]$ cd generate-cert
[nutanix@harbor generate-cert]$ openssl genrsa -out ca.key 4096

# Generate CA certificate
[nutanix@harbor generate-cert]$ openssl req -x509 -new -nodes -sha512 -days 3650 \
-subj "/C=TH/ST=TH/L=BK/O=IT/OU=IT/CN=harbor.local" \
-key ca.key \
-out ca.crt

#Generate Server key
[nutanix@harbor generate-cert]$ openssl genrsa -out harbor.local.key 4096

# Generate CSR (Certificate Signing Requests)
[nutanix@harbor generate-cert]$ openssl req -sha512 -new \
-subj "/C=TH/ST=TH/L=BK/O=IT/OU=IT/CN=harbor.local" \
-key harbor.local.key \
-out harbor.local.csr

# Create file v3.ext
[nutanix@harbor generate-cert]$ vi v3.ext
authorityKeyIdentifier=keyid,issuer
basicConstraints=CA:FALSE
keyUsage = digitalSignature, nonRepudiation, keyEncipherment, dataEncipherment
extendedKeyUsage = serverAuth
subjectAltName = @alt_names

[alt_names]
DNS.0=harbor.local
IP.0=10.55.10.75 #harbor IP address

# Generate Server Certificate signed with above CA generated
[nutanix@harbor generate-cert]$ openssl x509 -req -sha512 -days 3650 \
-extfile v3.ext \
-CA ca.crt -CAkey ca.key -CAcreateserial \
-in harbor.local.csr \
-out harbor.local.crt

# Optional - Convert the certificate to PEM format for docker
[nutanix@harbor generate-cert]$ openssl x509 -inform PEM -in harbor.local.crt -out harbor.local.cert

#copy harbor.local.crt and harbor.local.key for harbor server
[nutanix@harbor generate-cert]$ cp harbor.local.crt ../certs
[nutanix@harbor generate-cert]$ cp harbor.local.key ../certs

แก้ไขไฟล์ harbor.yml โดยมีค่าที่จำเป็นต้องแก้ดังนี้

hostname:
certificate:
private_keys:
data_volume:

hostname เป็น domain name ที่ map ไว้ที่ DNS server แต่ถ้าไม่มี DNS server สามารถใช้ IP แทนได้ดังตัวอย่างนี้

Certificate และ private_keys ได้จากขึ้นตอนสร้าง certificate ข้างต้น

data_volume คือข้อมูลระบบและ docker image ที่จัดเก็บใน harbor จำเป็นในการ backup กรณีระบบมีปัญหา และต้องการ recover

run install command เพื่อติดตั้ง harbor ทั้งนี้สามารถติดตั้ง components อื่นๆ ร่วมด้วยโดยใช้ options –with-trivy –with-notary –with-clair –with-chartmuseum

trivy และ clair สำหรับ vulnerability scanner และ notary สำหรับ container signing และ chartmuseum เพื่อให้ harbor สามารถเก็บ helm chart ได้ ตัวอย่างนี้จะติดตั้งเฉพาะ harbor

[nutanix@harbor harbor]$ sudo ./install.sh

หลังจากติดตั้งเสร็จ ทดสอบ login

[nutanix@harbor harbor]$ docker login 10.55.10.75
Username: admin
Password:

WARNING! Your credentials are stored unencrypted in '/home/nutanix/.docker/config.json'.
Configure a credential helper to remove this warning. See
https://docs.docker.com/go/credential-store/

Login Succeeded

กรณีที่ต้องการทำ registry proxy จะต้องไปสร้าง enpoint ที่ต้องการ connect ก่อน โดยเข้าไปที่เมนู Registries และ click +NEW ENDPOINT

กรณีนี้เลือก Docker Hub จากนั้นกรอกข้อมูล Access ID และ Access Secret เพื่อ connect ไปยัง Docker hub โดยต้องไปสร้าง access token ที่ Docker Hub ก่อน สามารถทำทดสอบการเชื่อมต่อโดย click TEST CONNECTION กด OK เพื่อเพิ่ม Endpoint

สร้าง Projects โดยเข้าไปที่เมนู Projects และ click + NEW PROJECT

กรอกข้อมูล Project name เลือก Access Level เลือก Proxy Cache และเลือก endpoint ที่สร้างในขั้นต้น และ click OK เพื่อสร้าง Project

สร้าง Projects อื่นๆ ตัวอย่างนี้สร้าง Project mirror สำหรับติดตั้ง NKP

กรอกข้อมูล Project

Project ที่สร้างขึ้น