Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add environmetal variable to set providerID format #635

Merged
merged 1 commit into from
Apr 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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"
Karthik-K-N marked this conversation as resolved.
Show resolved Hide resolved
}
}
```

**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
9 changes: 7 additions & 2 deletions docs/book/src/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,14 @@ 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
> Note: 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
```console
export POWERVS_PROVIDER_ID_FORMAT=v2
```

2. 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