Skip to content

Commit

Permalink
Merge branch 'master' into removal-of-catalog-v1
Browse files Browse the repository at this point in the history
  • Loading branch information
rohitsakala authored Nov 14, 2024
2 parents 5a25110 + 51db8c5 commit cf19941
Show file tree
Hide file tree
Showing 9 changed files with 57 additions and 8 deletions.
2 changes: 2 additions & 0 deletions docs/resources/cluster.md
Original file line number Diff line number Diff line change
Expand Up @@ -553,6 +553,7 @@ resource "rancher2_cluster" "foo" {
virtual_network_resource_group = "<virtual-network-resource-group>"
subnet = "<subnet>"
node_resource_group = "<node-resource-group>"
outbound_type = "loadBalancer"
node_pools {
availability_zones = ["1", "2", "3"]
name = "<nodepool-name-1>"
Expand Down Expand Up @@ -1550,6 +1551,7 @@ The following arguments are supported just for creating new AKS clusters (`impor
* `network_policy` - (Optional/Computed) The AKS network policy (string)
* `network_service_cidr` - (Optional/Computed) The AKS network service cidr (string)
* `node_resource_group` (Optional/Computed) The AKS node resource group name (string)
* `outbound_type` (Optional/Computed) The AKS outbound type for the egress traffic (string)
* `private_cluster` - (Optional/Computed) Is AKS cluster private? (bool)
* `subnet` - (Optional/Computed) The AKS subnet (string)
* `tags` - (Optional/Computed) The AKS cluster tags (map)
Expand Down
4 changes: 2 additions & 2 deletions docs/resources/node_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ The following attributes are exported:
* `docker_port` - (Optional) Port number for Docker engine. Default `2376` (string)
* `environment` - (Optional) Azure environment (e.g. AzurePublicCloud, AzureChinaCloud). Default `AzurePublicCloud` (string)
* `fault_domain_count` - (Optional) Fault domain count to use for availability set. Default `3` (string)
* `image` - (Optional) Azure virtual machine OS image. Default `canonical:UbuntuServer:18.04-LTS:latest` (string)
* `image` - (Optional) Azure virtual machine OS image. Default `canonical:ubuntu-24_04-lts:server-gen1:latest` (string)
* `location` - (Optional) Azure region to create the virtual machine. Default `westus` (string)
* `managed_disks` - (Optional) Configures VM and availability set for managed disks. For Rancher v2.3.x and above. Default `false` (bool)
* `no_public_ip` - (Optional) Do not create a public IP address for the machine. Default `false` (bool)
Expand All @@ -243,7 +243,7 @@ The following attributes are exported:
* `open_port` - (Optional) Make the specified port number accessible from the Internet. (list)
* `private_ip_address` - (Optional) Specify a static private IP address for the machine. (string)
* `resource_group` - (Optional) Azure Resource Group name (will be created if missing). Default `docker-machine` (string)
* `size` - (Optional) Size for Azure Virtual Machine. Default `Standard_A2` (string)
* `size` - (Optional) Size for Azure Virtual Machine. Default `Standard_D2_v2` (string)
* `ssh_user` - (Optional) Username for SSH login (string)
* `static_public_ip` - (Optional) Assign a static public IP address to the machine. Default `false` (bool)
* `storage_type` - (Optional) Type of Storage Account to host the OS Disk for the machine. Default `Standard_LRS` (string)
Expand Down
15 changes: 12 additions & 3 deletions rancher2/resource_rancher2_catalog_v2.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func resourceRancher2CatalogV2Create(d *schema.ResourceData, meta interface{}) e
d.SetId(clusterID + catalogV2ClusterIDsep + newCatalog.ID)
stateConf := &resource.StateChangeConf{
Pending: []string{},
Target: []string{"downloaded"},
Target: []string{"downloaded", "ociDownloaded"},
Refresh: catalogV2StateRefreshFunc(meta, clusterID, newCatalog.ID),
Timeout: d.Timeout(schema.TimeoutCreate),
Delay: 1 * time.Second,
Expand Down Expand Up @@ -103,7 +103,7 @@ func resourceRancher2CatalogV2Update(d *schema.ResourceData, meta interface{}) e
d.SetId(clusterID + catalogV2ClusterIDsep + newCatalog.ID)
stateConf := &resource.StateChangeConf{
Pending: []string{},
Target: []string{"downloaded"},
Target: []string{"downloaded", "ociDownloaded"},
Refresh: catalogV2StateRefreshFunc(meta, clusterID, newCatalog.ID),
Timeout: d.Timeout(schema.TimeoutCreate),
Delay: 1 * time.Second,
Expand Down Expand Up @@ -169,6 +169,15 @@ func catalogV2StateRefreshFunc(meta interface{}, clusterID, catalogID string) re
}
return nil, "error", fmt.Errorf("%s", obj.Status.Conditions[i].Message)
}
if obj.Status.Conditions[i].Type == string(v1.OCIDownloaded) {
if obj.Status.Conditions[i].Status == "Unknown" {
return obj, "transitioning", nil
}
if obj.Status.Conditions[i].Status == "True" {
return obj, "ociDownloaded", nil
}
return nil, "error", fmt.Errorf("%s", obj.Status.Conditions[i].Message)
}
}
return obj, "transitioning", nil
}
Expand Down Expand Up @@ -317,7 +326,7 @@ func waitCatalogV2Downloaded(c *Config, clusterID, catalogID string) (*ClusterRe
return nil, fmt.Errorf("Getting catalog V2 ID (%s): %v", catalogID, err)
}
for i := range obj.Status.Conditions {
if obj.Status.Conditions[i].Type == string(v1.RepoDownloaded) {
if obj.Status.Conditions[i].Type == string(v1.RepoDownloaded) || obj.Status.Conditions[i].Type == string(v1.OCIDownloaded) {
// Status of the condition, one of True, False, Unknown.
if obj.Status.Conditions[i].Status == "Unknown" {
break
Expand Down
19 changes: 19 additions & 0 deletions rancher2/resource_rancher2_catalog_v2_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@ const testAccRancher2CatalogV2Type = "rancher2_catalog_v2"

var (
testAccRancher2CatalogV2 string
testAccRancher2OCICatalogV2 string
testAccRancher2CatalogV2Update string
testAccRancher2CatalogV2Config string
testAccRancher2OCICatalogV2Config string
testAccRancher2CatalogV2UpdateConfig string
)

Expand All @@ -35,7 +37,16 @@ resource "` + testAccRancher2CatalogV2Type + `" "foo" {
git_branch = "master"
}
`
testAccRancher2OCICatalogV2 = `
resource "` + testAccRancher2CatalogV2Type + `" "foo" {
cluster_id = rancher2_cluster_sync.testacc.cluster_id
name = "foo"
url = "oci://chartproxy.container-registry.com/docs.projectcalico.org/charts"
git_branch = "dev-v2.5"
}
`
testAccRancher2CatalogV2Config = testAccCheckRancher2ClusterSyncTestacc + testAccRancher2CatalogV2
testAccRancher2OCICatalogV2Config = testAccCheckRancher2ClusterSyncTestacc + testAccRancher2OCICatalogV2
testAccRancher2CatalogV2UpdateConfig = testAccCheckRancher2ClusterSyncTestacc + testAccRancher2CatalogV2Update
}

Expand All @@ -47,6 +58,14 @@ func TestAccRancher2CatalogV2_basic(t *testing.T) {
Providers: testAccProviders,
CheckDestroy: testAccCheckRancher2CatalogV2Destroy,
Steps: []resource.TestStep{
{
Config: testAccRancher2OCICatalogV2Config,
Check: resource.ComposeTestCheckFunc(
testAccCheckRancher2CatalogV2Exists(testAccRancher2CatalogV2Type+".foo", catalog),
resource.TestCheckResourceAttr(testAccRancher2CatalogV2Type+".foo", "name", "foo"),
resource.TestCheckResourceAttr(testAccRancher2CatalogV2Type+".foo", "url", "oci://chartproxy.container-registry.com/docs.projectcalico.org/charts"),
),
},
{
Config: testAccRancher2CatalogV2Config,
Check: resource.ComposeTestCheckFunc(
Expand Down
12 changes: 12 additions & 0 deletions rancher2/schema_cluster_aks_config_v2.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,18 @@ package rancher2

import (
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/helper/validation"
)

const (
clusterAKSV2Kind = "aksV2"
clusterDriverAKSV2 = "AKS"
)

var (
clusterAKSOutboundType = []string{"loadbalancer", "managednatgateway", "userassignednatgateway", "userdefinedrouting"}
)

//Schemas

func clusterAKSConfigV2NodePoolsFields() map[string]*schema.Schema {
Expand Down Expand Up @@ -263,6 +268,13 @@ func clusterAKSConfigV2Fields() map[string]*schema.Schema {
Computed: true,
Description: "The AKS node resource group name",
},
"outboung_type": {
Type: schema.TypeString,
Optional: true,
Default: "loadBalancer",
Description: "The AKS outbound type for the egress traffic",
ValidateFunc: validation.StringInSlice(clusterAKSOutboundType, true),
},
"private_cluster": {
Type: schema.TypeBool,
Optional: true,
Expand Down
1 change: 0 additions & 1 deletion rancher2/schema_cluster_v2_rke_config_files.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ func clusterV2RKEConfigKeyToPathFields() map[string]*schema.Schema {
"dynamic": {
Type: schema.TypeBool,
Optional: true,
Default: true,
Description: "If ture, the file is ignored when determining whether the node should be drained before updating the node plan (default: true).",
},
"permissions": {
Expand Down
4 changes: 2 additions & 2 deletions rancher2/schema_node_template_azure.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ func azureConfigFields() map[string]*schema.Schema {
"image": {
Type: schema.TypeString,
Optional: true,
Default: "canonical:UbuntuServer:18.04-LTS:latest",
Default: "canonical:ubuntu-24_04-lts:server-gen1:latest",
Description: "Azure virtual machine OS image",
},
"location": {
Expand Down Expand Up @@ -158,7 +158,7 @@ func azureConfigFields() map[string]*schema.Schema {
"size": {
Type: schema.TypeString,
Optional: true,
Default: "Standard_A2",
Default: "Standard_D2_v2",
Description: "Size for Azure Virtual Machine",
},
"ssh_user": {
Expand Down
6 changes: 6 additions & 0 deletions rancher2/structure_cluster_aks_config_v2.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,9 @@ func flattenClusterAKSConfigV2(in *managementClient.AKSClusterConfigSpec, p []in
if in.NodeResourceGroup != nil && len(*in.NodeResourceGroup) > 0 {
obj["node_resource_group"] = *in.NodeResourceGroup
}
if in.OutboundType != nil && len(*in.OutboundType) > 0 {
obj["outbound_type"] = *in.OutboundType
}
if in.PrivateCluster != nil {
obj["private_cluster"] = *in.PrivateCluster
}
Expand Down Expand Up @@ -352,6 +355,9 @@ func expandClusterAKSConfigV2(p []interface{}) *managementClient.AKSClusterConfi
if v, ok := in["node_resource_group"].(string); ok && len(v) > 0 {
obj.NodeResourceGroup = &v
}
if v, ok := in["outbound_type"].(string); ok && len(v) > 0 {
obj.OutboundType = &v
}
if v, ok := in["subnet"].(string); ok && len(v) > 0 {
obj.Subnet = &v
}
Expand Down
2 changes: 2 additions & 0 deletions rancher2/structure_cluster_aks_config_v2_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ func init() {
NetworkServiceCIDR: newString("network_service_cidr"),
NodePools: testClusterAKSConfigV2NodePoolConf,
NodeResourceGroup: newString("node_resource_group"),
OutboundType: newString("loadBalancer"),
PrivateCluster: newTrue(),
ResourceGroup: "resource_group",
ResourceLocation: "resource_location",
Expand Down Expand Up @@ -122,6 +123,7 @@ func init() {
"network_service_cidr": "network_service_cidr",
"node_pools": testClusterAKSConfigV2NodePoolInterface,
"node_resource_group": "node_resource_group",
"outbound_type": "loadBalancer",
"private_cluster": true,
"resource_group": "resource_group",
"resource_location": "resource_location",
Expand Down

0 comments on commit cf19941

Please sign in to comment.