Skip to content

Commit

Permalink
Add support to latest gardner shoot apis (kyma-project#364)
Browse files Browse the repository at this point in the history
* Add support to latest gardner shoot apis

 - Add support to latest core/v1beta1 apis
 - Added additional parameters

* Add support for service endpoints in Azure
  • Loading branch information
rakesh-garimella authored Feb 12, 2020
1 parent 6a4ad8c commit 5251eba
Show file tree
Hide file tree
Showing 22 changed files with 115 additions and 72 deletions.
30 changes: 22 additions & 8 deletions cmd/kyma/provision/gardener/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,22 @@ Use the following instructions to create a service account for a selected provid
cmd.Flags().StringVarP(&o.Region, "region", "r", "europe-west3", "Region of the cluster.")
cmd.Flags().StringVarP(&o.Zone, "zone", "z", "europe-west3-a", "Zone of the cluster.")
cmd.Flags().StringVarP(&o.MachineType, "type", "t", "n1-standard-4", "Machine type used for the cluster.")
cmd.Flags().StringVar(&o.CIDR, "cidr", "10.250.0.0/19", "Gardener Classless Inter-Domain Routing (CIDR) used for the cluster.")
cmd.Flags().StringVar(&o.CIDR, "cidr", "10.250.0.0/16", "Gardener Classless Inter-Domain Routing (CIDR) used for the cluster.")
cmd.Flags().StringVar(&o.DiskType, "disk-type", "pd-standard", "Type of disk to use on the target provider.")
cmd.Flags().StringVar(&o.WCIDR, "workercidr", "10.250.0.0/19", "Specifies Gardener Classless Inter-Domain Routing (CIDR) of the workers of the cluster.")
cmd.Flags().StringVar(&o.WCIDR, "workercidr", "10.250.0.0/16", "Specifies Gardener Classless Inter-Domain Routing (CIDR) of the workers of the cluster.")
cmd.Flags().IntVar(&o.DiskSizeGB, "disk-size", 30, "Disk size (in GB) of the cluster.")
cmd.Flags().IntVar(&o.NodeCount, "nodes", 3, "Number of cluster nodes.")
cmd.Flags().IntVar(&o.ScalerMin, "scaler-min", 2, "Minimum autoscale value of the cluster.")
cmd.Flags().IntVar(&o.ScalerMax, "scaler-max", 4, "Maximum autoscale value of the cluster.")
cmd.Flags().IntVar(&o.Surge, "surge", 4, "Maximum surge of the cluster.")
cmd.Flags().IntVarP(&o.Unavailable, "unavailable", "u", 1, "Maximum allowed number of unavailable nodes.")
cmd.Flags().StringVar(&o.NetworkType, "network-type", "calico", "Network type to be used.")
cmd.Flags().StringVar(&o.NetworkNodes, "network-nodes", "10.250.0.0/16", "CIDR of the entire node network.")
cmd.Flags().StringVar(&o.NetworkPods, "network-pods", "100.96.0.0/11", "Network type to be used.")
cmd.Flags().StringVar(&o.NetworkServices, "network-services", "100.64.0.0/13", "CIDR of the service network.")
cmd.Flags().StringVar(&o.MachineImageName, "machine-image-name", "coreos", "Version of the shoot's machine image name in any environment.")
cmd.Flags().StringVar(&o.MachineImageVersion, "machine-image-version", "2303.3.0", "Version of the shoot's machine image version in any environment.")
cmd.Flags().StringSliceVar(&o.ServiceEndpoints, "service-endpoints", nil, "list of Azure ServiceEndpoints which should be associated with the worker subnet. eg. --service-endpoints=\"az1,az2\"")
cmd.Flags().StringSliceVarP(&o.Extra, "extra", "e", nil, "One or more arguments provided as the `NAME=VALUE` key-value pairs to configure additional cluster settings. You can use this flag multiple times or enter the key-value pairs as a comma-separated list.")

return cmd
Expand Down Expand Up @@ -141,14 +148,21 @@ func newProvider(o *Options) (*types.Provider, error) {
p.CustomConfigurations["target_secret"] = o.Secret
}
p.CustomConfigurations["target_provider"] = o.TargetProvider
p.CustomConfigurations["zone"] = o.Zone
p.CustomConfigurations["disk_type"] = o.DiskType
p.CustomConfigurations["autoscaler_min"] = o.ScalerMin
p.CustomConfigurations["autoscaler_max"] = o.ScalerMax
p.CustomConfigurations["max_surge"] = o.Surge
p.CustomConfigurations["max_unavailable"] = o.Unavailable
p.CustomConfigurations["cidr"] = o.CIDR
p.CustomConfigurations["worker_minimum"] = o.ScalerMin
p.CustomConfigurations["worker_maximum"] = o.ScalerMax
p.CustomConfigurations["worker_max_surge"] = o.Surge
p.CustomConfigurations["worker_max_unavailable"] = o.Unavailable
p.CustomConfigurations["vnetcidr"] = o.CIDR
p.CustomConfigurations["workercidr"] = o.WCIDR
p.CustomConfigurations["networking_nodes"] = o.NetworkNodes
p.CustomConfigurations["networking_pods"] = o.NetworkPods
p.CustomConfigurations["networking_services"] = o.NetworkServices
p.CustomConfigurations["networking_type"] = o.NetworkType
p.CustomConfigurations["machine_image_name"] = o.MachineImageName
p.CustomConfigurations["machine_image_version"] = o.MachineImageVersion
p.CustomConfigurations["service_endpoints"] = o.ServiceEndpoints
p.CustomConfigurations["zone"] = o.Zone

for _, e := range o.Extra {
v := strings.Split(e, "=")
Expand Down
20 changes: 14 additions & 6 deletions cmd/kyma/provision/gardener/cmd_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func TestProvisionGardenerFlags(t *testing.T) {
require.Equal(t, 4, o.ScalerMax, "Default value for the scaler-max flag not as expected.")
require.Equal(t, 4, o.Surge, "Default value for the surge flag not as expected.")
require.Equal(t, 1, o.Unavailable, "Default value for the unavailable flag not as expected.")
require.Equal(t, "10.250.0.0/19", o.CIDR, "Default value for the cidr flag not as expected.")
require.Equal(t, "10.250.0.0/16", o.CIDR, "Default value for the cidr flag not as expected.")
require.Empty(t, o.Extra, "Default value for the extra flag not as expected.")

// test passing flags
Expand Down Expand Up @@ -135,11 +135,19 @@ func TestNewProvider(t *testing.T) {
custom["target_provider"] = o.TargetProvider
custom["zone"] = o.Zone
custom["disk_type"] = o.DiskType
custom["autoscaler_min"] = o.ScalerMin
custom["autoscaler_max"] = o.ScalerMax
custom["max_surge"] = o.Surge
custom["max_unavailable"] = o.Unavailable
custom["cidr"] = o.CIDR
custom["worker_minimum"] = o.ScalerMin
custom["worker_maximum"] = o.ScalerMax
custom["worker_max_surge"] = o.Surge
custom["worker_max_unavailable"] = o.Unavailable
custom["vnetcidr"] = o.CIDR
custom["workercidr"] = o.WCIDR
custom["networking_nodes"] = o.NetworkNodes
custom["networking_pods"] = o.NetworkPods
custom["networking_services"] = o.NetworkServices
custom["networking_type"] = o.NetworkType
custom["machine_image_name"] = o.MachineImageName
custom["machine_image_version"] = o.MachineImageVersion
custom["service_endpoints"] = o.ServiceEndpoints

require.Equal(t, custom, p.CustomConfigurations, "Provider extra configurations not as expected.")
}
45 changes: 26 additions & 19 deletions cmd/kyma/provision/gardener/opts.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,32 @@ import "github.com/kyma-project/cli/internal/cli"
type Options struct {
*cli.Options

Name string
Project string
CredentialsFile string
TargetProvider string
Secret string
KubernetesVersion string
Region string
Zone string
MachineType string
CIDR string
WCIDR string
DiskType string
DiskSizeGB int
NodeCount int
ScalerMin int
ScalerMax int
Surge int
Unavailable int
Extra []string
Name string
Project string
CredentialsFile string
TargetProvider string
Secret string
KubernetesVersion string
Region string
Zone string
MachineType string
CIDR string
WCIDR string
DiskType string
DiskSizeGB int
NodeCount int
ScalerMin int
ScalerMax int
Surge int
Unavailable int
Extra []string
NetworkType string
NetworkNodes string
NetworkPods string
NetworkServices string
MachineImageName string
MachineImageVersion string
ServiceEndpoints []string
}

//NewOptions creates options with default values
Expand Down
2 changes: 1 addition & 1 deletion docs/gen-docs/kyma.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@ For more information, see: https://github.com/kyma-project/cli
* [kyma test](kyma_test.md) - Runs tests on a provisioned Kyma cluster.
* [kyma version](kyma_version.md) - Displays the version of Kyma CLI and the connected Kyma cluster.

###### Auto generated by spf13/cobra on 27-Jan-2020
###### Auto generated by spf13/cobra on 12-Feb-2020
2 changes: 1 addition & 1 deletion docs/gen-docs/kyma_completion.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@ kyma completion bash|zsh [flags]

* [kyma](kyma.md) - Controls a Kyma cluster.

###### Auto generated by spf13/cobra on 27-Jan-2020
###### Auto generated by spf13/cobra on 12-Feb-2020
2 changes: 1 addition & 1 deletion docs/gen-docs/kyma_console.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@ kyma console [flags]

* [kyma](kyma.md) - Controls a Kyma cluster.

###### Auto generated by spf13/cobra on 27-Jan-2020
###### Auto generated by spf13/cobra on 12-Feb-2020
2 changes: 1 addition & 1 deletion docs/gen-docs/kyma_install.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,4 +76,4 @@ kyma install [flags]

* [kyma](kyma.md) - Controls a Kyma cluster.

###### Auto generated by spf13/cobra on 27-Jan-2020
###### Auto generated by spf13/cobra on 12-Feb-2020
2 changes: 1 addition & 1 deletion docs/gen-docs/kyma_provision.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ Provisions a cluster for Kyma installation.
* [kyma provision gcp](kyma_provision_gcp.md) - Provisions a Google Kubernetes Engine (GKE) cluster on Google Cloud Platform (GCP).
* [kyma provision minikube](kyma_provision_minikube.md) - Provisions Minikube.

###### Auto generated by spf13/cobra on 27-Jan-2020
###### Auto generated by spf13/cobra on 12-Feb-2020
2 changes: 1 addition & 1 deletion docs/gen-docs/kyma_provision_azure.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,4 @@ kyma provision azure [flags]

* [kyma provision](kyma_provision.md) - Provisions a cluster for Kyma installation.

###### Auto generated by spf13/cobra on 27-Jan-2020
###### Auto generated by spf13/cobra on 12-Feb-2020
47 changes: 27 additions & 20 deletions docs/gen-docs/kyma_provision_gardener.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,25 +18,32 @@ kyma provision gardener [flags]
### Options

```
--cidr string Gardener Classless Inter-Domain Routing (CIDR) used for the cluster. (default "10.250.0.0/19")
-c, --credentials string Path to the kubeconfig file of the Gardener service account for a target provider. (required)
--disk-size int Disk size (in GB) of the cluster. (default 30)
--disk-type string Type of disk to use on the target provider. (default "pd-standard")
-e, --extra NAME=VALUE One or more arguments provided as the NAME=VALUE key-value pairs to configure additional cluster settings. You can use this flag multiple times or enter the key-value pairs as a comma-separated list.
-k, --kube-version string Kubernetes version of the cluster. (default "1.15.4")
-n, --name string Name of the cluster to provision. (required)
--nodes int Number of cluster nodes. (default 3)
-p, --project string Name of the Gardener project where you provision the cluster. (required)
-r, --region string Region of the cluster. (default "europe-west3")
--scaler-max int Maximum autoscale value of the cluster. (default 4)
--scaler-min int Minimum autoscale value of the cluster. (default 2)
-s, --secret string Name of the Gardener secret used to access the target provider. (required)
--surge int Maximum surge of the cluster. (default 4)
--target-provider string Cloud provider that Gardener should use to create the cluster. (default "gcp")
-t, --type string Machine type used for the cluster. (default "n1-standard-4")
-u, --unavailable int Maximum allowed number of unavailable nodes. (default 1)
--workercidr string Specifies Gardener Classless Inter-Domain Routing (CIDR) of the workers of the cluster. (default "10.250.0.0/19")
-z, --zone string Zone of the cluster. (default "europe-west3-a")
--cidr string Gardener Classless Inter-Domain Routing (CIDR) used for the cluster. (default "10.250.0.0/16")
-c, --credentials string Path to the kubeconfig file of the Gardener service account for a target provider. (required)
--disk-size int Disk size (in GB) of the cluster. (default 30)
--disk-type string Type of disk to use on the target provider. (default "pd-standard")
-e, --extra NAME=VALUE One or more arguments provided as the NAME=VALUE key-value pairs to configure additional cluster settings. You can use this flag multiple times or enter the key-value pairs as a comma-separated list.
-k, --kube-version string Kubernetes version of the cluster. (default "1.15.4")
--machine-image-name string Version of the shoot's machine image name in any environment. (default "coreos")
--machine-image-version string Version of the shoot's machine image version in any environment. (default "2303.3.0")
-n, --name string Name of the cluster to provision. (required)
--network-nodes string CIDR of the entire node network. (default "10.250.0.0/16")
--network-pods string Network type to be used. (default "100.96.0.0/11")
--network-services string CIDR of the service network. (default "100.64.0.0/13")
--network-type string Network type to be used. (default "calico")
--nodes int Number of cluster nodes. (default 3)
-p, --project string Name of the Gardener project where you provision the cluster. (required)
-r, --region string Region of the cluster. (default "europe-west3")
--scaler-max int Maximum autoscale value of the cluster. (default 4)
--scaler-min int Minimum autoscale value of the cluster. (default 2)
-s, --secret string Name of the Gardener secret used to access the target provider. (required)
--service-endpoints strings list of Azure ServiceEndpoints which should be associated with the worker subnet. eg. --service-endpoints="az1,az2"
--surge int Maximum surge of the cluster. (default 4)
--target-provider string Cloud provider that Gardener should use to create the cluster. (default "gcp")
-t, --type string Machine type used for the cluster. (default "n1-standard-4")
-u, --unavailable int Maximum allowed number of unavailable nodes. (default 1)
--workercidr string Specifies Gardener Classless Inter-Domain Routing (CIDR) of the workers of the cluster. (default "10.250.0.0/16")
-z, --zone string Zone of the cluster. (default "europe-west3-a")
```

### Options inherited from parent commands
Expand All @@ -52,4 +59,4 @@ kyma provision gardener [flags]

* [kyma provision](kyma_provision.md) - Provisions a cluster for Kyma installation.

###### Auto generated by spf13/cobra on 27-Jan-2020
###### Auto generated by spf13/cobra on 12-Feb-2020
2 changes: 1 addition & 1 deletion docs/gen-docs/kyma_provision_gcp.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,4 @@ kyma provision gcp [flags]

* [kyma provision](kyma_provision.md) - Provisions a cluster for Kyma installation.

###### Auto generated by spf13/cobra on 27-Jan-2020
###### Auto generated by spf13/cobra on 12-Feb-2020
2 changes: 1 addition & 1 deletion docs/gen-docs/kyma_provision_minikube.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,4 @@ kyma provision minikube [flags]

* [kyma provision](kyma_provision.md) - Provisions a cluster for Kyma installation.

###### Auto generated by spf13/cobra on 27-Jan-2020
###### Auto generated by spf13/cobra on 12-Feb-2020
2 changes: 1 addition & 1 deletion docs/gen-docs/kyma_test.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@ Use this command to run tests on a provisioned Kyma cluster.
* [kyma test run](kyma_test_run.md) - Runs tests on a Kyma cluster.
* [kyma test status](kyma_test_status.md) - Shows the status of a test suite and related test executions.

###### Auto generated by spf13/cobra on 27-Jan-2020
###### Auto generated by spf13/cobra on 12-Feb-2020
2 changes: 1 addition & 1 deletion docs/gen-docs/kyma_test_definitions.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ kyma test definitions [flags]

* [kyma test](kyma_test.md) - Runs tests on a provisioned Kyma cluster.

###### Auto generated by spf13/cobra on 27-Jan-2020
###### Auto generated by spf13/cobra on 12-Feb-2020
2 changes: 1 addition & 1 deletion docs/gen-docs/kyma_test_delete.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@ kyma test delete <test-suite-1> <test-suite-2> ... <test-suite-N> [flags]

* [kyma test](kyma_test.md) - Runs tests on a provisioned Kyma cluster.

###### Auto generated by spf13/cobra on 27-Jan-2020
###### Auto generated by spf13/cobra on 12-Feb-2020
2 changes: 1 addition & 1 deletion docs/gen-docs/kyma_test_list.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ kyma test list [flags]

* [kyma test](kyma_test.md) - Runs tests on a provisioned Kyma cluster.

###### Auto generated by spf13/cobra on 27-Jan-2020
###### Auto generated by spf13/cobra on 12-Feb-2020
2 changes: 1 addition & 1 deletion docs/gen-docs/kyma_test_logs.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,4 @@ kyma test logs <test-suite-1> <test-suite-2> ... <test-suite-N> [flags]

* [kyma test](kyma_test.md) - Runs tests on a provisioned Kyma cluster.

###### Auto generated by spf13/cobra on 27-Jan-2020
###### Auto generated by spf13/cobra on 12-Feb-2020
2 changes: 1 addition & 1 deletion docs/gen-docs/kyma_test_run.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,4 @@ kyma test run <test-definition-1> <test-definition-2> ... <test-definition-N> [f

* [kyma test](kyma_test.md) - Runs tests on a provisioned Kyma cluster.

###### Auto generated by spf13/cobra on 27-Jan-2020
###### Auto generated by spf13/cobra on 12-Feb-2020
2 changes: 1 addition & 1 deletion docs/gen-docs/kyma_test_status.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,4 @@ kyma test status <test-suite-1> <test-suite-2> ... <test-suite-N> [flags]

* [kyma test](kyma_test.md) - Runs tests on a provisioned Kyma cluster.

###### Auto generated by spf13/cobra on 27-Jan-2020
###### Auto generated by spf13/cobra on 12-Feb-2020
2 changes: 1 addition & 1 deletion docs/gen-docs/kyma_version.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@ kyma version [flags]

* [kyma](kyma.md) - Controls a Kyma cluster.

###### Auto generated by spf13/cobra on 27-Jan-2020
###### Auto generated by spf13/cobra on 12-Feb-2020
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ require (
github.com/golangplus/fmt v0.0.0-20150411045040-2a5d6d7d2995 // indirect
github.com/golangplus/testing v0.0.0-20180327235837-af21d9c3145e // indirect
github.com/imdario/mergo v0.3.8 // indirect
github.com/kyma-incubator/hydroform/provision v0.0.0-20200124103946-0c148d360a7f
github.com/kyma-incubator/hydroform/provision v0.0.0-20200212105437-dc38025169cb
github.com/kyma-incubator/octopus v0.0.0-20191009105757-2e9d86cd9967
github.com/kyma-project/kyma v0.5.1-0.20190909070658-69599d4a33a2
github.com/mattn/go-colorable v0.1.4 // indirect
Expand Down
Loading

0 comments on commit 5251eba

Please sign in to comment.