-
Notifications
You must be signed in to change notification settings - Fork 37
Added validations and templates for multiple networks configuration #453
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 6 commits
8a6e4fe
5fe0666
73243b5
4caa565
ff2c11a
a6cbcff
9ade181
40e37e7
3b6b33a
aefdd49
27ac17f
054530e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -31,6 +31,8 @@ | |||||||||||||||||
| "github.com/pkg/errors" | ||||||||||||||||||
| corev1 "k8s.io/api/core/v1" | ||||||||||||||||||
| infrav1 "sigs.k8s.io/cluster-api-provider-cloudstack/api/v1beta3" | ||||||||||||||||||
|
|
||||||||||||||||||
| netpkg "net" | ||||||||||||||||||
| ) | ||||||||||||||||||
|
|
||||||||||||||||||
| type VMIface interface { | ||||||||||||||||||
|
|
@@ -44,7 +46,15 @@ | |||||||||||||||||
| csMachine.Spec.ProviderID = ptr.To(fmt.Sprintf("cloudstack:///%s", vmResponse.Id)) | ||||||||||||||||||
| // InstanceID is later used as required parameter to destroy VM. | ||||||||||||||||||
| csMachine.Spec.InstanceID = ptr.To(vmResponse.Id) | ||||||||||||||||||
| csMachine.Status.Addresses = []corev1.NodeAddress{{Type: corev1.NodeInternalIP, Address: vmResponse.Ipaddress}} | ||||||||||||||||||
| csMachine.Status.Addresses = []corev1.NodeAddress{} | ||||||||||||||||||
|
||||||||||||||||||
| for _, nic := range vmResponse.Nic { | ||||||||||||||||||
| if nic.Ipaddress != "" { | ||||||||||||||||||
| csMachine.Status.Addresses = append(csMachine.Status.Addresses, corev1.NodeAddress{ | ||||||||||||||||||
| Type: corev1.NodeInternalIP, | ||||||||||||||||||
|
Comment on lines
+51
to
+52
|
||||||||||||||||||
| csMachine.Status.Addresses = append(csMachine.Status.Addresses, corev1.NodeAddress{ | |
| Type: corev1.NodeInternalIP, | |
| addressType := corev1.NodeInternalIP // Default to internal IP | |
| if nic.IsPublic { // Assuming `nic.IsPublic` indicates external/public IP | |
| addressType = corev1.NodeExternalIP | |
| } | |
| csMachine.Status.Addresses = append(csMachine.Status.Addresses, corev1.NodeAddress{ | |
| Type: addressType, |
harikrishna-patnala marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
harikrishna-patnala marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
harikrishna-patnala marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,148 @@ | ||
| --- | ||
| apiVersion: cluster.x-k8s.io/v1beta1 | ||
| kind: Cluster | ||
| metadata: | ||
| name: ${CLUSTER_NAME} | ||
| spec: | ||
| clusterNetwork: | ||
| pods: | ||
| cidrBlocks: | ||
| - 192.168.0.0/16 | ||
| serviceDomain: "cluster.local" | ||
| infrastructureRef: | ||
| apiVersion: infrastructure.cluster.x-k8s.io/v1beta3 | ||
| kind: CloudStackCluster | ||
| name: ${CLUSTER_NAME} | ||
| controlPlaneRef: | ||
| kind: KubeadmControlPlane | ||
| apiVersion: controlplane.cluster.x-k8s.io/v1beta1 | ||
| name: ${CLUSTER_NAME}-control-plane | ||
| --- | ||
| apiVersion: infrastructure.cluster.x-k8s.io/v1beta3 | ||
| kind: CloudStackCluster | ||
| metadata: | ||
| name: ${CLUSTER_NAME} | ||
| spec: | ||
| syncWithACS: ${CLOUDSTACK_SYNC_WITH_ACS=false} | ||
| controlPlaneEndpoint: | ||
| host: ${CLUSTER_ENDPOINT_IP} | ||
| port: ${CLUSTER_ENDPOINT_PORT=6443} | ||
| failureDomains: | ||
| - name: ${CLOUDSTACK_FD1_NAME=failure-domain-1} | ||
| acsEndpoint: | ||
| name: ${CLOUDSTACK_FD1_SECRET_NAME=cloudstack-credentials} | ||
| namespace: ${CLOUDSTACK_FD1_SECRET_NAMESPACE=default} | ||
| zone: | ||
| name: ${CLOUDSTACK_ZONE_NAME} | ||
| network: | ||
| name: ${CLOUDSTACK_NETWORK_NAME} | ||
| --- | ||
| kind: KubeadmControlPlane | ||
| apiVersion: controlplane.cluster.x-k8s.io/v1beta1 | ||
| metadata: | ||
| name: "${CLUSTER_NAME}-control-plane" | ||
| spec: | ||
| kubeadmConfigSpec: | ||
| initConfiguration: | ||
| nodeRegistration: | ||
| name: '{{ local_hostname }}' | ||
| kubeletExtraArgs: | ||
| provider-id: "cloudstack:///'{{ ds.meta_data.instance_id }}'" | ||
| joinConfiguration: | ||
| nodeRegistration: | ||
| name: '{{ local_hostname }}' | ||
| kubeletExtraArgs: | ||
| provider-id: "cloudstack:///'{{ ds.meta_data.instance_id }}'" | ||
| preKubeadmCommands: | ||
| - swapoff -a | ||
| machineTemplate: | ||
| infrastructureRef: | ||
| apiVersion: infrastructure.cluster.x-k8s.io/v1beta3 | ||
| kind: CloudStackMachineTemplate | ||
| name: "${CLUSTER_NAME}-control-plane" | ||
| replicas: ${CONTROL_PLANE_MACHINE_COUNT} | ||
| version: ${KUBERNETES_VERSION} | ||
| --- | ||
| apiVersion: infrastructure.cluster.x-k8s.io/v1beta3 | ||
| kind: CloudStackMachineTemplate | ||
| metadata: | ||
| name: ${CLUSTER_NAME}-control-plane | ||
| spec: | ||
| template: | ||
| spec: | ||
| sshKey: ${CLOUDSTACK_SSH_KEY_NAME} | ||
| offering: | ||
| name: ${CLOUDSTACK_CONTROL_PLANE_MACHINE_OFFERING} | ||
| networks: | ||
| - name: ${CLOUDSTACK_NETWORK_NAME} # (optional) default primary network; must match failureDomains.zone.network.name | ||
harikrishna-patnala marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| # ip: 10.1.1.21 # (optional) static IP in the primary network | ||
|
|
||
| # Additional (extra) networks can be specified below. Use either 'name' or 'id', and optionally an 'ip'. | ||
| # - name: isolated-net2 # (optional) extra network by name | ||
| # ip: 10.1.1.31 # (optional) static IP in this network | ||
|
|
||
| # - id: a1b2c3d4-5678-90ef-gh12-3456789ijklm # (optional) extra network by ID | ||
| # ip: 10.1.1.32 # (optional) static IP in this network | ||
| template: | ||
| name: ${CLOUDSTACK_TEMPLATE_NAME} | ||
| --- | ||
| apiVersion: cluster.x-k8s.io/v1beta1 | ||
| kind: MachineDeployment | ||
| metadata: | ||
| name: "${CLUSTER_NAME}-md-0" | ||
| spec: | ||
| clusterName: "${CLUSTER_NAME}" | ||
| replicas: ${WORKER_MACHINE_COUNT} | ||
| selector: | ||
| matchLabels: null | ||
| template: | ||
| spec: | ||
| clusterName: "${CLUSTER_NAME}" | ||
| version: "${KUBERNETES_VERSION}" | ||
| bootstrap: | ||
| configRef: | ||
| name: "${CLUSTER_NAME}-md-0" | ||
| apiVersion: bootstrap.cluster.x-k8s.io/v1beta1 | ||
| kind: KubeadmConfigTemplate | ||
| infrastructureRef: | ||
| name: "${CLUSTER_NAME}-md-0" | ||
| apiVersion: infrastructure.cluster.x-k8s.io/v1beta3 | ||
| kind: CloudStackMachineTemplate | ||
| --- | ||
| apiVersion: infrastructure.cluster.x-k8s.io/v1beta3 | ||
| kind: CloudStackMachineTemplate | ||
| metadata: | ||
| name: ${CLUSTER_NAME}-md-0 | ||
| spec: | ||
| template: | ||
| spec: | ||
| sshKey: ${CLOUDSTACK_SSH_KEY_NAME} | ||
| offering: | ||
| name: ${CLOUDSTACK_WORKER_MACHINE_OFFERING} | ||
| template: | ||
| name: ${CLOUDSTACK_TEMPLATE_NAME} | ||
| networks: | ||
| - name: ${CLOUDSTACK_NETWORK_NAME} # (optional) default primary network; must match failureDomains.zone.network.name | ||
| # ip: 10.1.1.41 # (optional) static IP in the primary network | ||
|
|
||
| # Additional (extra) networks can be specified below. Use either 'name' or 'id', and optionally an 'ip'. | ||
| # - name: isolated-net3 # (optional) extra network by name | ||
| # ip: 10.1.1.51 # (optional) static IP in this network | ||
|
|
||
| # - id: f5c93c15-d27b-4c93-b27c-00f48226b9a9 # (optional) extra network by ID | ||
| # ip: 10.1.1.52 # (optional) static IP in this network | ||
| --- | ||
| apiVersion: bootstrap.cluster.x-k8s.io/v1beta1 | ||
| kind: KubeadmConfigTemplate | ||
| metadata: | ||
| name: ${CLUSTER_NAME}-md-0 | ||
| spec: | ||
| template: | ||
| spec: | ||
| joinConfiguration: | ||
| nodeRegistration: | ||
| name: '{{ local_hostname }}' | ||
| kubeletExtraArgs: | ||
| provider-id: "cloudstack:///'{{ ds.meta_data.instance_id }}'" | ||
| preKubeadmCommands: | ||
| - swapoff -a | ||
Uh oh!
There was an error while loading. Please reload this page.