-
Notifications
You must be signed in to change notification settings - Fork 677
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Documentation for ODF Add-on and Worker Replace
review comments added reverted resource_addons.go
- Loading branch information
aayushsss1
authored and
aayushsss1
committed
Jun 18, 2023
1 parent
a4b62d9
commit 4a7406d
Showing
16 changed files
with
288 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -e | ||
|
||
WORKING_DIR=$(pwd) | ||
|
||
cp ${WORKING_DIR}/variables.tf ${WORKING_DIR}/ibm_odf_addon/schematics.tfvars | ||
cp ${WORKING_DIR}/schematics.tfvars ${WORKING_DIR}/ibm_odf_addon/schematics.tfvars | ||
cd ${WORKING_DIR}/ibm_odf_addon | ||
terraform init | ||
if [ -e ${WORKING_DIR}/ibm_odf_addon/terraform.tfstate ] | ||
then | ||
echo "ok" | ||
else | ||
terraform apply --auto-approve -var-file=${WORKING_DIR}/ibm_odf_addon/schematics.tfvars | ||
fi | ||
terraform destroy --auto-approve -var-file=${WORKING_DIR}/ibm_odf_addon/schematics.tfvars |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -e | ||
|
||
WORKING_DIR=$(pwd) | ||
|
||
cp ${WORKING_DIR}/variables.tf ${WORKING_DIR}/ocscluster/variables.tf | ||
cp ${WORKING_DIR}/schematics.tfvars ${WORKING_DIR}/ocscluster/schematics.tfvars | ||
cd ${WORKING_DIR}/ocscluster | ||
terraform init | ||
if [ -e ${WORKING_DIR}/ocscluster/terraform.tfstate ] | ||
then | ||
echo "ok" | ||
else | ||
terraform import -var-file=${WORKING_DIR}/ocscluster/schematics.tfvars kubernetes_manifest.ocscluster_ocscluster_auto "apiVersion=ocs.ibm.io/v1,kind=OcsCluster,namespace=openshift-storage,name=ocscluster-auto" | ||
terraform apply --auto-approve -var-file ${WORKING_DIR}/ocscluster/schematics.tfvars | ||
fi | ||
|
||
terraform destroy --auto-approve -var-file=${WORKING_DIR}/ocscluster/schematics.tfvars |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
89 changes: 89 additions & 0 deletions
89
examples/openshift-data-foundation/vpc-worker-replace/README.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
# OpenShift-Data-Foundation VPC Worker Replace | ||
|
||
This example shows how to replace & update the Kubernetes VPC Gen-2 worker installed with Openshift-Data-Foundation to the latest patch in the specified cluster. | ||
|
||
For more information, about VPC worker updates, see [Updating VPC worker nodes](https://cloud.ibm.com/docs/containers?topic=containers-update&interface=ui#vpc_worker_node) | ||
|
||
## Usage | ||
|
||
To run this example you need to execute: | ||
|
||
```sh | ||
$ terraform init | ||
$ terraform plan -var-file input.tfvars | ||
$ terraform apply -var-file input.tfvars | ||
``` | ||
|
||
* Run `terraform untaint ibm_container_vpc_worker.<resource_name>[index]` to untaint the failed worker after fixing it manually to proceed with next set of workers | ||
* Run `terraform destroy` when you need to provide new set of worker list | ||
|
||
## Example usage | ||
|
||
Perform worker replace: | ||
|
||
```terraform | ||
resource "ibm_container_vpc_worker" "worker" { | ||
count = length(var.worker_list) | ||
cluster_name = var.cluster_name | ||
replace_worker = element(var.worker_list, count.index) | ||
resource_group_id = data.ibm_resource_group.group.id | ||
kube_config_path = data.ibm_container_cluster_config.cluster_config.config_file_path | ||
sds = "ODF" | ||
sds_timeout = (var.sds_timeout != null ? var.sds_timeout : null) | ||
timeouts { | ||
create = (var.create_timeout != null ? var.create_timeout : null) | ||
delete = (var.delete_timeout != null ? var.delete_timeout : null) | ||
} | ||
} | ||
``` | ||
|
||
```terraform | ||
data ibm_resource_group group { | ||
name = var.resource_group | ||
} | ||
data ibm_container_cluster_config cluster_config { | ||
cluster_name_id = var.cluster_name | ||
resource_group_id = data.ibm_resource_group.group.id | ||
} | ||
``` | ||
|
||
<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK --> | ||
|
||
## Requirements | ||
|
||
| Name | Version | | ||
|------|---------| | ||
| terraform | >=1.0.0, <2.0 | | ||
|
||
## Providers | ||
|
||
| Name | Version | | ||
|------|---------| | ||
| ibm | latest | | ||
|
||
## Inputs | ||
|
||
| Name | Description | Type | Required | | ||
|------|-------------|------|---------| | ||
| cluster_name | Name of the cluster. | `string` | yes | | ||
| replace_worker | ID of the worker to be replaced. | `string` | yes | | ||
| resource_group_id | ID of the resousrce group | `string` | no | | ||
| check_ptx_status | Whether to check ptx status on replaced workers | `bool` | no | | ||
| kube_config_path | The Cluster config with absolute path | `string` | no | | ||
| ptx_timeout | Timeout used while checking the portworx status | `string` | no | ||
| sds | Software Defined Storage - Only `ODF` is currently supported | `string` | no | ||
| sds_timeout | Timeout used while checking the sds status/deployment | `string` | no | ||
|
||
## Note | ||
|
||
* This resource is different from all other resource of IBM Cloud. Worker replace has 2 operations, i.e. Delete old worker & Create a new worker. On `terraform apply`, Replace operation is being handled where both the deletion & creation happens whereas on the `terraform destroy`, only the state is cleared but not the actual resource. | ||
* When the worker list is being provided as inputs, the list must be user generated and should not be passed from the `ibm_container_cluster` data source. | ||
* If `terraform apply` fails during worker replace or while checking the sds status, perform any one of the following actions before retrying. | ||
* Resolve the issue manually and perform `terraform untaint` to proceed with the subsequent workers in the list. | ||
* If worker replace is still needed, update the input list by replacing the existing worker id with the new worker id. | ||
|
||
|
||
|
||
* Please note, currently only `ODF` is a supported value for the `sds` input |
31 changes: 31 additions & 0 deletions
31
examples/openshift-data-foundation/vpc-worker-replace/main.tf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
##################################################### | ||
# vpc worker replace/update | ||
# Copyright 2023 IBM | ||
##################################################### | ||
|
||
##################################################### | ||
# Read each worker information attached to cluster | ||
##################################################### | ||
data ibm_resource_group group { | ||
name = var.resource_group | ||
} | ||
|
||
data ibm_container_cluster_config cluster_config { | ||
cluster_name_id = var.cluster_name | ||
resource_group_id = data.ibm_resource_group.group.id | ||
} | ||
|
||
resource "ibm_container_vpc_worker" "worker" { | ||
count = length(var.worker_list) | ||
cluster_name = var.cluster_name | ||
replace_worker = element(var.worker_list, count.index) | ||
resource_group_id = data.ibm_resource_group.group.id | ||
kube_config_path = data.ibm_container_cluster_config.cluster_config.config_file_path | ||
sds = "ODF" | ||
sds_timeout = "30m" | ||
|
||
timeouts { | ||
create = (var.create_timeout != null ? var.create_timeout : null) | ||
delete = (var.delete_timeout != null ? var.delete_timeout : null) | ||
} | ||
} |
3 changes: 3 additions & 0 deletions
3
examples/openshift-data-foundation/vpc-worker-replace/provider.tf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
provider "ibm" { | ||
ibmcloud_api_key = var.ibmcloud_api_key | ||
} |
Oops, something went wrong.