From f9e721b77ccade2070a024a65c9a5938b192068a Mon Sep 17 00:00:00 2001 From: hakuna-matatah Date: Fri, 1 Dec 2023 17:25:24 -0800 Subject: [PATCH 1/4] Revert "Refactor pipeline defaults (#435)" This reverts commit 73ba59ffe8153482b468b28179b716483c496d4f. --- tests/pipelines/eks/awscli-cl2-load-with-addons.yaml | 4 ++-- tests/pipelines/eks/awscli-eks-cl2-load.yaml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/pipelines/eks/awscli-cl2-load-with-addons.yaml b/tests/pipelines/eks/awscli-cl2-load-with-addons.yaml index ecd22845..6967c7ed 100644 --- a/tests/pipelines/eks/awscli-cl2-load-with-addons.yaml +++ b/tests/pipelines/eks/awscli-cl2-load-with-addons.yaml @@ -16,9 +16,9 @@ spec: - name: slack-message - name: amp-workspace-id - name: vpc-cfn-url - default: "https://raw.githubusercontent.com/awslabs/kubernetes-iteration-toolkit/main/tests/assets/amazon-eks-vpc.json" + value: "https://raw.githubusercontent.com/awslabs/kubernetes-iteration-toolkit/main/tests/assets/amazon-eks-vpc.json" - name: ng-cfn-url - default: "https://raw.githubusercontent.com/awslabs/kubernetes-iteration-toolkit/main/tests/assets/eks_nodeGroup_launch_template.json" + value: "https://raw.githubusercontent.com/awslabs/kubernetes-iteration-toolkit/main/tests/assets/eks_nodeGroup_launch_template.json" - name: kubernetes-version - name: service-role-cfn-url default: "https://raw.githubusercontent.com/awslabs/kubernetes-iteration-toolkit/main/tests/assets/eks_service_role.json" diff --git a/tests/pipelines/eks/awscli-eks-cl2-load.yaml b/tests/pipelines/eks/awscli-eks-cl2-load.yaml index 1899fcde..2edbf857 100644 --- a/tests/pipelines/eks/awscli-eks-cl2-load.yaml +++ b/tests/pipelines/eks/awscli-eks-cl2-load.yaml @@ -18,9 +18,9 @@ spec: - name: slack-hook - name: slack-message - name: vpc-cfn-url - default: "https://raw.githubusercontent.com/awslabs/kubernetes-iteration-toolkit/main/tests/assets/amazon-eks-vpc.json" + value: "https://raw.githubusercontent.com/awslabs/kubernetes-iteration-toolkit/main/tests/assets/amazon-eks-vpc.json" - name: ng-cfn-url - default: "https://raw.githubusercontent.com/awslabs/kubernetes-iteration-toolkit/main/tests/assets/eks_nodeGroup_launch_template.json" + value: "https://raw.githubusercontent.com/awslabs/kubernetes-iteration-toolkit/main/tests/assets/eks_nodeGroup_launch_template.json" - name: kubernetes-version default: "1.23" - name: amp-workspace-id From 32f0c79e9dd2e5279189243d35230d2e9496bc5f Mon Sep 17 00:00:00 2001 From: hakuna-matatah Date: Fri, 1 Dec 2023 17:26:26 -0800 Subject: [PATCH 2/4] Revert "Refactoring assets folder (#434)" This reverts commit 3f233238d15d0f38a14e290f6975f3190e88cf85. --- .../assets/eks_nodeGroup_LaunchTemplate.yaml | 67 +++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 tests/assets/eks_nodeGroup_LaunchTemplate.yaml diff --git a/tests/assets/eks_nodeGroup_LaunchTemplate.yaml b/tests/assets/eks_nodeGroup_LaunchTemplate.yaml new file mode 100644 index 00000000..896acab1 --- /dev/null +++ b/tests/assets/eks_nodeGroup_LaunchTemplate.yaml @@ -0,0 +1,67 @@ +AWSTemplateFormatVersion: '2010-09-09' +Description: Create an EKS Node Group Launch Template + +Parameters: + LaunchTemplateName: + Type: String + Description: Name of the Launch Template + + ClusterName: + Type: String + Description: Name of the Cluster + + ImageId: + Type: String + Description: Latest AMI for a given kubernetes version + + ClusterCA: + Type: String + Description: Base64-encoded cluster CA certificate + + APIServerEndpoint: + Type: String + Description: API server endpoint URL + + DNSClusterIPRange: + Type: String + Description: DNS cluster IP range + +Resources: + NodeGroupLaunchTemplate: + Type: AWS::EC2::LaunchTemplate + Properties: + LaunchTemplateName: !Ref LaunchTemplateName + LaunchTemplateData: + ImageId: !Ref ImageId + BlockDeviceMappings: + - DeviceName: /dev/xvda + Ebs: + VolumeSize: 20 + VolumeType: gp2 + UserData: !Base64 + "Fn::Sub": | + MIME-Version: 1.0 + Content-Type: multipart/mixed; boundary="==MYBOUNDARY==" + + --==MYBOUNDARY== + Content-Type: text/x-shellscript; charset="us-ascii" + + #!/bin/bash + set -ex + + /etc/eks/bootstrap.sh ${ClusterName} \ + --b64-cluster-ca ${ClusterCA} \ + --apiserver-endpoint ${APIServerEndpoint} \ + --dns-cluster-ip ${DNSClusterIPRange} \ + --container-runtime containerd + + --==MYBOUNDARY==-- + MetadataOptions: + HttpPutResponseHopLimit: 2 + HttpEndpoint: enabled + HttpTokens: required + +Outputs: + NodeGroupLaunchTemplateName: + Description: Name of the Node Group Launch Template + Value: !Ref NodeGroupLaunchTemplate \ No newline at end of file From bb39396611885eb3e7923cd9c1488bf3765794ea Mon Sep 17 00:00:00 2001 From: hakuna-matatah Date: Fri, 1 Dec 2023 17:27:11 -0800 Subject: [PATCH 3/4] Revert "Converting launch template to json (#431)" This reverts commit c9d8fc3d15a166819646d1a1b90bac7520037616. --- .../assets/eks_nodeGroup_launch_template.json | 66 ------------------- .../eks/awscli-cl2-load-with-addons.yaml | 2 - tests/pipelines/eks/awscli-eks-cl2-load.yaml | 2 - 3 files changed, 70 deletions(-) delete mode 100644 tests/assets/eks_nodeGroup_launch_template.json diff --git a/tests/assets/eks_nodeGroup_launch_template.json b/tests/assets/eks_nodeGroup_launch_template.json deleted file mode 100644 index 70cb8e29..00000000 --- a/tests/assets/eks_nodeGroup_launch_template.json +++ /dev/null @@ -1,66 +0,0 @@ -{ - "AWSTemplateFormatVersion": "2010-09-09", - "Description": "Create an EKS Node Group Launch Template", - "Parameters": { - "LaunchTemplateName": { - "Type": "String", - "Description": "Name of the Launch Template" - }, - "ClusterName": { - "Type": "String", - "Description": "Name of the Cluster" - }, - "ImageId": { - "Type": "String", - "Description": "Latest AMI for a given Kubernetes version" - }, - "ClusterCA": { - "Type": "String", - "Description": "Base64-encoded cluster CA certificate" - }, - "APIServerEndpoint": { - "Type": "String", - "Description": "API server endpoint URL" - }, - "DNSClusterIPRange": { - "Type": "String", - "Description": "DNS cluster IP range" - } - }, - "Resources": { - "NodeGroupLaunchTemplate": { - "Type": "AWS::EC2::LaunchTemplate", - "Properties": { - "LaunchTemplateName": { "Ref": "LaunchTemplateName" }, - "LaunchTemplateData": { - "ImageId": { "Ref": "ImageId" }, - "BlockDeviceMappings": [ - { - "DeviceName": "/dev/xvda", - "Ebs": { - "VolumeSize": 20, - "VolumeType": "gp2" - } - } - ], - "UserData": { - "Fn::Base64": { - "Fn::Sub": "MIME-Version: 1.0\nContent-Type: multipart/mixed; boundary=\"==MYBOUNDARY==\"\n\n--==MYBOUNDARY==\nContent-Type: text/x-shellscript; charset=\"us-ascii\"\n\n#!/bin/bash\nset -ex\n/etc/eks/bootstrap.sh ${ClusterName} --b64-cluster-ca ${ClusterCA} --apiserver-endpoint ${APIServerEndpoint} --dns-cluster-ip ${DNSClusterIPRange} --container-runtime containerd\n--==MYBOUNDARY==--" - } - }, - "MetadataOptions": { - "HttpPutResponseHopLimit": 2, - "HttpEndpoint": "enabled", - "HttpTokens": "required" - } - } - } - } - }, - "Outputs": { - "NodeGroupLaunchTemplateName": { - "Description": "Name of the Node Group Launch Template", - "Value": { "Ref": "NodeGroupLaunchTemplate" } - } - } -} \ No newline at end of file diff --git a/tests/pipelines/eks/awscli-cl2-load-with-addons.yaml b/tests/pipelines/eks/awscli-cl2-load-with-addons.yaml index 6967c7ed..52f1a6c3 100644 --- a/tests/pipelines/eks/awscli-cl2-load-with-addons.yaml +++ b/tests/pipelines/eks/awscli-cl2-load-with-addons.yaml @@ -16,9 +16,7 @@ spec: - name: slack-message - name: amp-workspace-id - name: vpc-cfn-url - value: "https://raw.githubusercontent.com/awslabs/kubernetes-iteration-toolkit/main/tests/assets/amazon-eks-vpc.json" - name: ng-cfn-url - value: "https://raw.githubusercontent.com/awslabs/kubernetes-iteration-toolkit/main/tests/assets/eks_nodeGroup_launch_template.json" - name: kubernetes-version - name: service-role-cfn-url default: "https://raw.githubusercontent.com/awslabs/kubernetes-iteration-toolkit/main/tests/assets/eks_service_role.json" diff --git a/tests/pipelines/eks/awscli-eks-cl2-load.yaml b/tests/pipelines/eks/awscli-eks-cl2-load.yaml index 2edbf857..64a0f1a3 100644 --- a/tests/pipelines/eks/awscli-eks-cl2-load.yaml +++ b/tests/pipelines/eks/awscli-eks-cl2-load.yaml @@ -18,9 +18,7 @@ spec: - name: slack-hook - name: slack-message - name: vpc-cfn-url - value: "https://raw.githubusercontent.com/awslabs/kubernetes-iteration-toolkit/main/tests/assets/amazon-eks-vpc.json" - name: ng-cfn-url - value: "https://raw.githubusercontent.com/awslabs/kubernetes-iteration-toolkit/main/tests/assets/eks_nodeGroup_launch_template.json" - name: kubernetes-version default: "1.23" - name: amp-workspace-id From 51a6c872e49d41642c3efa351f9426e3b97fdcb5 Mon Sep 17 00:00:00 2001 From: hakuna-matatah Date: Fri, 1 Dec 2023 17:27:39 -0800 Subject: [PATCH 4/4] Revert "PVRE reporting for short lived instances (#427)" This reverts commit 5f48bf64e725f680e598bde2abbf24f7e3f15975. --- .../assets/eks_nodeGroup_LaunchTemplate.yaml | 67 ------------------ .../eks/awscli-cl2-load-with-addons.yaml | 25 +------ tests/pipelines/eks/awscli-eks-cl2-load.yaml | 25 +------ tests/tasks/setup/eks/awscli-cfn-lt.yaml | 69 ------------------- tests/tasks/setup/eks/awscli-mng.yaml | 3 - tests/tasks/teardown/awscli-eks.yaml | 2 - tests/tasks/teardown/awscli-vpc-delete.yaml | 2 +- 7 files changed, 3 insertions(+), 190 deletions(-) delete mode 100644 tests/assets/eks_nodeGroup_LaunchTemplate.yaml delete mode 100644 tests/tasks/setup/eks/awscli-cfn-lt.yaml diff --git a/tests/assets/eks_nodeGroup_LaunchTemplate.yaml b/tests/assets/eks_nodeGroup_LaunchTemplate.yaml deleted file mode 100644 index 896acab1..00000000 --- a/tests/assets/eks_nodeGroup_LaunchTemplate.yaml +++ /dev/null @@ -1,67 +0,0 @@ -AWSTemplateFormatVersion: '2010-09-09' -Description: Create an EKS Node Group Launch Template - -Parameters: - LaunchTemplateName: - Type: String - Description: Name of the Launch Template - - ClusterName: - Type: String - Description: Name of the Cluster - - ImageId: - Type: String - Description: Latest AMI for a given kubernetes version - - ClusterCA: - Type: String - Description: Base64-encoded cluster CA certificate - - APIServerEndpoint: - Type: String - Description: API server endpoint URL - - DNSClusterIPRange: - Type: String - Description: DNS cluster IP range - -Resources: - NodeGroupLaunchTemplate: - Type: AWS::EC2::LaunchTemplate - Properties: - LaunchTemplateName: !Ref LaunchTemplateName - LaunchTemplateData: - ImageId: !Ref ImageId - BlockDeviceMappings: - - DeviceName: /dev/xvda - Ebs: - VolumeSize: 20 - VolumeType: gp2 - UserData: !Base64 - "Fn::Sub": | - MIME-Version: 1.0 - Content-Type: multipart/mixed; boundary="==MYBOUNDARY==" - - --==MYBOUNDARY== - Content-Type: text/x-shellscript; charset="us-ascii" - - #!/bin/bash - set -ex - - /etc/eks/bootstrap.sh ${ClusterName} \ - --b64-cluster-ca ${ClusterCA} \ - --apiserver-endpoint ${APIServerEndpoint} \ - --dns-cluster-ip ${DNSClusterIPRange} \ - --container-runtime containerd - - --==MYBOUNDARY==-- - MetadataOptions: - HttpPutResponseHopLimit: 2 - HttpEndpoint: enabled - HttpTokens: required - -Outputs: - NodeGroupLaunchTemplateName: - Description: Name of the Node Group Launch Template - Value: !Ref NodeGroupLaunchTemplate \ No newline at end of file diff --git a/tests/pipelines/eks/awscli-cl2-load-with-addons.yaml b/tests/pipelines/eks/awscli-cl2-load-with-addons.yaml index 52f1a6c3..66cc3bd8 100644 --- a/tests/pipelines/eks/awscli-cl2-load-with-addons.yaml +++ b/tests/pipelines/eks/awscli-cl2-load-with-addons.yaml @@ -16,7 +16,6 @@ spec: - name: slack-message - name: amp-workspace-id - name: vpc-cfn-url - - name: ng-cfn-url - name: kubernetes-version - name: service-role-cfn-url default: "https://raw.githubusercontent.com/awslabs/kubernetes-iteration-toolkit/main/tests/assets/eks_service_role.json" @@ -90,26 +89,6 @@ spec: workspaces: - name: config workspace: config - - name: create-launch-template - params: - - name: cluster-name - value: $(params.cluster-name) - - name: stack-name - value: $(params.cluster-name)-launch-template - - name: kubernetes-version - value: "$(params.kubernetes-version)" - - name: ng-cfn-url - value: "$(params.ng-cfn-url)" - - name: endpoint - value: $(params.endpoint) - runAfter: - - create-eks-cluster - taskRef: - kind: Task - name: awscli-eks-cfn-launch-template - workspaces: - - name: config - workspace: config - name: create-mng-monitoring-nodes params: - name: cluster-name @@ -129,7 +108,7 @@ spec: - name: nodegroup-prefix value: "monitoring-" runAfter: - - create-launch-template + - create-eks-cluster taskRef: kind: Task name: awscli-eks-nodegroup-create @@ -235,8 +214,6 @@ spec: value: $(params.cluster-name)-service-role - name: node-role-stack-name value: $(params.cluster-name)-node-role - - name: launch-template-stack-name - value: $(params.cluster-name)-launch-template taskRef: kind: Task name: awscli-eks-cluster-teardown diff --git a/tests/pipelines/eks/awscli-eks-cl2-load.yaml b/tests/pipelines/eks/awscli-eks-cl2-load.yaml index 64a0f1a3..aaef0c83 100644 --- a/tests/pipelines/eks/awscli-eks-cl2-load.yaml +++ b/tests/pipelines/eks/awscli-eks-cl2-load.yaml @@ -18,7 +18,6 @@ spec: - name: slack-hook - name: slack-message - name: vpc-cfn-url - - name: ng-cfn-url - name: kubernetes-version default: "1.23" - name: amp-workspace-id @@ -89,26 +88,6 @@ spec: workspaces: - name: config workspace: config - - name: create-cfn-launch-template - params: - - name: cluster-name - value: $(params.cluster-name) - - name: stack-name - value: $(params.cluster-name)-launch-template - - name: kubernetes-version - value: "$(params.kubernetes-version)" - - name: ng-cfn-url - value: "$(params.ng-cfn-url)" - - name: endpoint - value: $(params.endpoint) - runAfter: - - create-eks-cluster - taskRef: - kind: Task - name: awscli-eks-cfn-launch-template - workspaces: - - name: config - workspace: config - name: create-mng-monitoring-nodes params: - name: cluster-name @@ -128,7 +107,7 @@ spec: - name: nodegroup-prefix value: "monitoring-" runAfter: - - create-cfn-launch-template + - create-eks-cluster taskRef: kind: Task name: awscli-eks-nodegroup-create @@ -222,8 +201,6 @@ spec: value: $(params.cluster-name)-service-role - name: node-role-stack-name value: $(params.cluster-name)-node-role - - name: launch-template-stack-name - value: $(params.cluster-name)-launch-template taskRef: kind: Task name: awscli-eks-cluster-teardown diff --git a/tests/tasks/setup/eks/awscli-cfn-lt.yaml b/tests/tasks/setup/eks/awscli-cfn-lt.yaml deleted file mode 100644 index 235dfe37..00000000 --- a/tests/tasks/setup/eks/awscli-cfn-lt.yaml +++ /dev/null @@ -1,69 +0,0 @@ ---- -apiVersion: tekton.dev/v1beta1 -kind: Task -metadata: - name: awscli-eks-cfn-launch-template - namespace: scalability -spec: - description: | - Create an EKS CFN stack to output a launch template. - This Task can be used to create an EKS CFN stack that outputs a launch template. - params: - - name: cluster-name - description: EKS cluster you want to create CFN stack for. - - name: stack-name - description: Stack name you want to spin. - - name: region - default: "us-west-2" - description: The region where the cluster is in. - - name: kubernetes-version - default: "1.28" - description: The EKS version to install. - - name: ng-cfn-url - description: The url of the CFN YAML/JSON to create CFN stack for NG launch template - - name: endpoint - default: "" - workspaces: - - name: config - mountPath: /config/ - stepTemplate: - env: - - name: KUBECONFIG - value: /config/kubeconfig - steps: - - name: create-launch-template - image: alpine/k8s:1.23.7 - script: | - ENDPOINT_FLAG="" - if [ -n "$(params.endpoint)" ]; then - ENDPOINT_FLAG="--endpoint $(params.endpoint)" - fi - - curl -s $(params.ng-cfn-url) -o ./amazon-ng-cfn - - launch_template_name=$(params.cluster-name)-launchTemplate - certificate_authority=$(aws eks $ENDPOINT_FLAG describe-cluster --query "cluster.certificateAuthority.data" --output text --name $(params.cluster-name) --region $(params.region)) - api_server_endpoint=$(aws eks $ENDPOINT_FLAG describe-cluster --query "cluster.endpoint" --output text --name $(params.cluster-name) --region $(params.region)) - dns_cluster_ip=$(aws eks $ENDPOINT_FLAG describe-cluster --query "cluster.kubernetesNetworkConfig.serviceIpv4Cidr" --output text --name $(params.cluster-name) --region $(params.region)) - image_id=$(aws ssm get-parameter --name "/aws/service/eks/optimized-ami/$(params.kubernetes-version)/amazon-linux-2/recommended/image_id" --query "Parameter.Value" --output text) - - STACK_NAME=$(params.stack-name) - STACK_STATUS=$(aws cloudformation describe-stacks --query 'Stacks[?StackName==`'${STACK_NAME}'`].StackStatus' --output text --region $(params.region)) - - if [[ "$STACK_STATUS" == "" ]]; then - aws cloudformation create-stack \ - --stack-name $STACK_NAME \ - --template-body file://$(pwd)/amazon-ng-cfn \ - --parameters ParameterKey=LaunchTemplateName,ParameterValue=$launch_template_name\ - ParameterKey=ImageId,ParameterValue=$image_id\ - ParameterKey=ClusterName,ParameterValue=$(params.cluster-name)\ - ParameterKey=ClusterCA,ParameterValue=$certificate_authority\ - ParameterKey=APIServerEndpoint,ParameterValue=$api_server_endpoint\ - ParameterKey=DNSClusterIPRange,ParameterValue=$dns_cluster_ip\ - --region $(params.region) - - aws cloudformation wait stack-create-complete --stack-name $STACK_NAME --region $(params.region) - echo "CREATED_CFN_STACK=$STACK_NAME" - else - echo "$STACK_NAME Already exists" - fi \ No newline at end of file diff --git a/tests/tasks/setup/eks/awscli-mng.yaml b/tests/tasks/setup/eks/awscli-mng.yaml index ab38b7f5..0a2561b7 100644 --- a/tests/tasks/setup/eks/awscli-mng.yaml +++ b/tests/tasks/setup/eks/awscli-mng.yaml @@ -75,11 +75,9 @@ spec: asgs=$((nodes/max_nodes)) echo "asgs: $asgs" node_group=$(params.nodegroup-prefix)$(params.cluster-name)-nodes - create_and_validate_dp_nodes() { node_group_name=$node_group-$1 - launch_template_name=$(params.cluster-name)-launchTemplate CREATED_NODEGROUP=$(aws eks $ENDPOINT_FLAG --region $(params.region) list-nodegroups --cluster-name $(params.cluster-name) --query 'nodegroups[?@==`'$node_group_name'`]' --output text) EC2_INSTANCES=$3 if [ "$CREATED_NODEGROUP" == "" ]; then @@ -88,7 +86,6 @@ spec: --cluster-name $(params.cluster-name) \ --nodegroup-name $node_group_name \ --node-role $NODE_ROLE_ARN \ - --launch-template name=$launch_template_name\ --region $(params.region) \ --instance-types $EC2_INSTANCES \ --scaling-config minSize=$(params.min-nodes),maxSize=$2,desiredSize=$2 \ diff --git a/tests/tasks/teardown/awscli-eks.yaml b/tests/tasks/teardown/awscli-eks.yaml index 579eb6de..3d6714c7 100644 --- a/tests/tasks/teardown/awscli-eks.yaml +++ b/tests/tasks/teardown/awscli-eks.yaml @@ -22,7 +22,6 @@ spec: default: "Job is completed" - name: service-role-stack-name - name: node-role-stack-name - - name: launch-template-stack-name steps: - name: delete-cluster image: alpine/k8s:1.23.7 @@ -43,7 +42,6 @@ spec: script: | aws cloudformation delete-stack --stack-name $(params.service-role-stack-name) aws cloudformation delete-stack --stack-name $(params.node-role-stack-name) - aws cloudformation delete-stack --stack-name $(params.launch-template-stack-name) - name: send-slack-notification image: alpine/k8s:1.23.7 script: | diff --git a/tests/tasks/teardown/awscli-vpc-delete.yaml b/tests/tasks/teardown/awscli-vpc-delete.yaml index d4173aa7..328d90e6 100644 --- a/tests/tasks/teardown/awscli-vpc-delete.yaml +++ b/tests/tasks/teardown/awscli-vpc-delete.yaml @@ -29,4 +29,4 @@ spec: aws cloudformation delete-stack --region $(params.region) --stack-name $(params.stack-name) # Wait for the stack to be deleted aws cloudformation wait stack-delete-complete --region $(params.region) --stack-name $(params.stack-name) - echo "Stack deleted successfully!" \ No newline at end of file + echo "Stack deleted successfully!"