Skip to content

Commit 34a5483

Browse files
committed
docs: add creation of virtual machine
1 parent cbb0d66 commit 34a5483

File tree

8 files changed

+205
-54
lines changed

8 files changed

+205
-54
lines changed

terraform/vmo-cluster/cluster_profiles.tf

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,41 +16,41 @@ resource "spectrocloud_cluster_profile" "maas-vmo-profile" {
1616
name = data.spectrocloud_pack.maas_ubuntu.name
1717
tag = data.spectrocloud_pack.maas_ubuntu.version
1818
uid = data.spectrocloud_pack.maas_ubuntu.id
19-
values = file("manifests/ubuntu-values.yaml")
19+
values = file("manifests/ubuntu-values.yaml")
2020
type = "spectro"
2121
}
2222

2323
pack {
2424
name = data.spectrocloud_pack.maas_k8s.name
2525
tag = data.spectrocloud_pack.maas_k8s.version
2626
uid = data.spectrocloud_pack.maas_k8s.id
27-
values = file("manifests/k8s-values.yaml")
27+
values = file("manifests/k8s-values.yaml")
2828
type = "spectro"
2929
}
3030

3131
pack {
3232
name = data.spectrocloud_pack.maas_cni.name
3333
tag = data.spectrocloud_pack.maas_cni.version
3434
uid = data.spectrocloud_pack.maas_cni.id
35-
values = file("manifests/cni-values.yaml")
35+
values = file("manifests/cni-values.yaml")
3636
type = "spectro"
3737
}
3838

3939
pack {
40-
name = data.spectrocloud_pack.maas_csi.name
41-
tag = data.spectrocloud_pack.maas_csi.version
42-
uid = data.spectrocloud_pack.maas_csi.id
43-
values = templatefile("manifests/csi-values.yaml", {
44-
worker_nodes = var.maas-worker-nodes,
40+
name = data.spectrocloud_pack.maas_csi.name
41+
tag = data.spectrocloud_pack.maas_csi.version
42+
uid = data.spectrocloud_pack.maas_csi.id
43+
values = templatefile("manifests/csi-values.yaml", {
44+
worker_nodes = var.maas-worker-nodes,
4545
})
46-
type = "spectro"
46+
type = "spectro"
4747
}
4848

4949
pack {
5050
name = data.spectrocloud_pack.maas_vmo.name
5151
tag = data.spectrocloud_pack.maas_vmo.version
5252
uid = data.spectrocloud_pack.maas_vmo.id
53-
values = file("manifests/vmo-values.yaml")
53+
values = file("manifests/vmo-values.yaml")
5454
type = "spectro"
5555
}
5656

terraform/vmo-cluster/clusters.tf

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,12 @@
66
################
77

88
resource "spectrocloud_cluster_maas" "cluster" {
9-
count = var.deploy-maas ? 1 : 0
9+
count = var.deploy-maas ? 1 : 0
1010

11-
name = "vmo-cluster-maas"
12-
tags = concat(var.tags, ["env:maas"])
13-
cloud_account_id = data.spectrocloud_cloudaccount_maas.account[0].id
11+
name = "vmo-cluster-maas"
12+
tags = concat(var.tags, ["env:maas"])
13+
cloud_account_id = data.spectrocloud_cloudaccount_maas.account[0].id
14+
pause_agent_upgrades = "unlock"
1415

1516
cloud_config {
1617
domain = var.maas-domain
@@ -21,28 +22,28 @@ resource "spectrocloud_cluster_maas" "cluster" {
2122
}
2223

2324
machine_pool {
24-
name = "maas-control-plane"
25-
count = 1
26-
control_plane = true
27-
azs = var.maas-control-plane-azs
28-
node_tags = var.maas-control-plane-node-tags
25+
name = "maas-control-plane"
26+
count = 1
27+
control_plane = true
28+
azs = var.maas-control-plane-azs
29+
node_tags = var.maas-control-plane-node-tags
2930
instance_type {
30-
min_cpu = 8
31-
min_memory_mb = 16000
31+
min_cpu = 8
32+
min_memory_mb = 16000
3233
}
3334
placement {
3435
resource_pool = var.maas-control-plane-resource-pool
3536
}
3637
}
3738

3839
machine_pool {
39-
name = "maas-worker-basic"
40-
count = 1
41-
azs = var.maas-worker-azs
40+
name = "maas-worker-basic"
41+
count = 1
42+
azs = var.maas-worker-azs
4243
node_tags = var.maas-worker-node-tags
4344
instance_type {
44-
min_cpu = 8
45-
min_memory_mb = 32000
45+
min_cpu = 8
46+
min_memory_mb = 32000
4647
}
4748
placement {
4849
resource_pool = var.maas-worker-resource-pool

terraform/vmo-cluster/data.tf

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ data "spectrocloud_pack" "maas_ubuntu" {
2929

3030
data "spectrocloud_pack" "maas_k8s" {
3131
name = "kubernetes"
32-
version = "1.28.3"
32+
version = "1.30.6"
3333
registry_uid = data.spectrocloud_registry.public_registry.id
3434
}
3535

@@ -51,3 +51,9 @@ data "spectrocloud_pack" "maas_vmo" {
5151
registry_uid = data.spectrocloud_registry.public_registry.id
5252
}
5353

54+
data "spectrocloud_cluster" "maas_vmo_cluster" {
55+
depends_on = [spectrocloud_cluster_maas.cluster]
56+
name = "vmo-cluster-maas"
57+
context = "project"
58+
}
59+

terraform/vmo-cluster/inputs.tf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,11 @@ variable "deploy-maas" {
4141
description = "A flag for enabling a deployment on MaaS."
4242
}
4343

44+
variable "deploy-maas-vm" {
45+
type = bool
46+
description = "A flag for enabling a VM creation on the MaaS cluster."
47+
}
48+
4449
variable "pcg-name" {
4550
type = string
4651
description = "The name of the PCG that will be used to deploy the cluster."

terraform/vmo-cluster/manifests/k8s-values.yaml

Lines changed: 26 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
pack:
22
k8sHardening: True
3+
content:
4+
images:
5+
- image: registry.k8s.io/coredns/coredns:v1.11.3
6+
- image: registry.k8s.io/etcd:3.5.15-0
7+
- image: registry.k8s.io/kube-apiserver:v1.30.6
8+
- image: registry.k8s.io/kube-controller-manager:v1.30.6
9+
- image: registry.k8s.io/kube-proxy:v1.30.6
10+
- image: registry.k8s.io/kube-scheduler:v1.30.6
11+
- image: registry.k8s.io/pause:3.9
12+
- image: registry.k8s.io/pause:3.8
313
#CIDR Range for Pods in cluster
414
# Note : This must not overlap with any of the host or service network
515
podCIDR: "100.64.0.0/18"
@@ -10,9 +20,6 @@ pack:
1020
config:
1121
dashboard:
1222
identityProvider: palette
13-
# serviceDomain: "cluster.local"
14-
15-
# KubeAdm customization for kubernetes hardening. Below config will be ignored if k8sHardening property above is disabled
1623
kubeadmconfig:
1724
apiServer:
1825
extraArgs:
@@ -31,6 +38,7 @@ kubeadmconfig:
3138
audit-log-maxbackup: "10"
3239
audit-log-maxsize: "100"
3340
authorization-mode: RBAC,Node
41+
kubelet-certificate-authority: "/etc/kubernetes/pki/ca.crt"
3442
tls-cipher-suites: "TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256,TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256,TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305,TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384,TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305,TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384,TLS_RSA_WITH_AES_256_GCM_SHA384,TLS_RSA_WITH_AES_128_GCM_SHA256"
3543
extraVolumes:
3644
- name: audit-log
@@ -85,31 +93,33 @@ kubeadmconfig:
8593
kind: PodSecurityConfiguration
8694
defaults:
8795
enforce: "baseline"
88-
enforce-version: "v1.28"
96+
enforce-version: "v1.30"
8997
audit: "baseline"
90-
audit-version: "v1.28"
98+
audit-version: "v1.30"
9199
warn: "restricted"
92-
warn-version: "v1.28"
100+
warn-version: "v1.30"
93101
audit: "restricted"
94-
audit-version: "v1.28"
102+
audit-version: "v1.30"
95103
exemptions:
96104
# Array of authenticated usernames to exempt.
97105
usernames: []
98106
# Array of runtime class names to exempt.
99107
runtimeClasses: []
100108
# Array of namespaces to exempt.
101-
namespaces: [kube-system,monitoring,rook-ceph]
109+
namespaces: [kube-system]
102110
103111
preKubeadmCommands:
104112
# For enabling 'protect-kernel-defaults' flag to kubelet, kernel parameters changes are required
105113
- 'echo "====> Applying kernel parameters for Kubelet"'
106114
- 'sysctl -p /etc/sysctl.d/90-kubelet.conf'
107-
#postKubeadmCommands:
108-
#- 'echo "List of post kubeadm commands to be executed"'
115+
116+
postKubeadmCommands:
117+
- 'chmod 600 /var/lib/kubelet/config.yaml'
118+
# - 'echo "List of post kubeadm commands to be executed"'
109119

110-
# Client configuration to add OIDC based authentication flags in kubeconfig
111-
#clientConfig:
112-
#oidc-issuer-url: "{{ .spectro.pack.kubernetes.kubeadmconfig.apiServer.extraArgs.oidc-issuer-url }}"
113-
#oidc-client-id: "{{ .spectro.pack.kubernetes.kubeadmconfig.apiServer.extraArgs.oidc-client-id }}"
114-
#oidc-client-secret: 1gsranjjmdgahm10j8r6m47ejokm9kafvcbhi3d48jlc3rfpprhv
115-
#oidc-extra-scope: profile,email
120+
# Client configuration to add OIDC based authentication flags in kubeconfig
121+
#clientConfig:
122+
#oidc-issuer-url: "{{ .spectro.pack.kubernetes.kubeadmconfig.apiServer.extraArgs.oidc-issuer-url }}"
123+
#oidc-client-id: "{{ .spectro.pack.kubernetes.kubeadmconfig.apiServer.extraArgs.oidc-client-id }}"
124+
#oidc-client-secret: 1gsranjjmdgahm10j8r6m47ejokm9kafvcbhi3d48jlc3rfpprhv
125+
#oidc-extra-scope: profile,email

terraform/vmo-cluster/terraform.tfvars

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,18 @@ palette-project = "Default" # The name of your project in Palette.
99
############################
1010
# MaaS Deployment Settings
1111
############################
12-
deploy-maas = true # Set to true to deploy to MaaS.
12+
deploy-maas = false # Set to true to deploy to MaaS.
13+
deploy-maas-vm = false # Set to true to create a VM on MaaS cluster once deployed.
1314

14-
pcg-name = "vmo-tutorial" # Provide the name of the PCG that will be used to deploy the Palette cluster.
15-
maas-domain = "maas.sc" # Provide the MaaS domain that will be used to deploy the Palette cluster.
15+
pcg-name = "REPLACE ME" # Provide the name of the PCG that will be used to deploy the Palette cluster.
16+
maas-domain = "REPLACE ME" # Provide the MaaS domain that will be used to deploy the Palette cluster.
1617

17-
maas-worker-nodes = 1 # Provide the number of worker nodes that will be used for Palette cluster.
18-
maas-worker-resource-pool = "vm-migration" # Provide a resource pool for the worker nodes.
19-
maas-worker-azs = ["az3"] # Provide a set of availability zones for the worker nodes.
20-
maas-worker-node-tags = ["docs"] # Provide a set of node tags for the worker nodes.
18+
maas-worker-nodes = 1 # Provide the number of worker nodes that will be used for Palette cluster.
19+
maas-worker-resource-pool = "REPLACE ME" # Provide a resource pool for the worker nodes.
20+
maas-worker-azs = ["REPLACE ME"] # Provide a set of availability zones for the worker nodes.
21+
maas-worker-node-tags = ["REPLACE ME"] # Provide a set of node tags for the worker nodes.
2122

22-
maas-control-plane-nodes = 1 # Provide the number of control plane nodes that will be used for Palette cluster.
23-
maas-control-plane-resource-pool = "picard-demo" # Provide a resource pool for the control plane nodes.
24-
maas-control-plane-azs = ["az3"] # Provide a set of availability zones for the control plane nodes.
25-
maas-control-plane-node-tags = ["docs-cp"] # Provide a set of node tags for the control plane nodes.
23+
maas-control-plane-nodes = 1 # Provide the number of control plane nodes that will be used for Palette cluster.
24+
maas-control-plane-resource-pool = "REPLACE ME" # Provide a resource pool for the control plane nodes.
25+
maas-control-plane-azs = ["REPLACE ME"] # Provide a set of availability zones for the control plane nodes.
26+
maas-control-plane-node-tags = ["REPLACE ME"] # Provide a set of node tags for the control plane nodes.
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#cloud-config
2+
ssh_pwauth: True
3+
chpasswd: { expire: False }
4+
password: spectro
5+
disable_root: false
6+
runcmd:
7+
- apt-get update
8+
- apt-get install -y qemu-guest-agent
9+
- systemctl start qemu-guest-agent
10+
- |
11+
apt-get -y install ca-certificates curl
12+
install -m 0755 -d /etc/apt/keyrings
13+
curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc
14+
chmod a+r /etc/apt/keyrings/docker.asc
15+
echo \
16+
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu \
17+
$(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \
18+
tee /etc/apt/sources.list.d/docker.list > /dev/null
19+
apt-get update
20+
apt-get install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
21+
groupadd docker
22+
gpasswd -a ubuntu docker
Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
2+
##########################
3+
# MaaS Virtual Machine
4+
##########################
5+
resource "spectrocloud_virtual_machine" "virtual-machine" {
6+
count = var.deploy-maas-vm ? 1 : 0
7+
depends_on = [spectrocloud_cluster_maas.cluster]
8+
9+
cluster_uid = data.spectrocloud_cluster.maas_vmo_cluster.id
10+
cluster_context = data.spectrocloud_cluster.maas_vmo_cluster.context
11+
12+
run_on_launch = true
13+
namespace = "default"
14+
name = "ubuntu-tutorial-vm"
15+
16+
timeouts {
17+
create = "60m"
18+
}
19+
20+
labels = {
21+
"tf" = "spectrocloud-tutorials"
22+
"kubevirt.io/vm" = "ubuntu-tutorial-vm"
23+
}
24+
25+
data_volume_templates {
26+
metadata {
27+
name = "ubuntu-tutorial-vm"
28+
}
29+
spec {
30+
source {
31+
pvc {
32+
name = "template-ubuntu-2204"
33+
namespace = "vmo-golden-images"
34+
}
35+
}
36+
pvc {
37+
access_modes = ["ReadWriteMany"]
38+
resources {
39+
requests = {
40+
storage = "50Gi"
41+
}
42+
}
43+
storage_class_name = "ceph-block"
44+
volume_mode = "Block"
45+
}
46+
}
47+
}
48+
49+
volume {
50+
name = "ubuntu-tutorial-vm"
51+
volume_source {
52+
data_volume {
53+
name = "ubuntu-tutorial-vm"
54+
}
55+
}
56+
}
57+
58+
volume {
59+
name = "cloudinitdisk"
60+
volume_source {
61+
cloud_init_no_cloud {
62+
user_data = file("virtual-machines/cloud-init")
63+
}
64+
}
65+
}
66+
67+
disk {
68+
name = "ubuntu-tutorial-vm"
69+
disk_device {
70+
disk {
71+
bus = "virtio"
72+
}
73+
}
74+
}
75+
disk {
76+
name = "cloudinitdisk"
77+
disk_device {
78+
disk {
79+
bus = "virtio"
80+
}
81+
}
82+
}
83+
84+
cpu {
85+
cores = 2
86+
sockets = 1
87+
threads = 1
88+
}
89+
memory {
90+
guest = "4Gi"
91+
}
92+
93+
resources {}
94+
95+
interface {
96+
name = "default"
97+
interface_binding_method = "InterfaceMasquerade"
98+
}
99+
100+
network {
101+
name = "default"
102+
network_source {
103+
pod {}
104+
}
105+
}
106+
}

0 commit comments

Comments
 (0)