Skip to content

Commit

Permalink
Add environmetal variable to set providerID format
Browse files Browse the repository at this point in the history
  • Loading branch information
Karthik-K-N committed Apr 20, 2022
1 parent 3fdb551 commit 11914b6
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 15 deletions.
2 changes: 1 addition & 1 deletion cloud/scope/powervs_machine.go
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,7 @@ func (m *PowerVSMachineScope) GetZone() string {
// SetProviderID will set the provider id for the machine.
func (m *PowerVSMachineScope) SetProviderID(id *string) {
// Based on the ProviderIDFormat version the providerID format will be decided.
if options.PowerVSProviderIDFormat == options.PowerVSProviderIDFormatV2 {
if options.PowerVSProviderIDFormatType(options.PowerVSProviderIDFormat) == options.PowerVSProviderIDFormatV2 {
if id != nil {
m.IBMPowerVSMachine.Spec.ProviderID = pointer.StringPtr(fmt.Sprintf("ibmpowervs://%s/%s/%s/%s", m.GetRegion(), m.GetZone(), m.IBMPowerVSMachine.Spec.ServiceInstanceID, *id))
}
Expand Down
4 changes: 0 additions & 4 deletions config/default/manager_auth_proxy_patch.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,3 @@ spec:
ports:
- containerPort: 8443
name: https
- name: manager
args:
- "--metrics-bind-addr=127.0.0.1:8080"
- "--leader-elect"
1 change: 1 addition & 0 deletions config/manager/manager.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ spec:
args:
- "--leader-elect"
- "--metrics-bind-addr=127.0.0.1:8080"
- "--powervs-provider-id-fmt=${POWERVS_PROVIDER_ID_FORMAT:=v1}"
image: controller:latest
name: manager
ports:
Expand Down
15 changes: 15 additions & 0 deletions docs/book/src/developer/tilt.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,21 @@ Add following extra_args to log Power VS REST API Requests/Responses
}
}
```

To deploy workload cluster with [Power VS cloud controller manager](/topics/powervs/external-cloud-provider.html) which is currently in experimental stage, Set `POWERVS_PROVIDER_ID_FORMAT` to `v2` under kustomize_substitutions.

```json
{
"default_registry": "gcr.io/you-project-name-here",
"provider_repos": ["../cluster-api-provider-ibmcloud"],
"enable_providers": ["ibmcloud", "kubeadm-bootstrap", "kubeadm-control-plane"],
"kustomize_substitutions": {
"IBMCLOUD_API_KEY": "XXXXXXXXXXXXXXXXXX",
"POWERVS_PROVIDER_ID_FORMAT": "v2"
}
}
```

**NOTE**: For information about all the fields that can be used in the `tilt-settings.json` file, check them [here](https://cluster-api.sigs.k8s.io/developer/tilt.html#tilt-settingsjson-fields).

## Run Tilt
Expand Down
10 changes: 8 additions & 2 deletions docs/book/src/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,15 @@ it into a management cluster using `clusterctl`.

> Note: Refer [Regions-Zones Mapping](/reference/regions-zones-mapping.html) for more information.

3. Initialize local bootstrap cluter as a management cluster
To deploy workload cluster with [Power VS cloud controller manager]((/topics/powervs/external-cloud-provider.html)) which is currently in experimental stage. Set the `POWERVS_PROVIDER_ID_FORMAT` environmental variable
``` bash
export POWERVS_PROVIDER_ID_FORMAT=v2
```

3. Initialize local bootstrap cluster as a management cluster
When executed for the first time, the following command accepts the infrasturcture provider as an input to install. `clusterctl init` automatically adds to the list the cluster-api core provider, and if unspecified, it also adds the kubeadm bootstrap and kubeadm control-plane providers, thereby converting it into a management cluster which will be used to provision a workload cluster in IBM Cloud.
When executed for the first time, the following command accepts the infrastructure provider as an input to install. `clusterctl init` automatically adds to the list the cluster-api core provider, and if unspecified, it also adds the kubeadm bootstrap and kubeadm control-plane providers, thereby converting it into a management cluster which will be used to provision a workload cluster in IBM Cloud.


```console
~ clusterctl init --infrastructure ibmcloud:<TAG>
Expand Down
4 changes: 2 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -220,13 +220,13 @@ func initFlags(fs *pflag.FlagSet) {
fs.StringVar(
&options.PowerVSProviderIDFormat,
"powervs-provider-id-fmt",
options.PowerVSProviderIDFormatV1,
string(options.PowerVSProviderIDFormatV1),
"ProviderID format is used set the Provider ID format for Machine",
)
}

func validateFlags() error {
switch options.PowerVSProviderIDFormat {
switch options.PowerVSProviderIDFormatType(options.PowerVSProviderIDFormat) {
case options.PowerVSProviderIDFormatV1:
setupLog.Info("Using v1 version of ProviderID format")
case options.PowerVSProviderIDFormatV2:
Expand Down
17 changes: 11 additions & 6 deletions pkg/options/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,16 @@ limitations under the License.

package options

// PowerVSProviderIDFormat is used to identify the Provider ID format for Machine.
var PowerVSProviderIDFormat string
// PowerVSProviderIDFormatType enum attribute to identify Power VS ProviderID format.
type PowerVSProviderIDFormatType string

const (
// PowerVSProviderIDFormatV1 will set provider id to machine as ibmpowervs://<cluster_name>/<vm_hostname>
PowerVSProviderIDFormatV1 PowerVSProviderIDFormatType = "v1"

// PowerVSProviderIDFormatV2 will set provider id to machine as ibmpowervs://<region>/<zone>/<service_instance_id>/<powervs_machine_id>
const PowerVSProviderIDFormatV2 = "v2"
// PowerVSProviderIDFormatV2 will set provider id to machine as ibmpowervs://<region>/<zone>/<service_instance_id>/<powervs_machine_id>
PowerVSProviderIDFormatV2 PowerVSProviderIDFormatType = "v2"
)

// PowerVSProviderIDFormatV1 will set provider id to machine as ibmpowervs://<cluster_name>/<vm_hostname>
const PowerVSProviderIDFormatV1 = "v1"
// PowerVSProviderIDFormat is used to identify the Provider ID format for Machine.
var PowerVSProviderIDFormat string

0 comments on commit 11914b6

Please sign in to comment.