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

PLAT-7427 PLAT-7428 CDK migration support #151

Merged
merged 2 commits into from
Oct 10, 2023
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
9 changes: 5 additions & 4 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ jobs:
run: |
export NAME=cdk-${GITHUB_SHA:0:6}-$(date +%s)
echo "NAME=$NAME" >> $GITHUB_ENV
./util.py generate_config_template --name $NAME --aws-region=$AWS_REGION --aws-account-id=$AWS_ACCOUNT_ID --dev --platform-nodegroups 2 --registry-username $REGISTRY_USERNAME --registry-password $REGISTRY_PASSWORD --hostname $NAME.$BASE_DOMAIN --acm-cert-arn $ACM_CERT_ARN --disable-flow-logs > config.yaml
./util.py generate_config_template --name $NAME --aws-region=$AWS_REGION --aws-account-id=$AWS_ACCOUNT_ID --dev --platform-nodegroups 2 --registry-username $REGISTRY_USERNAME --registry-password $REGISTRY_PASSWORD --hostname $NAME.$BASE_DOMAIN --acm-cert-arn $ACM_CERT_ARN --disable-flow-logs | tee config.yaml
./util.py load_config -f ./config.yaml
- name: Test default config (single and nested stacks)
env:
Expand Down Expand Up @@ -151,7 +151,7 @@ jobs:
if: (contains(github.event.pull_request.labels.*.name, 'deploy-test') || github.ref == 'refs/heads/master')
working-directory: ./convert/cloudformation-only
run: |
echo "{\"region\":\"us-west-2\",\"tags\":{},\"suffix\":\"$NAME\"}" > terraform.tfvars.json
echo "{\"region\":\"us-west-2\",\"tags\":{},\"suffix\":\"$NAME\"}" | tee terraform.tfvars.json
terraform init
terraform plan -out=terraform.plan
terraform apply -auto-approve terraform.plan
Expand All @@ -177,11 +177,12 @@ jobs:
ssh-keygen -t rsa -f dummy.pem -N ''

export DEPLOY_ID="$NAME"
export MOD_VERSION="v3.0.8"
export MOD_VERSION="v3.0.11"


envsubst < config.tpl | tee config.yaml
./convert.py check-requirements
./convert.py print-stack --verbose --yaml > stack-data.yaml
./convert.py print-stack --verbose --yaml >stack-data.yaml
./convert.py setup-tf-modules
./convert.py create-tfvars --ssh-key-path ./dummy.pem
./convert.py set-imports
Expand Down
6 changes: 3 additions & 3 deletions convert/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,11 @@ Set `AWS_REGION`, `DEPLOY_ID` and `MOD_VERSION` environment variables with appro

* `AWS_REGION` AWS region for the CloudFormation stack.
* `DEPLOY_ID` : Name of the main CloudFormation stack.
* `MOD_VERSION`: Release tag for [terraform-aws-eks](https://github.com/dominodatalab/terraform-aws-eks/releases) in the form `vX.Y.Z` (using `v3.0.0` as an example).
* `MOD_VERSION`: :warning: Use version `v3.0.11` or higher. Release tag for [terraform-aws-eks](https://github.com/dominodatalab/terraform-aws-eks/releases) in the form `vX.Y.Z` (using `v3.0.11` as an example).

Command:

export AWS_REGION='us-east-1' DEPLOY_ID='my-main-stack-name' MOD_VERSION='v3.0.0'
export AWS_REGION='us-east-1' DEPLOY_ID='my-main-stack-name' MOD_VERSION='v3.0.11'


### Set Config values
Expand Down Expand Up @@ -171,7 +171,7 @@ v1beta1.metrics.k8s.io - True (Passed)
```

If either are `False`, make sure the corresponding `prometheus-adapter` and `metrics-server` pods are up and running.
If it's not possible get them running, take a backup, delete the `apiservice` objects and then proceed with the infrastructure changes.
If it's not possible get them running, take a backup, delete the `apiservice` objects and then proceed with the infrastructure changes.

```
kubectl get apiservice v1beta1.external.metrics.k8s.io -oyaml > v1beta1.external.metrics.k8s.io.yml
Expand Down
8 changes: 7 additions & 1 deletion convert/lib/convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -568,10 +568,14 @@ def get_subnet_ids(subnet_type: str, prefix: str = "VPC"):
eks_cluster_result = self.eks.describe_cluster(name=self.cdkconfig["name"])
eks_k8s_version = eks_cluster_result["cluster"]["version"]
eks_cluster_auto_sg = eks_cluster_result["cluster"]["resourcesVpcConfig"]["clusterSecurityGroupId"]
k8s_service_ipv4_cidr = eks_cluster_result["cluster"]["kubernetesNetworkConfig"]["serviceIpv4Cidr"]

route53_hosted_zone_name = None
route53_hosted_zone_private = False
if r53_zone_ids := self.cdkconfig["route53"]["zone_ids"]:
route53_hosted_zone_name = self.r53.get_hosted_zone(Id=r53_zone_ids[0])["HostedZone"]["Name"]
hosted_zone = self.r53.get_hosted_zone(Id=r53_zone_ids[0])["HostedZone"]
route53_hosted_zone_name = hosted_zone["Name"]
route53_hosted_zone_private = hosted_zone["Config"]["PrivateZone"]

subnet_result = self.ec2.describe_subnets(SubnetIds=get_subnet_ids("Private"))
az_zone_ids = [s["AvailabilityZoneId"] for s in subnet_result["Subnets"]]
Expand All @@ -592,6 +596,7 @@ def get_subnet_ids(subnet_type: str, prefix: str = "VPC"):
}

eks = {
"service_ipv4_cidr": k8s_service_ipv4_cidr,
"k8s_version": eks_k8s_version,
"public_access": {
"enabled": eks_cluster_result["cluster"]["resourcesVpcConfig"]["endpointPublicAccess"],
Expand Down Expand Up @@ -650,6 +655,7 @@ def get_subnet_ids(subnet_type: str, prefix: str = "VPC"):
"enabled": False,
},
"route53_hosted_zone_name": route53_hosted_zone_name,
"route53_hosted_zone_private": route53_hosted_zone_private,
"bastion": {
"enabled": eks_cluster_result["cluster"]["resourcesVpcConfig"]["endpointPrivateAccess"],
},
Expand Down
Loading