mirror of
https://github.com/tektoncd/catalog.git
synced 2024-11-21 05:55:35 +00:00
Add EKS cluster create/teardown tasks
This commit is contained in:
parent
81d5673a74
commit
689406cb9b
26
task/eks-cluster-create/0.1/README.md
Normal file
26
task/eks-cluster-create/0.1/README.md
Normal file
@ -0,0 +1,26 @@
|
||||
# EKS Cluster Create
|
||||
|
||||
The Task `eks-cluster-create` can be used to create an EKS cluster in an AWS account, using the `eksctl` command,
|
||||
and fetch a kubeconfig that can be used (in a context with both kubectl and aws credentials available) to make
|
||||
requests to the cluster.
|
||||
|
||||
## Parameters
|
||||
|
||||
* **cluster-name**: The name of the EKS cluster which you want to spin. (_required_)
|
||||
* **cluster-version**: The EKS version to install. (_default_:1.17)
|
||||
* **region**: The region where the cluster is in. (_default_:us-west-2)
|
||||
* **zones**: The zones where the cluster is in. (_default_:us-west-2a,us-west-2b,us-west-2c)
|
||||
* **nodegroup-name**: The name of the nodegroup of the cluster. (_default_:linux-nodes)
|
||||
* **node-type**: The type of the EC2 instaces for the nodegroup of the cluster. (_default_:m5.xlarge)
|
||||
* **desired-nodes**: The desired number of nodes in the cluster. (_default_:4)
|
||||
* **min-nodes**: The minimum number of nodes in the cluster. (_default_:1)
|
||||
* **max-nodes**: The maximum number of nodes in the cluster. (_default_:4)
|
||||
|
||||
## Workspaces
|
||||
|
||||
* **secrets**: A Secret containing the AWS credentials to run the create.
|
||||
* **kubeconfig**: A workspace into which a kubeconfig file called `kubeconfig` will be written that will contain the information required to access the cluster. The `kubeconfig` will expect to use [aws-iam-authenticator](https://github.com/kubernetes-sigs/aws-iam-authenticator/) to authenticate, so in order for it to be used it must be run in a container which contains both `kubectl` and `aws-iam-authenticator`.
|
||||
|
||||
## Usage
|
||||
|
||||
See [samples/create-eks-cluster.yaml](https://github.com/tektoncd/catalog/tree/master/task/eks-cluster-create/0.1/samples/create-eks-cluster.yaml) for an example of a TaskRun that creates a EKS cluster and writes the kubeconfig to a PVC.
|
70
task/eks-cluster-create/0.1/eks-cluster-create.yaml
Normal file
70
task/eks-cluster-create/0.1/eks-cluster-create.yaml
Normal file
@ -0,0 +1,70 @@
|
||||
apiVersion: tekton.dev/v1beta1
|
||||
kind: Task
|
||||
metadata:
|
||||
name: eks-cluster-create
|
||||
labels:
|
||||
app.kubernetes.io/version: "0.1"
|
||||
annotations:
|
||||
tekton.dev/pipelines.minVersion: "0.12.1"
|
||||
tekton.dev/tags: "aws, eks"
|
||||
tekton.dev/displayName: "EKS Cluster Create"
|
||||
spec:
|
||||
description: |
|
||||
Create an EKS cluster.
|
||||
|
||||
This Task can be used to create an EKS cluster in an AWS account and fetch a kubeconfig that
|
||||
can be used (in a context with kubectl) to make requests to the cluster.
|
||||
params:
|
||||
- name: cluster-name
|
||||
description: The name of the EKS cluster you want to spin.
|
||||
- name: version
|
||||
default: "1.17"
|
||||
description: The EKS version to install.
|
||||
- name: region
|
||||
default: us-west-2
|
||||
description: The region where the cluster is in.
|
||||
- name: zones
|
||||
default: us-west-2a,us-west-2b,us-west-2c
|
||||
description: The zones where the cluster is in.
|
||||
- name: nodegroup-name
|
||||
default: linux-nodes
|
||||
description: The name of the nodegroup of the cluster.
|
||||
- name: node-type
|
||||
default: m5.xlarge
|
||||
description: The type of the EC2 instaces for the nodegroup of the cluster.
|
||||
- name: desired-nodes
|
||||
default: "4"
|
||||
description: The desired number of nodes in the cluster.
|
||||
- name: min-nodes
|
||||
default: "1"
|
||||
description: The minimum number of nodes in the cluster.
|
||||
- name: max-nodes
|
||||
default: "4"
|
||||
description: The maximum number of nodes in the cluster.
|
||||
workspaces:
|
||||
- name: secrets
|
||||
mountPath: /tekton/home/.aws
|
||||
description: The secret with the AWS keys
|
||||
- name: kubeconfig
|
||||
description: |
|
||||
A workspace into which a kubeconfig file called `kubeconfig` will be written that will contain the information required to access the cluster. The `kubeconfig` will expect to use [aws-iam-authenticator](https://github.com/kubernetes-sigs/aws-iam-authenticator/) to authenticate, so in order for it to be used it must be run in a container which contains both `kubectl` and `aws-iam-authenticator`.
|
||||
steps:
|
||||
- name: write-kubeconfig
|
||||
image: weaveworks/eksctl:0.35.0@sha256:48c1fa508970a01fd87a73ac7932a7160479d678cd019a3c84533d911fc54327
|
||||
script: |
|
||||
echo "Starting to create eks cluster"
|
||||
eksctl create cluster \
|
||||
--name $(params.cluster-name) \
|
||||
--version $(params.version) \
|
||||
--region $(params.region) \
|
||||
--zones $(params.zones) \
|
||||
--nodegroup-name $(params.nodegroup-name) \
|
||||
--node-type $(params.node-type) \
|
||||
--nodes $(params.desired-nodes) \
|
||||
--nodes-min $(params.min-nodes) \
|
||||
--nodes-max $(params.max-nodes)
|
||||
if [ $? -eq 0 ]
|
||||
then
|
||||
echo "Successfully created eks cluster $(params.cluster-name)"
|
||||
eksctl utils write-kubeconfig -c $(params.cluster-name) --kubeconfig $(workspaces.kubeconfig.path)/kubeconfig
|
||||
fi
|
46
task/eks-cluster-create/0.1/samples/create-eks-cluster.yaml
Normal file
46
task/eks-cluster-create/0.1/samples/create-eks-cluster.yaml
Normal file
@ -0,0 +1,46 @@
|
||||
apiVersion: v1
|
||||
kind: PersistentVolumeClaim
|
||||
metadata:
|
||||
name: eks-create-kubeconfig-pvc
|
||||
spec:
|
||||
resources:
|
||||
requests:
|
||||
storage: 5M
|
||||
volumeMode: Filesystem
|
||||
accessModes:
|
||||
- ReadWriteOnce
|
||||
storageClassName: gp2
|
||||
---
|
||||
apiVersion: tekton.dev/v1beta1
|
||||
kind: TaskRun
|
||||
metadata:
|
||||
generateName: create-eks-cluster-
|
||||
spec:
|
||||
taskRef:
|
||||
name: eks-cluster-create
|
||||
params:
|
||||
- name: cluster-name
|
||||
value: cluster-1
|
||||
- name: version
|
||||
value: "1.17"
|
||||
- name: region
|
||||
value: us-west-2
|
||||
- name: zones
|
||||
value: us-west-2a,us-west-2b,us-west-2c
|
||||
- name: nodegroup-name
|
||||
value: linux-nodes
|
||||
- name: node-type
|
||||
value: m5.xlarge
|
||||
- name: desired-nodes
|
||||
value: "2"
|
||||
- name: min-nodes
|
||||
value: "1"
|
||||
- name: max-nodes
|
||||
value: "2"
|
||||
workspaces:
|
||||
- name: secrets
|
||||
secret:
|
||||
secretName: aws-credentials
|
||||
- name: kubeconfig
|
||||
persistentVolumeClaim:
|
||||
claimName: eks-create-kubeconfig-pvc
|
13
task/eks-cluster-create/0.1/samples/secret.yaml
Normal file
13
task/eks-cluster-create/0.1/samples/secret.yaml
Normal file
@ -0,0 +1,13 @@
|
||||
apiVersion: v1
|
||||
kind: Secret
|
||||
metadata:
|
||||
name: aws-credentials
|
||||
type: Opaque
|
||||
stringData:
|
||||
credentials: |-
|
||||
[default]
|
||||
aws_access_key_id = $(aws_access_key_id)
|
||||
aws_secret_access_key = $(aws_secret_access_key)
|
||||
config: |-
|
||||
[default]
|
||||
region = us-east-2
|
5
task/eks-cluster-create/OWNERS
Normal file
5
task/eks-cluster-create/OWNERS
Normal file
@ -0,0 +1,5 @@
|
||||
approvers:
|
||||
- theofpa
|
||||
|
||||
reviewers:
|
||||
- theofpa
|
26
task/eks-cluster-teardown/0.1/README.md
Normal file
26
task/eks-cluster-teardown/0.1/README.md
Normal file
@ -0,0 +1,26 @@
|
||||
# EKS Cluster Teardown
|
||||
|
||||
The Task `eks-cluster-teardown` can be used to teardown an EKS cluster in an AWS account, using the `eksctl` command.
|
||||
|
||||
## Parameters
|
||||
|
||||
* **cluster-name**: The name of the EKS cluster which will be teared down. (_required_)
|
||||
* **region**: The region where the cluster is in. (_default_:us-west-2)
|
||||
|
||||
## Workspaces
|
||||
|
||||
* **secrets**: A Secret containing the AWS credentials to run the teardown.
|
||||
|
||||
## Secret
|
||||
|
||||
AWS `credentials` and `config` both should be provided in the form of `secret`.
|
||||
|
||||
[This](https://github.com/tektoncd/catalog/tree/master/task/eks-cluster-teardown/0.1/samples/secret.yaml) example can be referred to create `aws-credentials`.
|
||||
|
||||
Refer [this](https://docs.aws.amazon.com/sdk-for-java/v1/developer-guide/setup-credentials.html) guide for setting up AWS Credentials and Region.
|
||||
|
||||
The AWS user/role should have the [minimum IAM policies](https://eksctl.io/usage/minimum-iam-policies/) defined by `eksctl`.
|
||||
|
||||
## Usage
|
||||
|
||||
See [samples/teardown-eks-cluster.yaml](https://github.com/tektoncd/catalog/tree/master/task/eks-cluster-teardown/0.1/samples/teardown-eks-cluster.yaml) for an example of a TaskRun that tears down an EKS cluster.
|
37
task/eks-cluster-teardown/0.1/eks-cluster-teardown.yaml
Normal file
37
task/eks-cluster-teardown/0.1/eks-cluster-teardown.yaml
Normal file
@ -0,0 +1,37 @@
|
||||
apiVersion: tekton.dev/v1beta1
|
||||
kind: Task
|
||||
metadata:
|
||||
name: eks-cluster-teardown
|
||||
labels:
|
||||
app.kubernetes.io/version: "0.1"
|
||||
annotations:
|
||||
tekton.dev/pipelines.minVersion: "0.12.1"
|
||||
tekton.dev/tags: "aws, eks"
|
||||
tekton.dev/displayName: "EKS Cluster Teardown"
|
||||
spec:
|
||||
description: |
|
||||
Teardown an EKS cluster.
|
||||
|
||||
This Task can be used to teardown an EKS cluster in an AWS account.
|
||||
params:
|
||||
- name: cluster-name
|
||||
description: The name of the EKS cluster which will be teared down.
|
||||
- name: region
|
||||
default: us-west-2
|
||||
description: The region where the cluster is in.
|
||||
workspaces:
|
||||
- name: secrets
|
||||
mountPath: /tekton/home/.aws
|
||||
description: The service account with the AWS keys
|
||||
steps:
|
||||
- name: delete-cluster
|
||||
image: weaveworks/eksctl:0.35.0@sha256:48c1fa508970a01fd87a73ac7932a7160479d678cd019a3c84533d911fc54327
|
||||
script: |
|
||||
echo "Tearing down the eks cluster"
|
||||
eksctl delete cluster \
|
||||
--name $(params.cluster-name) \
|
||||
--region $(params.region)
|
||||
if [ $? -eq 0 ]
|
||||
then
|
||||
echo "Successfully teared down eks cluster $(params.cluster-name)"
|
||||
fi
|
13
task/eks-cluster-teardown/0.1/samples/secret.yaml
Normal file
13
task/eks-cluster-teardown/0.1/samples/secret.yaml
Normal file
@ -0,0 +1,13 @@
|
||||
apiVersion: v1
|
||||
kind: Secret
|
||||
metadata:
|
||||
name: aws-credentials
|
||||
type: Opaque
|
||||
stringData:
|
||||
credentials: |-
|
||||
[default]
|
||||
aws_access_key_id = $(aws_access_key_id)
|
||||
aws_secret_access_key = $(aws_secret_access_key)
|
||||
config: |-
|
||||
[default]
|
||||
region = us-east-2
|
@ -0,0 +1,16 @@
|
||||
apiVersion: tekton.dev/v1beta1
|
||||
kind: TaskRun
|
||||
metadata:
|
||||
generateName: teardown-eks-cluster-
|
||||
spec:
|
||||
taskRef:
|
||||
name: eks-cluster-teardown
|
||||
params:
|
||||
- name: cluster-name
|
||||
value: cluster-1
|
||||
- name: region
|
||||
value: us-west-2
|
||||
workspaces:
|
||||
- name: secrets
|
||||
secret:
|
||||
secretName: aws-credentials
|
5
task/eks-cluster-teardown/OWNERS
Normal file
5
task/eks-cluster-teardown/OWNERS
Normal file
@ -0,0 +1,5 @@
|
||||
approvers:
|
||||
- theofpa
|
||||
|
||||
reviewers:
|
||||
- theofpa
|
Loading…
Reference in New Issue
Block a user