Skip to content

Commit

Permalink
Removing pipelineruns
Browse files Browse the repository at this point in the history
  • Loading branch information
njtran committed Jul 5, 2022
1 parent a9c80fe commit 2f7efc3
Show file tree
Hide file tree
Showing 9 changed files with 169 additions and 243 deletions.
10 changes: 5 additions & 5 deletions test/infrastructure/rbac.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ metadata:
app.kubernetes.io/instance: default
app.kubernetes.io/part-of: tekton-dashboard
name: tekton
namespace: tekton-tests
namespace: karpenter-tests
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
Expand Down Expand Up @@ -57,7 +57,7 @@ roleRef:
subjects:
- kind: ServiceAccount
name: tekton
namespace: tekton-tests
namespace: karpenter-tests
- kind: Group
name: tekton
apiGroup: rbac.authorization.k8s.io
Expand All @@ -71,7 +71,7 @@ metadata:
app.kubernetes.io/instance: default
app.kubernetes.io/part-of: tekton-dashboard
name: tekton-pipelines-executor
namespace: tekton-tests
namespace: karpenter-tests
rules:
- apiGroups: ["kit.k8s.sh"]
resources: ["controlplanes", "dataplanes"]
Expand Down Expand Up @@ -106,15 +106,15 @@ metadata:
app.kubernetes.io/instance: default
app.kubernetes.io/part-of: tekton-dashboard
name: tekton-pipelines-executor
namespace: tekton-tests
namespace: karpenter-tests
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: Role
name: tekton-pipelines-executor
subjects:
- kind: ServiceAccount
name: tekton
namespace: tekton-tests
namespace: karpenter-tests
- kind: Group
name: tekton
apiGroup: rbac.authorization.k8s.io
9 changes: 5 additions & 4 deletions test/infrastructure/scripts/step-10-tekton-permissions.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
if [ -z "$(kubectl get ns tekton-tests)" ]; then
kubectl create ns tekton-tests

if [ -z "$(kubectl get ns karpenter-tests)" ] ; then
kubectl create ns karpenter-tests
fi

kubectl apply -f ${SCRIPTPATH}/rbac.yaml

eksctl create iamserviceaccount \
--cluster "${CLUSTER_NAME}" --name tekton --namespace tekton-tests \
--cluster "${CLUSTER_NAME}" --name tekton --namespace karpenter-tests \
--role-name "${CLUSTER_NAME}-tekton" \
--attach-policy-arn "arn:aws:iam::${AWS_ACCOUNT_ID}:policy/TektonPodPolicy-${CLUSTER_NAME}" \
--role-only \
Expand All @@ -18,4 +19,4 @@ kubectl patch configmap/aws-auth -n kube-system --patch "$(cat /tmp/aws-auth-pat

kubectl annotate --overwrite serviceaccount -n tekton-tests tekton "eks.amazonaws.com/role-arn=arn:aws:iam::${AWS_ACCOUNT_ID}:role/${CLUSTER_NAME}-tekton"

echo "Installed IRSA for Tekton pods in tekton-tests namespace."
echo "Installed IRSA for Tekton pods in karpenter-tests namespace."
2 changes: 1 addition & 1 deletion test/suites/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ Tekton CRDs used here are distinguished as Tasks, Pipelines, and PipelineRuns. T
After creating these resources using kubectl, you can use the tekton CLI to run these quickly without having to navigate the Tekton UI or delete and re-create the resources. The most common command to utilize the existing configs is to instantiate pipeline runs.

To run a tekton pipeline with a [pod template](https://tekton.dev/docs/pipelines/podtemplates/) for Task pods, take the following example:
- `tkn pipeline start create-kit-pipeline -n tekton-tests --pod-template pod-template.yaml -s tekton`
- `tkn pipeline start create-kit-pipeline -n karpenter-tests --pod-template pod-template.yaml -s tekton`
25 changes: 6 additions & 19 deletions test/suites/examples/create-eks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ apiVersion: tekton.dev/v1beta1
kind: Task
metadata:
name: create-eks-task
namespace: tekton-tests
namespace: karpenter-tests
spec:
description: |
Create an EKS cluster and MNG.
Expand All @@ -12,19 +12,20 @@ spec:
description: The name of the EKS cluster you want to spin up.
- name: k8s-version
description: The K8s version used for the cluster.
- name: aws-region
description: The region where the cluster will be created.
steps:
- name: create-cluster
image: docker.io/weaveworks/eksctl:v0.86.0
script: |
TOKEN=$(curl -X PUT "http://169.254.169.254/latest/api/token" -H "X-aws-ec2-metadata-token-ttl-seconds: 21600")
export AWS_REGION=$(curl -H "X-aws-ec2-metadata-token: $TOKEN" -v http://169.254.169.254/latest/meta-data/)
eksctl create cluster -f - << EOF
---
apiVersion: eksctl.io/v1alpha5
kind: ClusterConfig
metadata:
name: $(params.cluster-name)
region: $(params.aws-region)
region: ${AWS_REGION}
version: "$(params.k8s-version)"
tags:
karpenter.sh/discovery: $(params.cluster-name)
Expand All @@ -44,7 +45,7 @@ apiVersion: tekton.dev/v1beta1
kind: Pipeline
metadata:
name: create-eks-pipeline
namespace: tekton-tests
namespace: karpenter-tests
spec:
tasks:
- name: create-eks
Expand All @@ -55,17 +56,3 @@ spec:
value: 'test-eks-cluster'
- name: k8s-version
value: '1.21'
- name: aws-region
value: 'us-west-2'
---
apiVersion: tekton.dev/v1beta1
kind: PipelineRun
metadata:
name: create-eks-pipelinerun
namespace: tekton-tests
spec:
pipelineRef:
name: create-eks-pipeline
podTemplate:
nodeSelector:
kubernetes.io/arch: amd64
65 changes: 18 additions & 47 deletions test/suites/examples/create-kit.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ apiVersion: tekton.dev/v1beta1
kind: Task
metadata:
name: ping-aws-cli-task
namespace: tekton-tests
namespace: karpenter-tests
spec:
description: |
Ping AWS to test connectivity
steps:
- name: hello-world
image: docker.io/njtran/scratch:latest
image: public.ecr.aws/karpenter-testing/minimal:latest
script: |
aws sts get-caller-identity
Expand All @@ -18,35 +18,27 @@ apiVersion: tekton.dev/v1beta1
kind: Task
metadata:
name: create-kit-task
namespace: tekton-tests
namespace: karpenter-tests
spec:
description: |
Create a KIT Guest Cluster in the existing cluster. This installs aws-vpc-cni, approves the KCM request, and creates the Control Plane in the management cluster.
params:
- name: guest-cluster-name
description: Name of KIT guest cluster
- name: aws-region
description: AWS Region where cluster will be deployed
- name: pod-image
description: Docker image used for Tekton Pods
- name: provisioner-name
description: Name of Provisioner for KIT Guest Cluster resources
default: "default"
workspaces:
- name: config
description: |
Directory where kubeconfig for the Guest Cluster lives
steps:
- name: deploy-kit-control-plane
image: $(params.pod-image)
image: public.ecr.aws/karpenter-testing/minimal:latest
script: |
echo "Deploying KIT Guest Cluster Control Plane"
namespace=$(kubectl get ns tekton-tests -o yaml | grep phase | awk '{print $2}') || true
namespace=$(kubectl get ns karpenter-tests -o yaml | grep phase | awk '{print $2}') || true
if [[ $namespace != "Active" ]]
then
echo "Create namespace"
kubectl create namespace tekton-tests
kubectl create namespace karpenter-tests
fi
echo "Setting up control plane"
Expand All @@ -56,14 +48,14 @@ spec:
kind: ControlPlane
metadata:
name: $(params.guest-cluster-name) # Desired Cluster name
namespace: tekton-tests
namespace: karpenter-tests
spec: {}
EOF
echo "Getting kube admin config"
for i in $(seq 1 30)
do
data=$(kubectl get secret -n tekton-tests $(params.guest-cluster-name)-kube-admin-config -ojsonpath='{.data.config}') || true
data=$(kubectl get secret -n karpenter-tests $(params.guest-cluster-name)-kube-admin-config -ojsonpath='{.data.config}') || true
if [[ ! -z "$data" ]]; then
echo "Got a Control Plane secret!"
echo $data | base64 -d > /tmp/kubeconfig
Expand All @@ -73,18 +65,19 @@ spec:
done
echo "Waiting for the APIserver endpoint to be ready"
endpoint=$(cat /tmp/kubeconfig | grep server | awk '{print $2}')
for i in $(seq 1 30)
for i in $(seq 1 60)
do
state=$(curl -k --connect-timeout 5 -s $endpoint/healthz) 2>/dev/null || true
if [[ ! -z "$state" ]]; then
echo "Connected to Guest Cluster Endpoint"
break
fi
sleep 10
done
echo "Installing CNI"
kubectl --kubeconfig=/tmp/kubeconfig apply -f https://raw.githubusercontent.com/aws/amazon-vpc-cni-k8s/release-1.10/config/master/aws-k8s-cni.yaml
- name: deploy-kit-data-plane
image: $(params.pod-image)
image: public.ecr.aws/karpenter-testing/minimal:latest
script: |
echo "Deploying KIT Guest Cluster Data Plane"
echo "Getting subnet and security group tags"
Expand All @@ -95,29 +88,33 @@ spec:
kind: DataPlane
metadata:
name: $(params.guest-cluster-name)
namespace: tekton-tests
namespace: karpenter-tests
spec:
clusterName: $(params.guest-cluster-name) # Associated Cluster name
nodeCount: 1
subnetSelector:
karpenter.sh/discovery: ${TAG}
instanceTypes:
- m5.2xlarge
- m5a.2xlarge
EOF
echo "Getting kube admin config"
kubectl get secret -n tekton-tests $(params.guest-cluster-name)-kube-admin-config -ojsonpath='{.data.config}' | base64 -d > /tmp/kubeconfig
kubectl get secret -n karpenter-tests $(params.guest-cluster-name)-kube-admin-config -ojsonpath='{.data.config}' | base64 -d > /tmp/kubeconfig
echo "Waiting for the worker nodes to be ready"
while true; do
ready_node=$(kubectl --kubeconfig=/tmp/kubeconfig get nodes | grep -w Ready | wc -l)
if [[ "$ready_node" -eq 1 ]]; then break; fi
sleep 5
done
kubectl --kubeconfig=/tmp/kubeconfig get nodes
kubectl --kubeconifg=/tmp/kubeconfig certificate approve $(kubectl --kubeconfig=/tmp/kubeconfig get csr | grep "Pending" | awk '{print $1}')
---
apiVersion: tekton.dev/v1beta1
kind: Pipeline
metadata:
name: create-kit-pipeline
namespace: tekton-tests
namespace: karpenter-tests
spec:
tasks:
- name: ping-aws-cli
Expand All @@ -131,29 +128,3 @@ spec:
params:
- name: guest-cluster-name
value: "kit-guest-cluster"
- name: aws-region
value: "us-west-2"
- name: pod-image
value: "docker.io/njtran/scratch:latest"
workspaces:
- name: config
workspace: ws
workspaces:
- name: ws
description: The folder where we write the kubeconfig to
---
apiVersion: tekton.dev/v1beta1
kind: PipelineRun
metadata:
name: create-kit-pipelinerun
namespace: tekton-tests
spec:
serviceAccountName: tekton
pipelineRef:
name: create-kit-pipeline
podTemplate:
nodeSelector:
kubernetes.io/arch: amd64
workspaces:
- name: ws
emptyDir: {}
Loading

0 comments on commit 2f7efc3

Please sign in to comment.