Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[single-cluster/aws] make self-signed work #13305

Merged
merged 2 commits into from
Sep 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .werft/eks-installer-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ pod:
value: "/mnt/secrets/sh-playground-sa-perm/sh-sa.json"
- name: TF_VAR_dns_sa_creds
value: "/mnt/secrets/sh-playground-dns-perm/sh-dns-sa.json"
- name: TF_VAR_sa_creds
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is an unrelated change required to re-use the same environment while running tests! Context: https://gitpod.slack.com/archives/C01KLC56NP7/p1664268857397169?thread_ts=1664261197.651119&cid=C01KLC56NP7

value: "/mnt/secrets/sh-playground-sa-perm/sh-sa.json"
- name: NODENAME
valueFrom:
fieldRef:
Expand Down
11 changes: 7 additions & 4 deletions .werft/installer-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,12 @@ export async function installerTests(config: TestConfig) {
console.error("Failed to send message to Slack", error);
});

if (selfSigned === "true") {
exec(
`werft log result -d "Custom CA Certificate store underd GCP project 'sh-automated-tests'" url "gs://nightly-tests/tf-state/${process.env["TF_VAR_TEST_ID"]}-ca.pem"`,
);
}

exec(
`werft log result -d "Terraform state" url "Terraform state file name is ${process.env["TF_VAR_TEST_ID"]}"`,
);
Expand Down Expand Up @@ -384,10 +390,7 @@ function runIntegrationTests() {
function callMakeTargets(phase: string, description: string, makeTarget: string, failable: boolean = false) {
werft.log(phase, `Calling ${makeTarget}`);
// exporting cloud env var is important for the make targets
var env = `export TF_VAR_cluster_version=${k8s_version} cloud=${cloud} TF_VAR_domain=${baseDomain} TF_VAR_gcp_zone=${gcpDnsZone}`;
if (selfSigned) {
env = env.concat(` self_signed=${selfSigned}`)
}
const env = `export TF_VAR_cluster_version=${k8s_version} cloud=${cloud} TF_VAR_domain=${baseDomain} TF_VAR_gcp_zone=${gcpDnsZone}`;

const response = exec(
`${env} && make -C ${makefilePath} ${makeTarget}`,
Expand Down
24 changes: 18 additions & 6 deletions install/infra/modules/eks/kubernetes.tf
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,18 @@ module "eks" {
enable_bootstrap_user_data = true
vpc_security_group_ids = [aws_security_group.nodes.id]
ebs_optimized = true

Pothulapati marked this conversation as resolved.
Show resolved Hide resolved
post_bootstrap_user_data = <<-EOT
#!/bin/bash
cat << CONFIG >> /etc/containerd/config.toml

[plugins."io.containerd.grpc.v1.cri".registry]
config_path = "/etc/containerd/certs.d"

CONFIG

service containerd restart
EOT
}

eks_managed_node_groups = {
Expand Down Expand Up @@ -144,7 +156,7 @@ module "eks" {
export CONTAINER_RUNTIME="containerd"
export USE_MAX_PODS=false
EOF
# Source extra environment 5ariables in bootstrap script
# Source extra environment variables in bootstrap script
sed -i '/^set -o errexit/a\\nsource /etc/profile.d/bootstrap.sh' /etc/eks/bootstrap.sh
EOT
}
Expand All @@ -170,7 +182,7 @@ module "eks" {
desired_size = 2
enable_bootstrap_user_data = true
labels = {
"gitpod.io/workload_workspace_regular" = true
"gitpod.io/workload_workspace_regular" = true
}

tags = {
Expand Down Expand Up @@ -262,14 +274,14 @@ resource "null_resource" "kubeconfig" {

data "aws_iam_policy_document" "eks_policy" {
statement {
actions = [
actions = [
"eks:DescribeCluster",
"eks:ListClusters"
]
resources = [
"*",
]
effect = "Allow"
effect = "Allow"
}
}

Expand All @@ -281,7 +293,7 @@ resource "aws_iam_policy" "eks_policy" {

resource "aws_iam_user" "eks_user" {
force_destroy = true
name = "eks-user-${var.cluster_name}"
name = "eks-user-${var.cluster_name}"
}

resource "aws_iam_user_policy_attachment" "eks_attachment" {
Expand All @@ -290,5 +302,5 @@ resource "aws_iam_user_policy_attachment" "eks_attachment" {
}

resource "aws_iam_access_key" "eks_user_key" {
user = aws_iam_user.eks_user.name
user = aws_iam_user.eks_user.name
}
6 changes: 6 additions & 0 deletions install/tests/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,9 @@ self-signed-config:
envsubst < ./manifests/kots-config-self-signed.yaml > tmp_2_config.yml
yq m -i tmp_config.yml tmp_2_config.yml

# upload the Custom CA Cert into tf-state
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you also add commands to delete this file upon cleanup? It can be in this target if you would like.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've added it to destroy-kubeconfig, Do you think we should do it separately? 🤔

gsutil cp ./ca.pem gs://nightly-tests/tf-state/${TF_VAR_TEST_ID}-ca.pem

storage-config-incluster:
@echo "Nothing to do"

Expand Down Expand Up @@ -449,6 +452,9 @@ destroy-kubeconfig:
gcloud auth activate-service-account --key-file=${GOOGLE_APPLICATION_CREDENTIALS} --project=sh-automated-tests
gsutil rm gs://nightly-tests/tf-state/${TF_VAR_TEST_ID}-kubeconfig || echo "No kubeconfig"
gsutil rm gs://nightly-tests/tf-state/${TF_VAR_TEST_ID}-creds || echo "No credentials file"
ifeq (true,$(self_signed))
gsutil rm gs://nightly-tests/tf-state/${TF_VAR_TEST_ID}-ca.pem || echo "No custom CA cert file"
endif
rm ${KUBECONFIG} || echo "No kubeconfig"

select-workspace:
Expand Down