-
Notifications
You must be signed in to change notification settings - Fork 2
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
How-To: Adopt worker nodes with the cloudscale Machine API Provider #362
Open
bastjan
wants to merge
3
commits into
master
Choose a base branch
from
cloudscale-node-adoption-howto
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
218 changes: 218 additions & 0 deletions
218
docs/modules/ROOT/pages/how-tos/cloudscale/provider-adopt-worker-nodes.adoc
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,218 @@ | ||
= Adopt worker nodes with the cloudscale Machine API Provider | ||
|
||
[abstract] | ||
-- | ||
Steps to adopt worker nodes on https://cloudscale.ch[cloudscale] with the https://github.com/appuio/machine-api-provider-cloudscale[cloudscale Machine API Provider]. | ||
-- | ||
|
||
== Starting situation | ||
|
||
* You already have an OpenShift 4 cluster on cloudscale | ||
* You have admin-level access to the cluster | ||
* You want the nodes adopted by the https://github.com/appuio/machine-api-provider-cloudscale[cloudscale Machine API Provider] | ||
|
||
== Prerequisites | ||
|
||
The following CLI utilities need to be available locally: | ||
|
||
* `commodore`, see https://syn.tools/commodore/running-commodore.html[Running Commodore] | ||
* `docker` | ||
* `kubectl` | ||
* `vault` | ||
* `yq` | ||
|
||
== Prepare local environment | ||
|
||
include::partial$cloudscale/setup-local-env.adoc[] | ||
|
||
== Update Cluster Config | ||
|
||
. Update cluster config | ||
+ | ||
[source,bash] | ||
---- | ||
pushd inventory/classes/"${TENANT_ID}" | ||
|
||
yq -i '.applications += "machine-api-provider-cloudscale"' \ | ||
${CLUSTER_ID}.yml | ||
|
||
yq eval -i ".parameters.openshift4_terraform.terraform_variables.make_worker_adoptable_by_provider = true" \ | ||
${CLUSTER_ID}.yml | ||
|
||
git commit -m "Allow adoption of worker nodes" "${CLUSTER_ID}.yml" | ||
popd | ||
---- | ||
|
||
. Compile and push the cluster catalog. | ||
+ | ||
[source,bash] | ||
---- | ||
commodore catalog compile "${CLUSTER_ID}" --push | ||
---- | ||
|
||
== Prepare Terraform environment | ||
|
||
include::partial$cloudscale/configure-terraform-secrets.adoc[] | ||
|
||
include::partial$setup_terraform.adoc[] | ||
|
||
== Run terraform | ||
|
||
. Verify terraform output and apply the changes if everything looks good. | ||
+ | ||
Terraform will tag the nodes as preparation for the adoption by the cloudscale Machine API Provider. | ||
+ | ||
[source,bash] | ||
---- | ||
terraform apply | ||
---- | ||
|
||
== Apply Machine and MachineSet manifests | ||
|
||
[IMPORTANT] | ||
==== | ||
Please ensure the terraform apply has completed successfully before proceeding with this step. | ||
Without the tags applied by Terraform, nodes will be duplicated with the same name and weird stuff might happen. | ||
|
||
Please be careful to not apply the `MachineSet` before the `Machine` manifests. | ||
==== | ||
|
||
. Copy `worker-machines_yml` from the Terraform output and apply it to the cluster. | ||
+ | ||
[source,bash] | ||
---- | ||
terraform output -raw worker-machines_yml | yq -P > worker-machines.yml | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. on my machine Terraform prints a warning which then gets included in the yaml (because they have never heard of stderr):
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I ended up using this command:
|
||
head worker-machines.yml | ||
kubectl apply -f worker-machines.yml | ||
---- | ||
|
||
. Check that all machines are in the `Running` state. | ||
+ | ||
[source,bash] | ||
---- | ||
kubectl get -f worker-machines.yml | ||
---- | ||
|
||
. Copy `worker-machineset_yml` from the Terraform output and apply it to the cluster. | ||
+ | ||
[source,bash] | ||
---- | ||
terraform output -raw worker-machineset_yml | yq -P > worker-machineset.yml | ||
head worker-machineset.yml | ||
kubectl apply -f worker-machineset.yml | ||
---- | ||
|
||
. Copy `infra-machines_yml` from the Terraform output and apply it to the cluster. | ||
+ | ||
[source,bash] | ||
---- | ||
terraform output -raw infra-machines_yml | yq -P > infra-machines.yml | ||
head infra-machines.yml | ||
kubectl apply -f infra-machines.yml | ||
---- | ||
|
||
. Check that all machines are in the `Running` state. | ||
+ | ||
[source,bash] | ||
---- | ||
kubectl get -f infra-machines.yml | ||
---- | ||
|
||
. Copy `infra-machineset_yml` from the Terraform output and apply it to the cluster. | ||
+ | ||
[source,bash] | ||
---- | ||
terraform output -raw infra-machineset_yml | yq -P > infra-machineset.yml | ||
head infra-machineset.yml | ||
kubectl apply -f infra-machineset.yml | ||
---- | ||
|
||
. Copy `additional-worker-machines_yml` from the Terraform output and apply it to the cluster. | ||
+ | ||
[source,bash] | ||
---- | ||
terraform output -raw additional-worker-machines_yml | yq -P > additional-worker-machines.yml | ||
head additional-worker-machines.yml | ||
kubectl apply -f additional-worker-machines.yml | ||
---- | ||
|
||
. Check that all machines are in the `Running` state. | ||
+ | ||
[source,bash] | ||
---- | ||
kubectl get -f additional-worker-machines.yml | ||
---- | ||
|
||
. Copy `additional-worker-machinesets_yml` from the Terraform output and apply it to the cluster. | ||
+ | ||
[source,bash] | ||
---- | ||
terraform output -raw additional-worker-machinesets_yml | yq -P > additional-worker-machinesets.yml | ||
head additional-worker-machinesets.yml | ||
kubectl apply -f additional-worker-machinesets.yml | ||
---- | ||
|
||
== Remove nodes from the Terraform state | ||
|
||
. Remove the nodes from the Terraform state. | ||
+ | ||
[source,bash] | ||
---- | ||
terraform state rm module.cluster.module.worker | ||
terraform state rm module.cluster.module.infra | ||
terraform state rm module.cluster.module.additional_worker | ||
cat > override.tf <<EOF | ||
module "cluster" { | ||
infra_count = 0 | ||
worker_count = 0 | ||
additional_worker_groups = {} | ||
} | ||
EOF | ||
---- | ||
|
||
. Check the terraform plan output and apply the changes. | ||
There should be no server recreation. | ||
Hieradata entries can be ignored. | ||
bastjan marked this conversation as resolved.
Show resolved
Hide resolved
|
||
+ | ||
[source,bash] | ||
---- | ||
terraform plan | ||
terraform apply | ||
---- | ||
|
||
== Cleanup | ||
|
||
. Persist the Terraform changes and start managing the machine sets. | ||
+ | ||
[source,bash] | ||
---- | ||
popd | ||
pushd "inventory/classes/${TENANT_ID}" | ||
|
||
yq -i e '.parameters.openshift4_terraform.terraform_variables.additional_worker_groups= {}' \ | ||
"${CLUSTER_ID}.yml" | ||
yq -i e '.parameters.openshift4_terraform.terraform_variables.infra_count = 0' \ | ||
"${CLUSTER_ID}.yml" | ||
yq -i e '.parameters.openshift4_terraform.terraform_variables.worker_count = 0' \ | ||
"${CLUSTER_ID}.yml" | ||
|
||
yq -i ea 'select(fileIndex == 0) as $cluster | | ||
$cluster.parameters.openshift4_nodes.machineSets = | ||
([select(fileIndex > 0)][] as $ms ireduce ({}; | ||
$ms.metadata.name as $msn | | ||
del($ms.apiVersion) | | ||
del($ms.kind) | | ||
del($ms.metadata.name) | | ||
del($ms.metadata.labels.name) | | ||
del($ms.metadata.namespace) | | ||
. * {$msn: $ms} | ||
)) | | ||
$cluster' \ | ||
"${CLUSTER_ID}.yml" ../../../catalog/manifests/openshift4-terraform/*machineset*.yml | ||
|
||
git commit -am "Persist provider adopted machine and terraform state for ${CLUSTER_ID}" | ||
git push origin master | ||
popd | ||
|
||
commodore catalog compile "${CLUSTER_ID}" --push | ||
---- |
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A git push appears to be missing here.