Level 7: Multi-Cluster Kubernetes Orchestration
This example demonstrates defining an environment independent Kubernetes workload and deploying it to development and production clusters. The example runs on Amazon Web Services (AWS) or Microsoft Azure and so requires an account and API credentials. It available on github.
The infrastructure deployment consists of ServiceComponent
s representing:
- network
- database
- object store
- kubernetes
The implementation of these components is based on the environment type, which is supplied as an input to the deployment. For example, if a development environment is selected, Minio is used as the object store and Minikube as the Kubernetes provider. If an AWS production environment is selected, S3 and EKS is used for each, respectively, whereas on Azure Blob and AKS is used.
Concepts
Configuration Indirection
Multi-Kubernetes Cluster orchestration is achieved using a combination of the plugins mentioned above, and the design technique introduced in the Environment as a Service example. The technique uses a structured secret (a JSON object) to map the input environment type to component blueprint names. For example, to retrieve the name of the database blueprint, the following YAML is used in the main blueprint:
id: { get_secret: [ eaas_params, { get_input: cloud_type }, { get_input: env_type }, db, blueprint ] }
Where
eaas_params
: the name of the secret containing the JSON objectcloud_type
: a cloud provider (aws, azure)env_type
: one of the valid environment type names (e.g.dev-small
,prod
)
Service Composition
The configuration indirection mentioned above helps with mapping simple identifiers (like ‘dev-small’) to complex configuration details (like image names/id, flavors, etc..). This is not sufficient to completely abstract away the different Kubernetes environments required. To do this requires service composition. Service composition allows blueprint nodes to represent entire blueprints themselves, effectively nesting blueprints and enabling a building block approach. To make it possible to use components in the way required by this example, components of a similar kind (for example, blueprints that represent different kinds of database), all have a consistent interface. In Cloudify DSL, this interface is provided by the capabilitites
section in the blueprint. This is analogous to the use of interfaces or protocols in an object oriented programming paradigm.
Looking at the multi-Kubernetes cluster example, consider the object storage options minio
and S3
. Both of these are represented by a blueprint that exposes a single capability
: bucket_url
. Because of this standard “interface”, the blueprints can be substituted for each other at deploy time. You will find the same pattern for other elements: minikube/EKS (endpoint
), psql
/RDS
(host
, master_username
, master_password
), and so on.
Running the Example Implementation
Prerequisites
This example expects the following prerequisites:
-
A Cloudify Manager setup ready. This can be either a Cloudify Hosted service trial account, a Cloudify Premium Manager, or a Cloudify Community Manager.
-
The following plugins must be uploaded to the Cloudify Manager
- If running on AWS:
- AWS Plugin (version 2.5.6+)
- If running on Azure:
- Azure Plugin (version 3.0.10+)
- Kubernetes Plugin (version 2.9.3+)
- Terraform Plugin (version 0.15.0+)
- Fabric Plugin (version 2.0.7+)
- If running on AWS:
-
The following secrets must be defined on the Cloudify Manager
- AWS Specific:
aws_access_key_id
- The AWS access keyaws_secret_access_key
- The AWS secret key
- Azure Specific
azure_tenant_id
- The Azure Tenant IDazure_subscription_id
- The Azure subscription IDazure_client_id
- The Azure client IDazure_client_secret
- The Azure client secret
private_key_content
- The SSH private key contents from the keypairpublic_key_content
- The SSH public key contents from the keypaireaas_params
- See the example for the structure of this secret.
- AWS Specific:
-
Access to the cloud infrastructure you select is required to demonstrate this example. That can mean ability to allocate the required VMs and networking (ECS), and/or access to S3, RDS, and EKS, or the Azure equivalents.
-
These instructions use the CLI to run the example. Using the CLI requires an addition installation step unless the example is run on the manager itself, un which case it is pre-installed.
Install the Example
Our Environment-as-a-Service example on GitHub demonstrates a deploy-time selectable Kubernetes-based environment that includes object and relational storage external to the Kubernetes cluster. The three selectable environment types representing small and large development environments, and a production environment.
- Download or clone the example to your local system. If downloaded as an archive, the archive must be extracted.
- Upload each blueprint in the
infra
directory, and use the names from the table below:
Path | Name | File | Notes |
---|---|---|---|
infra/dev/minikube | minikube | blueprint.yaml | |
infra/dev/minio | minio | blueprint.yaml | |
infra/dev/multi_node | multi_node | aws-blueprint.yaml | AWS only |
infra/dev/multi_node | multi_node | azure-blueprint.yaml | Azure only |
infra/dev/psql | psql | aws-blueprint.yaml | AWS only |
infra/dev/psql | psql | azure-blueprint.yaml | Azure only |
infra/dev/single_node | single_node | aws-blueprint.yaml | AWS only |
infra/dev/single_node | single_node | azure-blueprint.yaml | Azure only |
infra/dev/vm | vm | aws-blueprint.yaml | AWS only |
infra/dev/vm | vm | azure-blueprint.yaml | Azure only |
infra/prod/eks | eks | blueprint.yaml | AWS only |
infra/prod/aks | aks | blueprint.yaml | Azure only |
infra/prod/prod_network | prod_network | aws-blueprint.yaml | AWS only |
infra/prod/prod_network | prod_network | azure-blueprint.yaml | Azure only |
infra/prod/rds_psql | rds_psql | aws-blueprint.yaml | AWS only |
infra/prod/rds_psql | rds_psql | azure-blueprint.yaml | Azure only |
infra/prod/s3 | s3 | aws-blueprint.yaml | AWS only |
infra/prod/s3 | s3 | azure-blueprint.yaml | Azure only |
infra/vpc | vpc | aws-blueprint.yaml | AWS only |
infra/rg | vpc | azure-blueprint.yaml | Azure only |
- Upload the application/main blueprint from
app/blueprint.yaml
. - Create a small development cluster:
cfy deployments create app_dev_small -b app -i env_type=dev-small
cfy executions start install -d app_dev_small
- Create a large development cluster:
cfy deployments create app_dev_large -b app -i env_type=dev-large
cfy executions start install -d app_dev_large
- Create a production cluster:
cfy deployments create app_prod -b app -i env_type=production
cfy executions start install -d app_prod