Skip to content

Commit

Permalink
finish cleaning up steps
Browse files Browse the repository at this point in the history
  • Loading branch information
lpmi-13 committed Jul 7, 2020
1 parent eba29ae commit dde25a1
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 26 deletions.
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -47,4 +47,4 @@ This tutorial assumes you have access to [Digital Ocean](https://www.digitalocea
* [Provisioning Pod Network Routes](docs/11-pod-network-routes.md) - WIP
* [Deploying the DNS Cluster Add-on](docs/12-dns-addon.md)
* [Smoke Test](docs/13-smoke-test.md) - WIP
* [Cleaning Up](docs/14-cleanup.md) - WIP
* [Cleaning Up](docs/14-cleanup.md)
12 changes: 8 additions & 4 deletions docs/03-compute-resources.md
Expand Up @@ -29,13 +29,15 @@ aws ec2 attach-internet-gateway --internet-gateway-id ${INTERNET_GATEWAY_ID} --v

```sh
LOAD_BALANCER_ID=$(doctl compute load-balancer create \
--name kubernetes \
--name kubernetes-lb \
--region ${DO_REGION} \
--forwarding-rules entry_protocol:tcp,entry_port:443,target_protocol:tcp,target_port:6443 \
--vpc-uuid ${VPC_ID} \
--output json | jq -r '.[].id')
```

> the load balancer takes about a minute or so to be created, so if the ip address doesn't resolve with the following command, try again a bit later.
```sh
KUBERNETES_PUBLIC_ADDRESS=$(doctl compute load-balancer list \
--output json | jq -r '.[].ip')
Expand All @@ -52,8 +54,8 @@ ssh-keygen -t rsa -b 4096 -f kubernetes.id_rsa
then import it via the doctl CLI

```sh
SSH_KEY_FINGERPRINT=$(doctl compute ssh-key import kubernetes \
--public-key-file kubernetes.id_rsa.pub | jq -r '.[0].fingerprint')
SSH_KEY_FINGERPRINT=$(doctl compute ssh-key import kubernetes-key \
--public-key-file kubernetes.id_rsa.pub --output json | jq -r '.[0].fingerprint')
```

### Kubernetes Controllers
Expand Down Expand Up @@ -126,11 +128,13 @@ done

```sh
doctl compute firewall create \
--inbound-rules protocol:tcp,ports:0,tags:kubernetes \
--inbound-rules protocol:tcp,ports:0,address:10.200.0.0/16 \
--inbound-rules protocol:tcp,ports:22,address:0.0.0.0/0 \
--inbound-rules protocol:tcp,ports:6443,address:0.0.0.0/0 \
--inbound-rules protocol:tcp,ports:443,address:0.0.0.0/0 \
--inbound-rules protocol:icmp,ports:1,address:0.0.0.0/0 \
--name kubernetes \
--name kubernetes-firewall \
--tag-names kubernetes
```

Expand Down
52 changes: 31 additions & 21 deletions docs/14-cleanup.md
Expand Up @@ -7,33 +7,43 @@ In this lab you will delete the compute resources created during this tutorial.
Delete the controller and worker compute instances:

```
aws ec2 terminate-instances \
--instance-ids \
$(aws ec2 describe-instances \
--filter "Name=tag:Name,Values=controller-0,controller-1,controller-2,worker-0,worker-1,worker-2" \
--output text --query 'Reservations[].Instances[].InstanceId')
aws ec2 delete-key-pair --key-name kubernetes
for droplet_id in $(doctl compute droplet list --format ID --no-header --tag-name kubernetes); do
doctl compute droplet delete ${droplet_id} -f
done
```

Delete the stored SSH key:
```
SSH_KEY_ID=$(doctl compute ssh-key list --output json \
| jq -cr '.[] | select(.name == "kubernetes-key") | .id')
doctl compute ssh-key delete ${SSH_KEY_ID} -f
```

## Networking

Delete the external load balancer network resources:
Delete the external load balancer:

```
LOAD_BALANCER_ID=$(doctl compute load-balancer list --output json \
| jq -cr '.[] | select(.name == "kubernetes-lb") | .id')
doctl compute load-balancer delete $LOAD_BALANCER_ID -f
```

Delete the firewall:

```
aws elbv2 delete-load-balancer --load-balancer-arn "${LOAD_BALANCER_ARN}"
aws elbv2 delete-target-group --target-group-arn "${TARGET_GROUP_ARN}"
aws ec2 delete-security-group --group-id "${SECURITY_GROUP_ID}"
ROUTE_TABLE_ASSOCIATION_ID="$(aws ec2 describe-route-tables \
--route-table-ids "${ROUTE_TABLE_ID}" \
--output text --query 'RouteTables[].Associations[].RouteTableAssociationId')"
aws ec2 disassociate-route-table --association-id "${ROUTE_TABLE_ASSOCIATION_ID}"
FIREWALL_ID=$(doctl compute firewall list --output json \
| jq -cr '.[] | select(.name == "kuberenetes-firewall" | .id')
doctl compute firewall delete ${FIREWALL_ID} -f
```

Delete the VPC:

aws ec2 delete-route-table --route-table-id "${ROUTE_TABLE_ID}"
aws ec2 detach-internet-gateway \
--internet-gateway-id "${INTERNET_GATEWAY_ID}" \
--vpc-id "${VPC_ID}"
aws ec2 delete-internet-gateway --internet-gateway-id "${INTERNET_GATEWAY_ID}"
aws ec2 delete-subnet --subnet-id "${SUBNET_ID}"
aws ec2 delete-vpc --vpc-id "${VPC_ID}"
```
VPC_ID=$(doctl vpcs list --output json \
| jq -cr '.[] | select(.name == "kubernetes") | .id')
doctl vpcs delete ${VPC_ID} -f
```

0 comments on commit dde25a1

Please sign in to comment.