Skip to content

Commit

Permalink
Merge pull request #174 from kahun/feature/azure_custom_infra
Browse files Browse the repository at this point in the history
[EOS-11529] Support infra custom
  • Loading branch information
kahun authored Jun 23, 2023
2 parents 6846ffe + b73a03e commit a20103d
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,27 @@ spec:
location: "{{ .Descriptor.Region }}"
sku:
tier: "{{ .Descriptor.ControlPlane.Azure.Tier }}"
resourceGroupName: "{{ .Descriptor.ClusterID }}"
nodeResourceGroupName: "{{ .Descriptor.ClusterID }}-nodes"
resourceGroupName: {{ .Descriptor.ClusterID }}
nodeResourceGroupName: {{ .Descriptor.ClusterID }}-nodes
networkPolicy: calico
sshPublicKey: \"\"
subscriptionID: "{{ .Credentials.SubscriptionID }}"
version: "{{ .Descriptor.K8SVersion }}"
{{- if and (ne .Descriptor.Networks.VPCID "") (ne .Descriptor.Networks.VPCCidrBlock "" ) }}
virtualNetwork:
name: {{ .Descriptor.Networks.VPCID }}
cidrBlock: {{ .Descriptor.Networks.VPCCidrBlock }}
{{- if ne .Descriptor.Networks.ResourceGroup "" }}
resourceGroup: {{ .Descriptor.Networks.ResourceGroup }}
{{- end }}
{{- if gt (len .Descriptor.Networks.Subnets) 0 }}
subnet:
{{- with (index .Descriptor.Networks.Subnets 0) }}
name: {{ .SubnetId }}
cidrBlock: {{ .CidrBlock }}
{{- end }}
{{- end }}
{{- end }}
---
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
kind: AzureClusterIdentity
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,25 @@ spec:
name: "{{ .Descriptor.ClusterID }}-identity"
location: "{{ .Descriptor.Region }}"
networkSpec:
vnet:
name: {{ if ne .Descriptor.Networks.VPCID "" }}{{ .Descriptor.Networks.VPCID }}{{ else }}{{ .Descriptor.ClusterID }}-vnet{{- end }}
{{- if ne .Descriptor.Networks.ResourceGroup "" }}
resourceGroup: {{ .Descriptor.Networks.ResourceGroup }}
{{- end }}
subnets:
{{- if gt (len .Descriptor.Networks.Subnets) 0 }}
{{- range .Descriptor.Networks.Subnets }}
- name: {{ .SubnetId }}
role: {{ .Role }}
{{- end }}
{{- else }}
- name: control-plane-subnet
role: control-plane
- name: node-subnet
role: node
vnet:
name: "{{ .Descriptor.ClusterID }}-vnet"
resourceGroup: "{{ .Descriptor.ClusterID }}"
subscriptionID: "{{ .Credentials.SubscriptionID }}"
{{- end }}
resourceGroup: {{ .Descriptor.ClusterID }}
subscriptionID: {{ .Credentials.SubscriptionID }}
---
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
kind: AzureClusterIdentity
Expand Down
8 changes: 6 additions & 2 deletions pkg/commons/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,18 +90,22 @@ type DescriptorFile struct {
} `yaml:"control_plane"`

StorageClass StorageClass `yaml:storageclass`
WorkerNodes WorkerNodes `yaml:"worker_nodes" validate:"required,dive"`
WorkerNodes WorkerNodes `yaml:"worker_nodes" validate:"required,dive"`
}

type Networks struct {
VPCID string `yaml:"vpc_id"`
VPCCidrBlock string `yaml:"vpc_cidr" validate:"omitempty,cidrv4"`
PodsCidrBlock string `yaml:"pods_cidr" validate:"omitempty,cidrv4"`
PodsSubnets []Subnets `yaml:"pods_subnets"`
Subnets []Subnets `yaml:"subnets"`
ResourceGroup string `yaml:"resource_group"`
}

type Subnets struct {
SubnetId string `yaml:"subnet_id"`
SubnetId string `yaml:"subnet_id"`
CidrBlock string `yaml:"cidr" validate:"omitempty,cidrv4"`
Role string `yaml:"role" validate:"oneof='control-plane' 'node'"`
}

type AWSCP struct {
Expand Down

0 comments on commit a20103d

Please sign in to comment.