kubernetes-the-hard-way/docs/10-cleanup.md

209 lines
3.6 KiB
Markdown
Raw Normal View History

2016-07-07 23:53:39 +03:00
# Cleaning Up
2016-09-11 12:40:34 +03:00
## GCP
### Virtual Machines
2016-07-07 23:53:39 +03:00
```
gcloud compute instances delete \
controller0 controller1 controller2 \
worker0 worker1 worker2 \
etcd0 etcd1 etcd2
```
2016-09-11 12:40:34 +03:00
### Networking
2016-07-07 23:56:22 +03:00
2016-07-07 23:53:39 +03:00
```
2016-07-07 23:56:22 +03:00
gcloud compute forwarding-rules delete kubernetes-rule
2016-07-07 23:53:39 +03:00
```
```
2016-07-08 20:26:32 +03:00
gcloud compute target-pools delete kubernetes-pool
2016-07-07 23:53:39 +03:00
```
```
2016-07-07 23:56:22 +03:00
gcloud compute http-health-checks delete kube-apiserver-check
2016-07-07 23:53:39 +03:00
```
```
2016-07-08 20:26:32 +03:00
gcloud compute addresses delete kubernetes
2016-07-07 23:53:39 +03:00
```
2016-07-08 20:26:32 +03:00
2016-07-07 23:53:39 +03:00
```
2016-07-08 21:39:58 +03:00
gcloud compute firewall-rules delete \
kubernetes-allow-api-server \
kubernetes-allow-healthz \
2016-07-09 06:37:57 +03:00
kubernetes-allow-icmp \
kubernetes-allow-internal \
kubernetes-allow-rdp \
kubernetes-nginx-service \
kubernetes-allow-ssh
2016-07-08 01:14:24 +03:00
```
```
2016-07-08 21:39:58 +03:00
gcloud compute routes delete \
kubernetes-route-10-200-0-0-24 \
kubernetes-route-10-200-1-0-24 \
kubernetes-route-10-200-2-0-24
2016-07-09 06:28:42 +03:00
```
2016-07-09 06:37:57 +03:00
```
gcloud compute networks subnets delete kubernetes
```
2016-07-09 06:28:42 +03:00
```
gcloud compute networks delete kubernetes
2016-09-11 12:40:34 +03:00
```
## AWS
2016-09-11 14:08:38 +03:00
### Virtual Machines
2016-09-11 12:40:34 +03:00
```
KUBERNETES_HOSTS=(controller0 controller1 controller2 etcd0 etcd1 etcd2 worker0 worker1 worker2)
```
```
for host in ${KUBERNETES_HOSTS[*]}; do
INSTANCE_ID=$(aws ec2 describe-instances \
--filters "Name=tag:Name,Values=${host}" | \
jq -j '.Reservations[].Instances[].InstanceId')
aws ec2 terminate-instances --instance-ids ${INSTANCE_ID}
done
```
### IAM
```
aws iam remove-role-from-instance-profile \
--instance-profile-name kubernetes \
--role-name kubernetes
```
```
aws iam delete-instance-profile \
--instance-profile-name kubernetes
```
```
aws iam delete-role-policy \
--role-name kubernetes \
--policy-name kubernetes
```
```
aws iam delete-role --role-name kubernetes
```
### SSH Keys
```
aws ec2 delete-key-pair --key-name kubernetes
```
### Networking
2016-09-11 15:30:55 +03:00
Be sure to wait about a minute for all VMs to terminates to avoid the following errors:
```
An error occurred (DependencyViolation) when calling ...
```
Network resources cannot be deleted while VMs hold a reference to them.
2016-09-11 12:40:34 +03:00
#### Load Balancers
```
aws elb delete-load-balancer \
--load-balancer-name kubernetes
```
#### Internet Gateways
```
VPC_ID=$(aws ec2 describe-vpcs \
--filters "Name=tag:Name,Values=kubernetes" | \
jq -r '.Vpcs[].VpcId')
```
```
INTERNET_GATEWAY_ID=$(aws ec2 describe-internet-gateways \
--filters "Name=tag:Name,Values=kubernetes" | \
jq -r '.InternetGateways[].InternetGatewayId')
```
```
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}
```
2016-09-11 17:06:48 +03:00
#### Security Groups
```
SECURITY_GROUP_ID=$(aws ec2 describe-security-groups \
--filters "Name=tag:Name,Values=kubernetes" | \
jq -r '.SecurityGroups[].GroupId')
```
```
aws ec2 delete-security-group \
--group-id ${SECURITY_GROUP_ID}
```
2016-09-11 15:27:57 +03:00
#### Subnets
2016-09-11 12:40:34 +03:00
```
2016-09-11 15:27:57 +03:00
SUBNET_ID=$(aws ec2 describe-subnets \
2016-09-11 12:40:34 +03:00
--filters "Name=tag:Name,Values=kubernetes" | \
2016-09-11 15:27:57 +03:00
jq -r '.Subnets[].SubnetId')
2016-09-11 12:40:34 +03:00
```
```
2016-09-11 15:27:57 +03:00
aws ec2 delete-subnet --subnet-id ${SUBNET_ID}
2016-09-11 12:40:34 +03:00
```
2016-09-11 15:27:57 +03:00
#### Route Tables
2016-09-11 12:40:34 +03:00
```
2016-09-11 15:27:57 +03:00
ROUTE_TABLE_ID=$(aws ec2 describe-route-tables \
2016-09-11 12:40:34 +03:00
--filters "Name=tag:Name,Values=kubernetes" | \
2016-09-11 15:27:57 +03:00
jq -r '.RouteTables[].RouteTableId')
2016-09-11 12:40:34 +03:00
```
```
2016-09-11 15:27:57 +03:00
aws ec2 delete-route-table --route-table-id ${ROUTE_TABLE_ID}
2016-09-11 12:40:34 +03:00
```
#### VPC
```
VPC_ID=$(aws ec2 describe-vpcs \
--filters "Name=tag:Name,Values=kubernetes" | \
jq -r '.Vpcs[].VpcId')
```
```
aws ec2 delete-vpc --vpc-id ${VPC_ID}
```
#### DHCP Option Sets
```
DHCP_OPTION_SET_ID=$(aws ec2 describe-dhcp-options \
--filters "Name=tag:Name,Values=kubernetes" | \
jq -r '.DhcpOptions[].DhcpOptionsId')
```
```
aws ec2 delete-dhcp-options \
--dhcp-options-id ${DHCP_OPTION_SET_ID}
```