hoatranlab.io.vn Zalo: 0917516878 Hotline: 0917516878 [email protected]
HoaTranLab HoaTranLab
Buổi 2 / 14

Triển Khai vCenter Server

Module 3: VCSA deployment · Inventory Structure · RBAC · Active Directory Integration

Tiến độ khóa học2 / 14 buổi
~4 giờ Intermediate Module 3 VCSA 8.x RBAC
Nội dung thực hành trên ESXi 8.0 Update 3 & vCenter Server 8.0 Update 3 (Build 24022515)

Mục Tiêu Buổi Học

  • Hiểu kiến trúc VCSA và vCenter Inventory Hierarchy
  • Cài đặt thành công VCSA qua VCSA Installer GUI (Stage 1 + Stage 2)
  • Xây dựng Inventory: Datacenter, Cluster, Folders, Resource Pools
  • Phân quyền RBAC với custom roles và propagation
  • Tích hợp Active Directory làm Identity Source
  • Hiểu VCSA sizing guidelines cho môi trường thực tế

LÝ THUYẾT — MODULE 3

3.1 Kiến Trúc vCenter Server Appliance (VCSA)

			Docker Desktop Installation Verification
			# Chi tiết kiến trúc:
			Docker Desktop Installation Verification

vCenter Inventory Hierarchy

			Docker Desktop Installation Verification

	
	

vSphere Permissions Model

Permission = Role + User/Group + Object (+ Propagate)

Built-in Roles:
  - No Access
  - Read-Only
  - Administrator
  - Virtual Machine User
  - Virtual Machine Power User
  - Resource Pool Administrator
  - VMware Consolidated Backup User
  - Datastore Consumer
  - Network Administrator
  			Docker Desktop Installation Verification

  

VCSA Sizing Guidelines

Deployment SizevCPURAMStorageMax HostsMax VMs
Tiny212 GB415 GB10100
Small419 GB480 GB1001,000
Medium828 GB700 GB4004,000
Large1637 GB1,065 GB1,00010,000
X-Large2445 GB1,805 GB2,00035,000

LAB THỰC HÀNH — MODULE 3

Lab 3.1 — Cài Đặt VCSA (vCenter Server Appliance)

Phương thức: VCSA Installer GUI (từ Windows/Mac/Linux)

Bước 1: Mount ISO
  File: VMware-VCSA-all-8.x.x-xxxxx.iso
  Chạy: /vcsa-ui-installer/win32/installer.exe

Bước 2: Stage 1 — Deploy OVF
  Install → vCenter Server with Embedded PSC
  Target ESXi: 10.100.100.11 (root / password)
  VM Name: vcsa-01
  Deployment Size: Small
  Datastore: datastore1 (thin provisioned)

Bước 3: Cấu hình Network
  Network: VM Network
  IP: 10.100.100.10 (static)
  Subnet: 255.255.255.0
  Gateway: 10.100.100.1
  DNS: 10.100.100.1
  FQDN: vcsa-01.lab.local

Bước 4: Stage 2 — vCenter Configuration
  NTP Server: time.google.com
  SSO Domain: vsphere.local
  SSO Password: VMware1!

Bước 5: Truy cập vSphere Client
  URL: https://vcsa-01.lab.local/ui
  User: [email protected]
  Password: VMware1!

Lab 3.2 — Xây Dựng Inventory Structure

1. Tạo Datacenter:
   vSphere Client → Right-click vCenter → New Datacenter
   Name: DC-HaNoi

2. Tạo Cluster:
   Right-click DC-HaNoi → New Cluster
   Name: Cluster-Production
   (Chưa bật HA/DRS ở đây — cấu hình ở Module 8)

3. Add ESXi Hosts vào Cluster:
   Right-click Cluster → Add Hosts
   Thêm: 10.100.100.11, 10.100.100.12, 10.100.100.13

4. Tạo VM Folders:
   Right-click Datacenter → New Folder → VM and Templates
   Folders: Production, Development, Templates, Decommission

5. Tạo Resource Pool:
   Right-click Cluster → New Resource Pool
   Name: RP-Production
   CPU Shares: High
   Memory Shares: High

   Name: RP-Development
   CPU Shares: Low
   Memory Shares: Low
   
 ### Mục đích:
 1. Tạo Datacenter (DC-HaNoi)
	Datacenter là container logic cấp cao nhất trong vCenter Inventory, 
	gom tất cả tài nguyên (hosts, VMs, networks, datastores) thành một đơn vị quản lý thống nhất. 
	Đặt tên theo địa lý (DC-HaNoi) giúp phân biệt rõ khi hệ thống mở rộng ra nhiều site.

2. Tạo Cluster (Cluster-Production)
	Cluster nhóm nhiều ESXi host lại để chia sẻ tài nguyên và kích hoạt HA/DRS sau này. 
	Tạo trước nhưng chưa bật HA/DRS để giữ cấu hình sạch 
	— các tính năng nâng cao sẽ được cấu hình ở Module 8 khi hạ tầng đã ổn định.

3. Add ESXi Hosts vào Cluster
	Đưa các host (10.100.100.11, .12, .13) vào cluster để quản lý tập trung qua vCenter. 
	Từ đây, vCenter kiểm soát toàn bộ vòng đời VM, 
	tài nguyên và network trên cả 3 host thay vì quản lý từng host riêng lẻ.

4. Tạo VM Folders
	Folders phân loại VM theo mục đích sử dụng và vòng đời, không phải theo vật lý:
	Production — VM đang chạy thật
	Development — VM thử nghiệm
	Templates — lưu golden image để clone nhanh
	Decommission — VM chuẩn bị xóa/tắt, tránh nhầm lẫn

5. Tạo Resource Pool
	Resource Pool phân chia và ưu tiên tài nguyên CPU/Memory giữa các nhóm workload:
		Resource Pool	CPU Shares	Memory Shares	Mục đích
		RP-Production	High	High	Đảm bảo VM production luôn được ưu tiên tài nguyên khi tranh chấp
		RP-Development	Low	Low	Giới hạn tài nguyên cho VM dev, không ảnh hưởng production
###Mục đích tổng thể
Toàn bộ chuỗi bước này thực chất là bước chuẩn bị inventory — xây khung hạ tầng có cấu trúc,
	phân quyền và phân tầng rõ ràng, để khi triển khai VM thực tế và bật HA/DRS ở các module sau,
	mọi thứ đều hoạt động đúng chỗ và dễ vận hành.  
 			Docker Desktop Installation Verification
 			Docker Desktop Installation Verification
 			Docker Desktop Installation Verification
 			Docker Desktop Installation Verification
 			Docker Desktop Installation Verification
 			Docker Desktop Installation Verification
  

Lab 3.3 — Phân Quyền Role-Based Access Control (RBAC)

Scenario: Tạo user cho team vận hành

1. Tạo SSO Users:
   Menu → Administration → Users and Groups → Users
   Domain: vsphere.local

   User: vm-operator (quyền vận hành VM)
   User: network-admin (quyền quản lý network)
   User: readonly-audit (chỉ đọc, cho audit)
 			Docker Desktop Installation Verification

2. Tạo Custom Role:
   Menu → Administration → Roles → Create
   Name: VM-Operator
   Permissions:
     Virtual Machine → Interaction → Power On/Off, Console
     Virtual Machine → Snapshot → Create, Delete, Revert
 			Docker Desktop Installation Verification

3. Assign Permission:
   Right-click Folder "Production" → Add Permission
   User: [email protected]
   Role: VM-Operator
   ✓ Propagate to children
 			Docker Desktop Installation Verification

4. Kiểm tra:
   Logout → Login với vm-operator
   Xác nhận chỉ thấy VMs trong Production
    			Docker Desktop Installation Verification

   

ỨNG DỤNG DOANH NGHIỆP — MODULE 3

Các pattern triển khai vCenter thực tế tại doanh nghiệp — từ tích hợp AD, thiết kế RBAC đến kiến trúc multi-site và governance.

1. Active Directory Integration — Từng Bước Chi Tiết

Đây là bước bắt buộc trong môi trường doanh nghiệp — không sử dụng vsphere.local cho production.

Chuẩn bị trước khi tích hợp AD

  • VCSA phải resolve được domain (DNS trỏ đúng AD DNS server)
  • NTP đồng bộ giữa VCSA và Domain Controller (chênh lệch <5 phút)
  • Chuẩn bị sẵn tài khoản [email protected] có quyền join máy vào domain
  • Tạo sẵn các AD Groups: GG-VMware-Admins, GG-VMware-Ops, GG-VMware-ReadOnly, GG-VMware-Backup

vCenter 8.0.3 — Cấu trúc tab SSO Configuration

Identity Provider
→ Join / Leave AD Domain
Identity Sources
→ Add / Edit / Delete nguồn

IWA (Integrated Windows Auth) bị deprecated từ vSphere 8.0 — khuyến nghị dùng LDAP/LDAPS thay thế

### BƯỚC 1: Kiểm tra DNS từ VCSA (SSH vào VCSA)
# SSH: ssh [email protected]
nslookup hoatranlab.io.local            # Phải resolve ra DC IP (10.100.100.3)
nslookup dc01.hoatranlab.io.local       # Forward lookup
nslookup 10.100.100.3                   # Reverse lookup

# Kiểm tra time sync
timedatectl status                      # Phải SYNCHRONIZED (chênh <5 phút với DC)

### BƯỚC 2: Join VCSA vào Active Directory Domain
# vSphere Client → Menu → Administration
# → Single Sign-On → Configuration
# → Tab: [Identity Provider]                  ← đúng vị trí vCenter 8.0.3
# → Nút [JOIN AD DOMAIN]
#
# Active Directory Domain: hoatranlab.io.local
# Organizational Unit (OU, tuỳ chọn): OU=Servers,OU=IT,DC=hoatranlab,DC=io,DC=local
# Username (UPN format):  [email protected]  ← BẮT BUỘC dùng UPN
# Password:               *****
#
# → [JOIN] → Thông báo "Successfully joined" → REBOOT VCSA (bắt buộc)

### BƯỚC 3: Thêm AD làm Identity Source (sau khi reboot)
# Administration → Single Sign-On → Configuration
# → Tab: [Identity Sources]                   ← tab khác với BƯỚC 2
# → [ADD]
#
# Identity source type:
#   ● Active Directory (Integrated Windows Authentication)  ← dùng nếu đã join domain
#     Domain name:  hoatranlab.io.local
#     Domain alias: HOATRANLAB
#
#   ● Active Directory over LDAP  ← thay thế nếu không muốn join domain
#     Server URL:   ldap://10.100.100.3:389
#     Base DN:      DC=hoatranlab,DC=io,DC=local
#     Username:     CN=svc-vcenter,OU=Service Accounts,DC=hoatranlab,DC=io,DC=local
#
# → [ADD] (không có nút Test Connection riêng — kiểm tra qua Users and Groups)

### BƯỚC 4: Xác nhận Identity Source hoạt động
# Administration → Single Sign-On → Configuration → Identity Sources
# Danh sách hiển thị:
#   localos          (built-in)
#   vsphere.local    (hệ thống — GIỮ LẠI làm tài khoản break-glass)
#   hoatranlab.io.local  ← phải xuất hiện ở đây

# Kiểm tra user/group AD visible:
# Administration → Single Sign-On → Users and Groups
# → Chọn Domain: hoatranlab.io.local → tìm user/group

### BƯỚC 5: Gán quyền cho AD Groups
# Administration → Access Control → Global Permissions
# → [+] ADD
#   Domain:  HOATRANLAB  (chọn từ dropdown)
#   User/Group: GG-VMware-Admins  → Role: Administrator  ✓ Propagate
#
# → [+] ADD
#   User/Group: GG-VMware-ReadOnly → Role: Read-Only     ✓ Propagate

### BƯỚC 6: Test đăng nhập AD
# Đăng xuất → Đăng nhập: [email protected]
# Xác nhận thấy đúng scope inventory theo RBAC đã cấu hình

Troubleshooting AD Integration thường gặp

LỗiNguyên nhânGiải pháp
"Domain not reachable"DNS sai / firewall block port 389Kiểm tra DNS, mở port 389/636/3268
"Clock skew too great"NTP lệch >5 phútĐồng bộ NTP với DC, restart chronyd
"Login failed" sau khi add ADChưa reboot VCSA sau khi join domainReboot VCSA appliance, thử lại
User thấy "No access"Chưa gán permission / Propagate chưa bậtAdd permission, bật Propagate to children

2. RBAC Design Pattern Doanh Nghiệp (Least Privilege)

Thiết kế RBAC theo nguyên tắc Minimum Necessary Access — mỗi team chỉ có quyền trên đúng scope họ cần.

AD Group vSphere Role Scope (Object) Propagate Mô tả
GG-VMware-AdminsAdministratorvCenter rootIT Infra team, toàn quyền
GG-VMware-OpsVM-Operator*Folder: ProductionOps team: power on/off, console, snapshot
GG-VMware-DevOpsVM-Provisioner*Folder: DevelopmentDevOps: tạo/clone/xóa VM trong Dev
GG-VMware-NetworkNetwork Admin*Distributed SwitchesNetwork team: quản lý vDS, port groups
GG-VMware-BackupBackup User*vCenter rootVeeam/backup agent: snapshot, read VM config
GG-VMware-AuditRead-OnlyvCenter rootAuditor, monitoring agents: chỉ đọc

* Custom Role — cần tạo thủ công. Xem PowerCLI script bên dưới.

### PowerCLI — Tạo Custom Roles tự động
Connect-VIServer vcsa-01.lab.local -User [email protected]

# 1. VM-Operator Role (Ops team)
$vmOpsPriv = @(
    'VirtualMachine.Interact.PowerOn',
    'VirtualMachine.Interact.PowerOff',
    'VirtualMachine.Interact.ConsoleInteract',
    'VirtualMachine.State.CreateSnapshot',
    'VirtualMachine.State.RevertToSnapshot',
    'VirtualMachine.State.RemoveSnapshot'
)
New-VIRole -Name "VM-Operator" -Privilege (Get-VIPrivilege -Id $vmOpsPriv)

# 2. VM-Provisioner Role (DevOps team)
$provPriv = @(
    'VirtualMachine.Inventory.Create',
    'VirtualMachine.Inventory.Delete',
    'VirtualMachine.Inventory.Move',
    'VirtualMachine.Config.AddNewDisk',
    'VirtualMachine.Config.Memory',
    'VirtualMachine.Config.CPUCount',
    'VirtualMachine.Provisioning.Clone',
    'VirtualMachine.Provisioning.DeployTemplate'
) + $vmOpsPriv
New-VIRole -Name "VM-Provisioner" -Privilege (Get-VIPrivilege -Id $provPriv)

# 3. Backup Role (Veeam/Commvault)
$backupPriv = @(
    'VirtualMachine.State.CreateSnapshot',
    'VirtualMachine.State.RemoveSnapshot',
    'VirtualMachine.Config.DiskLease',
    'VirtualMachine.Provisioning.DiskRandomRead',
    'VirtualMachine.Provisioning.GetVmFiles',
    'Datastore.Browse',
    'Global.DisableMethods',
    'Global.EnableMethods'
)
New-VIRole -Name "Backup-User" -Privilege (Get-VIPrivilege -Id $backupPriv)

# 4. Gán Permissions từ AD Groups
$vcRoot = Get-Folder -NoRecursion -Type Datacenter | Get-VIObjectByVIView
New-VIPermission -Entity (Get-Folder "vm" -Type VM) -Principal "CORP\GG-VMware-Admins" -Role "Administrator" -Propagate $true
New-VIPermission -Entity (Get-Folder "Production") -Principal "CORP\GG-VMware-Ops"   -Role "VM-Operator"  -Propagate $true
New-VIPermission -Entity (Get-Folder "Development") -Principal "CORP\GG-VMware-DevOps" -Role "VM-Provisioner" -Propagate $true

3. Service Accounts cho Automation & Integration

Mỗi công cụ tự động hóa cần service account riêng với quyền tối thiểu — không dùng chung hoặc dùng admin account.

Service Account Dùng cho Role cần thiết Scope Ghi chú bảo mật
svc-terraform@corpTerraform vSphere providerVM-Provisioner + DatastoreDC cụ thểRotate password 90 ngày
svc-ansible@corpAnsible VMware modulesVM-OperatorFolder ProductionLưu credential trong Vault
svc-veeam@corpVeeam Backup & ReplicationBackup-UservCenter rootDedicated account cho Veeam
svc-zabbix@corpZabbix vSphere monitoringRead-OnlyvCenter rootKhông cần write permission
svc-vrops@corpAria Operations (vROps)Read-Only + vROpsvCenter rootvROps có built-in role

Best Practice — Quản lý Credentials

  • Lưu service account credentials trong HashiCorp Vault hoặc CyberArk PAM
  • Không hardcode password trong script, config file hoặc pipeline
  • Enable Password Never Expires cho service accounts nhưng rotate thủ công theo chu kỳ 90 ngày
  • Ghi lại đầy đủ trong CMDB (ServiceNow): account purpose, owner, expiry date
  • Bật account audit logging — theo dõi login failures từ service accounts

4. Kiến Trúc Multi-Site — Enhanced Linked Mode

Doanh nghiệp có nhiều data center (HN + HCM / On-prem + Cloud) cần quản lý tập trung từ 1 giao diện duy nhất.

### TOPOLOGY — Multi-Site Enhanced Linked Mode

  ┌─────────────────────────────────────────────────────────────────┐
  │                    SINGLE SSO DOMAIN: hoatranlab.io.local          │
  │  ┌───────────────────────┐     ┌───────────────────────────┐   │
  │  │   vCenter HÀ NỘI      │     │   vCenter HỒ CHÍ MINH     │   │
  │  │   vcsa-hn.corp.com    │◄────►   vcsa-hcm.corp.com       │   │
  │  │   (Primary)           │     │   (Secondary)             │   │
  │  │   Cluster-HN-Prod     │     │   Cluster-HCM-Prod        │   │
  │  │   3x ESXi hosts       │     │   3x ESXi hosts           │   │
  │  └───────────────────────┘     └───────────────────────────┘   │
  │                   ▲ Enhanced Linked Mode ▲                      │
  │              Single pane of glass via vSphere Client            │
  └─────────────────────────────────────────────────────────────────┘

### YÊU CẦU cho Enhanced Linked Mode:
  - Cùng SSO domain (vsphere.local hoặc federate AD)
  - vCenter phiên bản phải tương đồng (không chênh quá 1 minor version)
  - Network connectivity giữa 2 vCenter (port 443, 7444)
  - DNS phải resolve cả 2 FQDN từ cả 2 site

### CẤU HÌNH:
# Trên vcsa-hn (Primary):
# Menu → Administration → Single Sign On
# → Configuration → Identity Provider
# → Join Existing SSO Domain (nếu standalone)

# Sau khi cùng SSO domain:
# Tự động được link trong vSphere Client
# Người dùng chỉ cần đăng nhập 1 lần → thấy cả 2 vCenter

### KHI NÀO DÙNG:
  ✓ Quản lý >1 vCenter từ 1 giao diện
  ✓ vMotion cross-vCenter (Enhanced vMotion Capability)
  ✓ Unified permission management
  ✗ KHÔNG bắt buộc nếu chỉ có 1 vCenter
Kịch bảnGiải phápƯu điểmLưu ý
<100 hosts, 1 site1 vCenterĐơn giản, tiết kiệm licenseSizing: Small đến Medium
2+ sites, DR requirementEnhanced Linked ModeSingle pane of glass, cross-vCenter vMotionCần SSO domain chung
>1000 hosts / Multi-tenantFederation + vSphere+Scale out, tenant isolationYêu cầu vSphere+ subscription

5. Checklist Triển Khai VCSA Production

Danh sách kiểm tra trước và sau triển khai VCSA trong môi trường production thực tế.

Trước khi Deploy

Sau khi Deploy

6. Governance — Naming Convention & Change Management

Đặt convention nhất quán từ đầu — thay đổi sau rất tốn công sức khi có 100+ VMs.

### NAMING CONVENTION chuẩn doanh nghiệp

# vCenter / VCSA:
  vcsa-[site]-[env].hoatranlab.io.local
  vcsa-hn-prod.hoatranlab.io.local
  vcsa-hcm-prod.hoatranlab.io.local

# Datacenter:
  DC-[Thành phố]-[Số]
  DC-HaNoi-01, DC-HoChiMinh-01

# Cluster:
  CL-[Site]-[Tier]-[Số]
  CL-HN-Prod-01, CL-HN-Dev-01

# ESXi Hosts:
  esxi-[site]-[rack]-[số].hoatranlab.io.local
  esxi-hn-r01-01.hoatranlab.io.local

# VM:
  [Prefix]-[App]-[Env]-[Số]
  LNXWEB-PORTAL-PRD-01   (Linux Web, Portal app, Production)
  WINDB-ERP-PRD-01        (Windows DB, ERP app, Production)
  LNXAPP-CRM-DEV-01       (Linux App, CRM, Development)

# Resource Pool:
  RP-[Tier]-[Đặc tả]
  RP-PROD-Critical, RP-PROD-Standard, RP-DEV-Shared

### CHANGE MANAGEMENT (tích hợp ServiceNow):
  - Mọi thay đổi cấu hình vCenter → tạo Change Request
  - Phân loại: Standard (pre-approved) / Normal / Emergency
  - Ghi lại: Who / What / When / Why / Rollback plan
  - Ví dụ Standard Change: Thêm VM folder, gán permission
  - Ví dụ Normal Change: Thêm host vào cluster, thay đổi RBAC scope

Audit Events quan trọng cần monitor trong SIEM

  • User login / logout vCenter
  • Failed login attempts (>3 lần)
  • Permission changes (add/remove)
  • Role creation / modification
  • VM power off / delete operations
  • Host disconnected / removed
  • vCenter configuration changes
  • SSH access từ IP bất thường
### Cấu hình Syslog từ vCenter → SIEM (Splunk/ELK)
# VAMI (port 5480) → Syslog → New Forwarding Configuration
# Protocol: UDP / TCP / TLS
# Host: siem.hoatranlab.io.local
# Port: 514 (UDP) hoặc 6514 (TLS)
# Tất cả events từ vCenter sẽ được forward real-time