This is an ansible playbook that deploys | destroys hypershift clusters using Ansible.
This automation makes certain assumptions:
- Existing openshift cluster with multicluster-engine configured with hypershift TP feature
- Ansible is installed on your system, with kuberenetes.core collections
oc
andhypershift
binaries installed and in your path- Your pull secret from "https://console.redhat.com"
- An AWS credentials file with a profile that allows you to create cloud resources
parameter | default | description |
---|---|---|
create | false | set true to create cluster |
destroy | false | set true to destroy cluster |
deployment_dir | ~/clusters |
Path where cluster config info is stored |
name | hcpdflt |
cluster name ( also used for infraID) |
replicas | 1 |
Number of machines to create |
instance_type | m5.xlarge |
AWS Machine type |
domain | example.com |
base domain for route53 and cluster deployment |
pull_secret | ~/.pullsecret |
Path to pull secret from console.redhat.com |
creds | ~/.aws/credentials |
Path to credentials file for aws |
region | us-west-2 |
default region to deploy resources |
image | 4.13.22 |
OpenShift version to deploy |
tags | "key=value,key=value" |
add additional tags for aws resources |
gather_facts | false | eeedisabled for speed |
This playbook has three stages:
- preflight
- deploy
- destroy
Preflight Stage does the following:
- verifies
oc
andhypershift
binaries exist in your path (which $binary
) - verifies your pull secret and aws credentials exist (it does not confirm their validity)
Deploy Stage does the following:
- creates deployment directory
- creates cluster-info.txt with information to access the cluster once deployed
- creates a kubeconfig for accessing the cluster using the kubeconfig
- creates a hostedcluster
Destroy Stage destroys the hostedcluster and deletes the deployment directory.
- Creating a cluster
ansible-playbook hcp.yml -e "create=true name=example
- Destroying a cluster
ansible-playbook hcp.yml -e "destroy=true name=example