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

[WIP] Support ignition #1687

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
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 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
30 changes: 30 additions & 0 deletions docs/book/src/topics/powervs/ignition.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Use ignition for IBM PowerVS cluster

## Steps

- Set ```powervs.cluster.x-k8s.io/create-infra:true``` annotation to IBMPowerVSCluster resource to auto create required resources.
- The cluster will be configured with IBM PowerVS external [cloud provider](https://kubernetes.io/docs/concepts/architecture/cloud-controller/)
- The [cluster-template-powervs-ignition](https://github.com/kubernetes-sigs/cluster-api-provider-ibmcloud/blob/main/templates/cluster-template-powervs-ignition.yaml) will use [clusterresourceset](https://cluster-api.sigs.k8s.io/tasks/experimental-features/cluster-resource-set.html) and will create the necessary config map, secret and roles to run the cloud controller manager
- As a prerequisite set the `provider-id-fmt` [flag](https://github.com/kubernetes-sigs/cluster-api-provider-ibmcloud/blob/5e7f80878f2252c6ab13c16102de90c784a2624d/main.go#L168-L173) with value v2.
- Set ```export EXP_KUBEADM_BOOTSTRAP_FORMAT_IGNITION=true``` if using clusterctl or set ```"EXP_KUBEADM_BOOTSTRAP_FORMAT_IGNITION": "true"``` when using tilt to update capi bootstrap provided to set ignition format.

### Deploy PowerVS cluster with IBM PowerVS cloud provider

```
IBMCLOUD_API_KEY=<api_key>> \
IBMPOWERVS_SSHKEY_NAME="karthik-ssh" \
COS_BUCKET_REGION="us-south" \
COS_BUCKET_NAME="power-oss-bucket" \
COS_OBJECT_NAME=capi-rhcos-openstack-4.5.ova.gz \
IBMACCOUNT_ID="<account_id>" \
IBMPOWERVS_REGION="wdc" \
IBMPOWERVS_ZONE="wdc06" \
IBMVPC_REGION="us-east" \
IBM_RESOURCE_GROUP="ibm-hypershift-dev" \
BASE64_API_KEY=$(echo -n $IBMCLOUD_API_KEY | base64) \
clusterctl generate cluster capi-powervs- --kubernetes-version v1.28.4 \
--target-namespace default \
--control-plane-machine-count=3 \
--worker-machine-count=1 \
--from ./cluster-template-powervs-ignition.yaml | kubectl apply -f -
```
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