diff --git a/cmd/pke/app/constants/constants.go b/cmd/pke/app/constants/constants.go index dd38b139..44625507 100644 --- a/cmd/pke/app/constants/constants.go +++ b/cmd/pke/app/constants/constants.go @@ -116,6 +116,10 @@ const ( FlagAzureLoadBalancerSku = "azure-loadbalancer-sku" // FlagAzureRouteTableName the name of the route table attached to the subnet that the cluster is deployed in. FlagAzureRouteTableName = "azure-route-table-name" + // FlagAzureStorageAccountType Azure storage account Sku tier. + FlagAzureStorageAccountType = "azure-storage-account-type" + // FlagAzureStorageKind possible values are shared, dedicated, and managed (default). + FlagAzureStorageKind = "azure-storage-kind" // FlagDisableDefaultStorageClass adds default storage class. FlagDisableDefaultStorageClass = "disable-default-storage-class" diff --git a/cmd/pke/app/phases/kubeadm/controlplane/controlplane.go b/cmd/pke/app/phases/kubeadm/controlplane/controlplane.go index c44196bb..eeb49b81 100644 --- a/cmd/pke/app/phases/kubeadm/controlplane/controlplane.go +++ b/cmd/pke/app/phases/kubeadm/controlplane/controlplane.go @@ -105,6 +105,8 @@ type ControlPlane struct { azureVMType string azureLoadBalancerSku string azureRouteTableName string + azureStorageAccountType string + azureStorageKind string azureExcludeMasterFromStandardLB bool cidr string disableDefaultStorageClass bool @@ -169,6 +171,8 @@ func (c *ControlPlane) RegisterFlags(flags *pflag.FlagSet) { flags.String(constants.FlagAzureVMType, "standard", "The type of azure nodes. Candidate values are: vmss and standard") flags.String(constants.FlagAzureLoadBalancerSku, "basic", "Sku of Load Balancer and Public IP. Candidate values are: basic and standard") flags.String(constants.FlagAzureRouteTableName, "kubernetes-routes", "The name of the route table attached to the subnet that the cluster is deployed in") + flags.String(constants.FlagAzureStorageAccountType, "Standard_LRS", "Azure storage account Sku tier") + flags.String(constants.FlagAzureStorageKind, "dedicated", "Possible values are shared, dedicated, and managed") // Pipeline flags.StringP(constants.FlagPipelineAPIEndpoint, constants.FlagPipelineAPIEndpointShort, "", "Pipeline API server url") flags.StringP(constants.FlagPipelineAPIToken, constants.FlagPipelineAPITokenShort, "", "Token for accessing Pipeline API") @@ -215,14 +219,16 @@ func (c *ControlPlane) Validate(cmd *cobra.Command) error { // Azure specific required flags if c.cloudProvider == constants.CloudProviderAzure { if err := validator.NotEmpty(map[string]interface{}{ - constants.FlagAzureTenantID: c.azureTenantID, - constants.FlagAzureSubnetName: c.azureSubnetName, - constants.FlagAzureSecurityGroupName: c.azureSecurityGroupName, - constants.FlagAzureVNetName: c.azureVNetName, - constants.FlagAzureVNetResourceGroup: c.azureVNetResourceGroup, - constants.FlagAzureVMType: c.azureVMType, - constants.FlagAzureLoadBalancerSku: c.azureLoadBalancerSku, - constants.FlagAzureRouteTableName: c.azureRouteTableName, + constants.FlagAzureTenantID: c.azureTenantID, + constants.FlagAzureSubnetName: c.azureSubnetName, + constants.FlagAzureSecurityGroupName: c.azureSecurityGroupName, + constants.FlagAzureVNetName: c.azureVNetName, + constants.FlagAzureVNetResourceGroup: c.azureVNetResourceGroup, + constants.FlagAzureVMType: c.azureVMType, + constants.FlagAzureLoadBalancerSku: c.azureLoadBalancerSku, + constants.FlagAzureRouteTableName: c.azureRouteTableName, + constants.FlagAzureStorageAccountType: c.azureStorageAccountType, + constants.FlagAzureStorageKind: c.azureStorageKind, }); err != nil { return err } @@ -519,6 +525,20 @@ func (c *ControlPlane) masterBootstrapParameters(cmd *cobra.Command) (err error) if err != nil { return } + err = c.azureParameters(cmd) + if err != nil { + return + } + c.cidr, err = cmd.Flags().GetString(constants.FlagInfrastructureCIDR) + if err != nil { + return + } + c.disableDefaultStorageClass, err = cmd.Flags().GetBool(constants.FlagDisableDefaultStorageClass) + + return +} + +func (c *ControlPlane) azureParameters(cmd *cobra.Command) (err error) { c.azureTenantID, err = cmd.Flags().GetString(constants.FlagAzureTenantID) if err != nil { return @@ -551,11 +571,11 @@ func (c *ControlPlane) masterBootstrapParameters(cmd *cobra.Command) (err error) if err != nil { return } - c.cidr, err = cmd.Flags().GetString(constants.FlagInfrastructureCIDR) + c.azureStorageAccountType, err = cmd.Flags().GetString(constants.FlagAzureStorageAccountType) if err != nil { return } - c.disableDefaultStorageClass, err = cmd.Flags().GetBool(constants.FlagDisableDefaultStorageClass) + c.azureStorageKind, err = cmd.Flags().GetString(constants.FlagAzureStorageKind) return } @@ -644,7 +664,7 @@ func (c *ControlPlane) installMaster(out io.Writer) error { } // apply default storage class - if err := applyDefaultStorageClass(out, c.disableDefaultStorageClass, c.cloudProvider); err != nil { + if err := applyDefaultStorageClass(out, c.disableDefaultStorageClass, c.cloudProvider, c.azureStorageAccountType, c.azureStorageKind); err != nil { return err } diff --git a/cmd/pke/app/phases/kubeadm/controlplane/storage_class.go b/cmd/pke/app/phases/kubeadm/controlplane/storage_class.go index c8a23608..c05d6b72 100644 --- a/cmd/pke/app/phases/kubeadm/controlplane/storage_class.go +++ b/cmd/pke/app/phases/kubeadm/controlplane/storage_class.go @@ -24,7 +24,7 @@ import ( "github.com/banzaicloud/pke/cmd/pke/app/util/runner" ) -func applyDefaultStorageClass(out io.Writer, disableDefaultStorageClass bool, cloudProvider string) error { +func applyDefaultStorageClass(out io.Writer, disableDefaultStorageClass bool, cloudProvider, azureStorageAccountType, azuerStorageKind string) error { if disableDefaultStorageClass { return nil } @@ -34,7 +34,7 @@ func applyDefaultStorageClass(out io.Writer, disableDefaultStorageClass bool, cl case constants.CloudProviderAmazon: err = writeStorageClassAmazon(out, storageClassConfig) case constants.CloudProviderAzure: - err = writeStorageClassAzure(out, storageClassConfig) + err = writeStorageClassAzure(out, storageClassConfig, azureStorageAccountType, azuerStorageKind) default: err = writeStorageClassLocalPathStorage(out, storageClassConfig) } @@ -86,7 +86,7 @@ parameters: return tmpl.Execute(w, d) } -func writeStorageClassAzure(out io.Writer, filename string) error { +func writeStorageClassAzure(out io.Writer, filename string, storageAccountType, kind string) error { _, _ = fmt.Fprintf(out, "[%s] creating Azure default storage class\n", use) // https://kubernetes.io/docs/concepts/storage/storage-classes/#new-azure-disk-storage-class-starting-from-v1-7-2 conf := `kind: StorageClass @@ -95,6 +95,8 @@ metadata: name: azure-disk annotations: storageclass.kubernetes.io/is-default-class: "true" + labels: + kubernetes.io/cluster-service: "true" provisioner: kubernetes.io/azure-disk volumeBindingMode: WaitForFirstConsumer parameters: @@ -120,8 +122,8 @@ parameters: } d := data{ - StorageAccountType: "Standard_LRS", - Kind: "dedicated", + StorageAccountType: storageAccountType, + Kind: kind, } return tmpl.Execute(w, d) diff --git a/cmd/pke/app/util/pipeline/client.go b/cmd/pke/app/util/pipeline/client.go index b8286dfa..97921f9a 100644 --- a/cmd/pke/app/util/pipeline/client.go +++ b/cmd/pke/app/util/pipeline/client.go @@ -35,7 +35,8 @@ func Client(out io.Writer, endpoint, token string) *pipeline.APIClient { config.HTTPClient = oauth2.NewClient(nil, oauth2.StaticTokenSource( &oauth2.Token{AccessToken: token}, )) - config.HTTPClient.Timeout = 30 * time.Second + // Since transport.NewRetryTransport is added, this timeout will affect only the cumulated retry calls. + config.HTTPClient.Timeout = 24 * time.Hour tl := transport.NewLogger(out, config.HTTPClient.Transport) config.HTTPClient.Transport = transport.NewRetryTransport(tl) diff --git a/cmd/pke/docs/pke_install_master.md b/cmd/pke/docs/pke_install_master.md index 2070a4f2..68f6e7a2 100644 --- a/cmd/pke/docs/pke_install_master.md +++ b/cmd/pke/docs/pke_install_master.md @@ -16,6 +16,8 @@ pke install master [flags] --azure-loadbalancer-sku string Sku of Load Balancer and Public IP. Candidate values are: basic and standard (default "basic") --azure-route-table-name string The name of the route table attached to the subnet that the cluster is deployed in (default "kubernetes-routes") --azure-security-group-name string The name of the security group attached to the cluster's subnet + --azure-storage-account-type string Azure storage account Sku tier (default "Standard_LRS") + --azure-storage-kind string Possible values are shared, dedicated, and managed (default "dedicated") --azure-subnet-name string The name of the subnet that the cluster is deployed in --azure-tenant-id string The AAD Tenant ID for the Subscription that the cluster is deployed in --azure-vm-type string The type of azure nodes. Candidate values are: vmss and standard (default "standard") diff --git a/cmd/pke/docs/pke_install_master_kubernetes-controlplane.md b/cmd/pke/docs/pke_install_master_kubernetes-controlplane.md index ca449bc0..1308d4f1 100644 --- a/cmd/pke/docs/pke_install_master_kubernetes-controlplane.md +++ b/cmd/pke/docs/pke_install_master_kubernetes-controlplane.md @@ -16,6 +16,8 @@ pke install master kubernetes-controlplane [flags] --azure-loadbalancer-sku string Sku of Load Balancer and Public IP. Candidate values are: basic and standard (default "basic") --azure-route-table-name string The name of the route table attached to the subnet that the cluster is deployed in (default "kubernetes-routes") --azure-security-group-name string The name of the security group attached to the cluster's subnet + --azure-storage-account-type string Azure storage account Sku tier (default "Standard_LRS") + --azure-storage-kind string Possible values are shared, dedicated, and managed (default "dedicated") --azure-subnet-name string The name of the subnet that the cluster is deployed in --azure-tenant-id string The AAD Tenant ID for the Subscription that the cluster is deployed in --azure-vm-type string The type of azure nodes. Candidate values are: vmss and standard (default "standard") diff --git a/cmd/pke/docs/pke_install_single.md b/cmd/pke/docs/pke_install_single.md index ba43b752..c3ceef74 100644 --- a/cmd/pke/docs/pke_install_single.md +++ b/cmd/pke/docs/pke_install_single.md @@ -16,6 +16,8 @@ pke install single [flags] --azure-loadbalancer-sku string Sku of Load Balancer and Public IP. Candidate values are: basic and standard (default "basic") --azure-route-table-name string The name of the route table attached to the subnet that the cluster is deployed in (default "kubernetes-routes") --azure-security-group-name string The name of the security group attached to the cluster's subnet + --azure-storage-account-type string Azure storage account Sku tier (default "Standard_LRS") + --azure-storage-kind string Possible values are shared, dedicated, and managed (default "dedicated") --azure-subnet-name string The name of the subnet that the cluster is deployed in --azure-tenant-id string The AAD Tenant ID for the Subscription that the cluster is deployed in --azure-vm-type string The type of azure nodes. Candidate values are: vmss and standard (default "standard") diff --git a/cmd/pke/docs/pke_install_single_kubernetes-controlplane.md b/cmd/pke/docs/pke_install_single_kubernetes-controlplane.md index 7368b017..f8e2c028 100644 --- a/cmd/pke/docs/pke_install_single_kubernetes-controlplane.md +++ b/cmd/pke/docs/pke_install_single_kubernetes-controlplane.md @@ -16,6 +16,8 @@ pke install single kubernetes-controlplane [flags] --azure-loadbalancer-sku string Sku of Load Balancer and Public IP. Candidate values are: basic and standard (default "basic") --azure-route-table-name string The name of the route table attached to the subnet that the cluster is deployed in (default "kubernetes-routes") --azure-security-group-name string The name of the security group attached to the cluster's subnet + --azure-storage-account-type string Azure storage account Sku tier (default "Standard_LRS") + --azure-storage-kind string Possible values are shared, dedicated, and managed (default "dedicated") --azure-subnet-name string The name of the subnet that the cluster is deployed in --azure-tenant-id string The AAD Tenant ID for the Subscription that the cluster is deployed in --azure-vm-type string The type of azure nodes. Candidate values are: vmss and standard (default "standard") diff --git a/docs/aws.md b/docs/aws.md index 7892fec5..df7ce1f9 100644 --- a/docs/aws.md +++ b/docs/aws.md @@ -94,7 +94,7 @@ aws ec2 run-instances --image-id ami-3548444c \ Once you single master instance booted up, SSH into it with the key file configured. Run the following commands as root: ``` -curl -v https://banzaicloud.com/downloads/pke/pke-0.2.3 -o /usr/local/bin/pke +curl -v https://banzaicloud.com/downloads/pke/pke-0.4.4 -o /usr/local/bin/pke chmod +x /usr/local/bin/pke export PATH=$PATH:/usr/local/bin/ @@ -129,7 +129,7 @@ export INTERNAL_IP=$(curl http://169.254.169.254/latest/meta-data/local-ipv4) export MAC=$(curl -s http://169.254.169.254/latest/meta-data/network/interfaces/macs/) export VPC_CIDR=$(curl -s http://169.254.169.254/latest/meta-data/network/interfaces/macs/$MAC/vpc-ipv4-cidr-block/) -curl -v https://banzaicloud.com/downloads/pke/pke-0.2.3 -o /usr/local/bin/pke +curl -v https://banzaicloud.com/downloads/pke/pke-0.4.4 -o /usr/local/bin/pke chmod +x /usr/local/bin/pke export PATH=$PATH:/usr/local/bin/ @@ -162,7 +162,7 @@ pke token create To install a worker node, run the following commands. Take note that you'd need to set the TOKEN and CERTHASH variables from above. ``` -curl -v https://banzaicloud.com/downloads/pke/pke-0.2.3 -o /usr/local/bin/pke +curl -v https://banzaicloud.com/downloads/pke/pke-0.4.4 -o /usr/local/bin/pke chmod +x /usr/local/bin/pke export PATH=$PATH:/usr/local/bin/ diff --git a/docs/azure.md b/docs/azure.md index 8291c6b6..fe5ba479 100644 --- a/docs/azure.md +++ b/docs/azure.md @@ -285,7 +285,7 @@ Install PKE. > `--kubernetes-cluster-name` is used for load balancer naming. ```bash -curl -v https://banzaicloud.com/downloads/pke/pke-0.2.3 -o /usr/local/bin/pke +curl -v https://banzaicloud.com/downloads/pke/pke-0.4.4 -o /usr/local/bin/pke chmod +x /usr/local/bin/pke export PATH=$PATH:/usr/local/bin/ diff --git a/docs/requirements.md b/docs/requirements.md index 92b78461..c5c30982 100644 --- a/docs/requirements.md +++ b/docs/requirements.md @@ -16,7 +16,7 @@ You can also use the following commands as root to achieve this: ``` -curl -v https://banzaicloud.com/downloads/pke/pke-0.2.3 -o /usr/local/bin/pke +curl -v https://banzaicloud.com/downloads/pke/pke-0.4.4 -o /usr/local/bin/pke chmod +x /usr/local/bin/pke export PATH=$PATH:/usr/local/bin/ ``` diff --git a/docs/vagrant.md b/docs/vagrant.md index 81074cd7..b57f7769 100644 --- a/docs/vagrant.md +++ b/docs/vagrant.md @@ -23,7 +23,7 @@ Once the node is up follow these instructions: vagrant ssh node1 sudo -s -curl -v https://banzaicloud.com/downloads/pke/pke-0.2.3 -o /usr/local/bin/pke +curl -v https://banzaicloud.com/downloads/pke/pke-0.4.4 -o /usr/local/bin/pke chmod +x /usr/local/bin/pke export PATH=$PATH:/usr/local/bin/ @@ -47,7 +47,7 @@ Once the node is up follow these instructions: vagrant ssh node1 sudo -s -curl -v https://banzaicloud.com/downloads/pke/pke-0.2.3 -o /usr/local/bin/pke +curl -v https://banzaicloud.com/downloads/pke/pke-0.4.4 -o /usr/local/bin/pke chmod +x /usr/local/bin/pke export PATH=$PATH:/usr/local/bin/ @@ -77,7 +77,7 @@ Take note that you'd need to export the TOKEN and CERTHASH environment variables vagrant ssh node2 sudo -s -curl -v https://banzaicloud.com/downloads/pke/pke-0.2.3 -o /usr/local/bin/pke +curl -v https://banzaicloud.com/downloads/pke/pke-0.4.4 -o /usr/local/bin/pke chmod +x /usr/local/bin/pke export PATH=$PATH:/usr/local/bin/