Skip to content

Commit

Permalink
Support ignition
Browse files Browse the repository at this point in the history
  • Loading branch information
Karthik-K-N committed Mar 26, 2024
1 parent 79af100 commit ff46e86
Show file tree
Hide file tree
Showing 7 changed files with 547 additions and 2 deletions.
2 changes: 1 addition & 1 deletion api/v1beta2/ibmpowervscluster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ type Ignition struct {
// Version defines which version of Ignition will be used to generate bootstrap data.
//
// +optional
// +kubebuilder:default="2.3"
// +kubebuilder:default="2.4"
// +kubebuilder:validation:Enum="2.3";"2.4";"3.0";"3.1";"3.2";"3.3";"3.4"
Version string `json:"version,omitempty"`
}
Expand Down
2 changes: 1 addition & 1 deletion api/v1beta2/ibmpowervsmachine_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ const (
// PowerVSProcessorTypeCapped enum property to identify a Capped Power VS processor type.
PowerVSProcessorTypeCapped PowerVSProcessorType = "Capped"
// DefaultIgnitionVersion represents default Ignition version generated for machine userdata.
DefaultIgnitionVersion = "2.3"
DefaultIgnitionVersion = "2.4"
)

// IBMPowerVSMachineSpec defines the desired state of IBMPowerVSMachine.
Expand Down
35 changes: 35 additions & 0 deletions cloud/scope/powervs_machine.go
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,41 @@ func (m *PowerVSMachineScope) resolveUserData() (string, error) {
if err != nil {
return "", err
}

if getIgnitionVersion(m) == "2.4" {
var ignData ignV2Types.Config
if err := json.Unmarshal(userData, &ignData); err != nil {
m.Error(err, "error while unmarshalling ignition data")
return "", err
}

// we make use of HTTPHeaders for fetching the ignition data from the COS bucket https://github.com/kubernetes-sigs/cluster-api-provider-ibmcloud/blob/258630acf8ef19c390b8defc64b4500c16316fe5/cloud/scope/powervs_machine.go#L470-L474
// by default cluster api bootstrap controller will create ignition with 2.3.0 version, but that version dont have HTTPHeaders authentication(https://github.com/coreos/ignition/blob/spec2x/doc/configuration-v2_3.md)
// So we convert the version to 2.4.0 to make use of HTTPHeaders for authentication(https://github.com/coreos/ignition/blob/spec2x/doc/configuration-v2_4.md)
if ignData.Ignition.Version == "2.3.0" {
ignData.Ignition.Version = "2.4.0"
}

// TODO(RemoveThis): For debug only
//ignData.Passwd = ignV2Types.Passwd{
// Users: []ignV2Types.PasswdUser{
// {
// Name: "",
// PasswordHash: core.StringPtr(""),
// SSHAuthorizedKeys: []ignV2Types.SSHAuthorizedKey{
// "",
// },
// },
// },
//}

userData, err = json.Marshal(ignData)
if err != nil {
m.Error(err, "error while marshalling ignition data")
return "", err
}
}

if m.UseIgnition(userDataFormat) {
data, err := m.ignitionUserData(userData)
if err != nil {
Expand Down
1 change: 1 addition & 0 deletions docs/book/src/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
- [Creating a cluster with External Cloud Provider](./topics/powervs/external-cloud-provider.md)
- [Creating a cluster from ClusterClass](./topics/powervs/clusterclass-cluster.md)
- [Creating a cluster by auto creating required resources](./topics/powervs/create-resources.md)
- [Creating a cluster using ignition](./topics/powervs/ignition.md)
- [Using autoscaler with scaling from 0 machine](./topics/powervs/autoscaler-scalling-from-0.md)
- [capibmadm CLI](./topics/capibmadm/index.md)
- [PowerVS Commands](./topics/capibmadm/powervs/index.md)
Expand Down
19 changes: 19 additions & 0 deletions docs/book/src/developer/tilt.md
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,25 @@ kustomize_substitutions:
IBMCLOUD_AUTH_URL: "https://iam.test.cloud.ibm.com"
```

### 4. Configuration to deploy PowerVS workload cluster with ignition

Set ```EXP_KUBEADM_BOOTSTRAP_FORMAT_IGNITION: "true"``` to update cluster-api bootstrap provider to use ignition format.

```yaml
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"
PROVIDER_ID_FORMAT: "v2"
EXP_CLUSTER_RESOURCE_SET: "true"
EXP_KUBEADM_BOOTSTRAP_FORMAT_IGNITION: "true",
```

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

## Run Tilt
Expand Down
1 change: 1 addition & 0 deletions docs/book/src/topics/powervs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@
- [Creating a cluster with external cloud provider](/topics/powervs/external-cloud-provider.html)
- [Creating a cluster from ClusterClass](/topics/powervs/clusterclass-cluster.html)
- [Creating a cluster by auto creating required resources](/topics/powervs/create-resources.html)
- [Creating a cluster using ignition](/topics/powervs/ignition.html)
- [Using autoscaler with scaling from 0 machine](/topics/powervs/autoscaler-scalling-from-0.html)
Loading

0 comments on commit ff46e86

Please sign in to comment.