mirror of
				https://github.com/kelseyhightower/kubernetes-the-hard-way.git
				synced 2025-11-04 02:02:33 +03:00 
			
		
		
		
	add support for aws
This commit is contained in:
		@@ -35,9 +35,13 @@ service "nginx" exposed
 | 
				
			|||||||
Grab the `NodePort` that was setup for the nginx service:
 | 
					Grab the `NodePort` that was setup for the nginx service:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
```
 | 
					```
 | 
				
			||||||
export NODE_PORT=$(kubectl get svc nginx --output=jsonpath='{range .spec.ports[0]}{.nodePort}')
 | 
					NODE_PORT=$(kubectl get svc nginx --output=jsonpath='{range .spec.ports[0]}{.nodePort}')
 | 
				
			||||||
```
 | 
					```
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					### Create the Node Port Firewall Rule
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#### GCP
 | 
				
			||||||
 | 
					
 | 
				
			||||||
```
 | 
					```
 | 
				
			||||||
gcloud compute firewall-rules create kubernetes-nginx-service \
 | 
					gcloud compute firewall-rules create kubernetes-nginx-service \
 | 
				
			||||||
  --allow=tcp:${NODE_PORT} \
 | 
					  --allow=tcp:${NODE_PORT} \
 | 
				
			||||||
@@ -47,10 +51,36 @@ gcloud compute firewall-rules create kubernetes-nginx-service \
 | 
				
			|||||||
Grab the `EXTERNAL_IP` for one of the worker nodes:
 | 
					Grab the `EXTERNAL_IP` for one of the worker nodes:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
```
 | 
					```
 | 
				
			||||||
export NODE_PUBLIC_IP=$(gcloud compute instances describe worker0 \
 | 
					NODE_PUBLIC_IP=$(gcloud compute instances describe worker0 \
 | 
				
			||||||
  --format 'value(networkInterfaces[0].accessConfigs[0].natIP)')
 | 
					  --format 'value(networkInterfaces[0].accessConfigs[0].natIP)')
 | 
				
			||||||
```
 | 
					```
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#### AWS
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					```
 | 
				
			||||||
 | 
					SECURITY_GROUP_ID=$(aws ec2 describe-security-groups \
 | 
				
			||||||
 | 
					  --filters "Name=tag:Name,Values=kubernetes" | \
 | 
				
			||||||
 | 
					  jq -r '.SecurityGroups[].GroupId')
 | 
				
			||||||
 | 
					```
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					```
 | 
				
			||||||
 | 
					aws ec2 authorize-security-group-ingress \
 | 
				
			||||||
 | 
					  --group-id ${SECURITY_GROUP_ID} \
 | 
				
			||||||
 | 
					  --protocol tcp \
 | 
				
			||||||
 | 
					  --port ${NODE_PORT} \
 | 
				
			||||||
 | 
					  --cidr 0.0.0.0/0
 | 
				
			||||||
 | 
					```
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					Grab the `EXTERNAL_IP` for one of the worker nodes:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					```
 | 
				
			||||||
 | 
					NODE_PUBLIC_IP=$(aws ec2 describe-instances \
 | 
				
			||||||
 | 
					  --filters "Name=tag:Name,Values=worker0" | \
 | 
				
			||||||
 | 
					  jq -j '.Reservations[].Instances[].PublicIpAddress')
 | 
				
			||||||
 | 
					```
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					---
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Test the nginx service using cURL:
 | 
					Test the nginx service using cURL:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
```
 | 
					```
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user