parent
0d94436f03
commit
7ed632a08c
|
@ -42,8 +42,8 @@ Kubernetes The Hard Way guides you through bootstrapping a highly available Kube
|
||||||
* [TLS Bootstrapping the Kubernetes Worker Nodes](docs/10-tls-bootstrapping-kubernetes-workers.md)
|
* [TLS Bootstrapping the Kubernetes Worker Nodes](docs/10-tls-bootstrapping-kubernetes-workers.md)
|
||||||
* [Configuring kubectl for Remote Access](docs/11-configuring-kubectl.md)
|
* [Configuring kubectl for Remote Access](docs/11-configuring-kubectl.md)
|
||||||
* [Deploy Weave - Pod Networking Solution](docs/12-configure-pod-networking.md)
|
* [Deploy Weave - Pod Networking Solution](docs/12-configure-pod-networking.md)
|
||||||
* [Deploying the DNS Cluster Add-on](docs/13-dns-addon.md)
|
* [Kube API Server to Kubelet Configuration](docs/13-kube-apiserver-to-kubelet.md)
|
||||||
* [Kube API Server to Kubelet Configuration](docs/14-kube-apiserver-to-kubelet.md)
|
* [Deploying the DNS Cluster Add-on](docs/14-dns-addon.md)
|
||||||
* [Smoke Test](docs/15-smoke-test.md)
|
* [Smoke Test](docs/15-smoke-test.md)
|
||||||
* [E2E Test](docs/16-e2e-tests.md)
|
* [E2E Test](docs/16-e2e-tests.md)
|
||||||
* [Extra - Dynamic Kubelet Configuration](docs/17-extra-dynamic-kubelet-configuration.md)
|
* [Extra - Dynamic Kubelet Configuration](docs/17-extra-dynamic-kubelet-configuration.md)
|
||||||
|
|
|
@ -59,4 +59,4 @@ kubectl version --client
|
||||||
Client Version: version.Info{Major:"1", Minor:"13", GitVersion:"v1.13.0", GitCommit:"ddf47ac13c1a9483ea035a79cd7c10005ff21a6d", GitTreeState:"clean", BuildDate:"2018-12-03T21:04:45Z", GoVersion:"go1.11.2", Compiler:"gc", Platform:"linux/amd64"}
|
Client Version: version.Info{Major:"1", Minor:"13", GitVersion:"v1.13.0", GitCommit:"ddf47ac13c1a9483ea035a79cd7c10005ff21a6d", GitTreeState:"clean", BuildDate:"2018-12-03T21:04:45Z", GoVersion:"go1.11.2", Compiler:"gc", Platform:"linux/amd64"}
|
||||||
```
|
```
|
||||||
|
|
||||||
Next: [Provisioning Compute Resources](03-compute-resources.md)
|
Next: [Certificate Authority](04-certificate-authority.md)
|
||||||
|
|
|
@ -255,4 +255,4 @@ worker-1 NotReady <none> 93s v1.13.0
|
||||||
> Note: It is OK for the worker node to be in a NotReady state.
|
> Note: It is OK for the worker node to be in a NotReady state.
|
||||||
That is because we haven't configured Networking yet.
|
That is because we haven't configured Networking yet.
|
||||||
|
|
||||||
Next: [Configuring kubectl for Remote Access](10-configuring-kubectl.md)
|
Next: [TLS Bootstrapping Kubernetes Workers](10-tls-bootstrapping-kubernetes-workers.md)
|
||||||
|
|
|
@ -399,3 +399,5 @@ NAME STATUS ROLES AGE VERSION
|
||||||
worker-1 Ready <none> 12h v1.13.0
|
worker-1 Ready <none> 12h v1.13.0
|
||||||
worker-2 Ready <none> 37m v1.13.0
|
worker-2 Ready <none> 37m v1.13.0
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Next: [Configuring Kubectl](11-configuring-kubectl.md)
|
||||||
|
|
|
@ -36,3 +36,5 @@ NAME READY STATUS RESTARTS AGE
|
||||||
weave-net-58j2j 2/2 Running 0 89s
|
weave-net-58j2j 2/2 Running 0 89s
|
||||||
weave-net-rr5dk 2/2 Running 0 89s
|
weave-net-rr5dk 2/2 Running 0 89s
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Next: [Kube API Server to Kubelet Connectivity](13-kube-apiserver-to-kubelet.md)
|
||||||
|
|
|
@ -52,3 +52,5 @@ subjects:
|
||||||
name: kube-apiserver
|
name: kube-apiserver
|
||||||
EOF
|
EOF
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Next: [DNS Addon](14-dns-addon.md)
|
|
@ -72,4 +72,4 @@ Name: kubernetes
|
||||||
Address 1: 10.96.0.1 kubernetes.default.svc.cluster.local
|
Address 1: 10.96.0.1 kubernetes.default.svc.cluster.local
|
||||||
```
|
```
|
||||||
|
|
||||||
Next: [Smoke Test](14-kube-apiserver-to-kubelet.md)
|
Next: [Smoke Test](15-smoke-test.md)
|
|
@ -57,13 +57,13 @@ In this section you will verify the ability to create and manage [Deployments](h
|
||||||
Create a deployment for the [nginx](https://nginx.org/en/) web server:
|
Create a deployment for the [nginx](https://nginx.org/en/) web server:
|
||||||
|
|
||||||
```
|
```
|
||||||
kubectl run nginx --image=nginx
|
kubectl create deployment nginx --image=nginx
|
||||||
```
|
```
|
||||||
|
|
||||||
List the pod created by the `nginx` deployment:
|
List the pod created by the `nginx` deployment:
|
||||||
|
|
||||||
```
|
```
|
||||||
kubectl get pods -l run=nginx
|
kubectl get pods -l app=nginx
|
||||||
```
|
```
|
||||||
|
|
||||||
> output
|
> output
|
||||||
|
@ -73,62 +73,49 @@ NAME READY STATUS RESTARTS AGE
|
||||||
nginx-dbddb74b8-6lxg2 1/1 Running 0 10s
|
nginx-dbddb74b8-6lxg2 1/1 Running 0 10s
|
||||||
```
|
```
|
||||||
|
|
||||||
### Port Forwarding
|
### Services
|
||||||
|
|
||||||
In this section you will verify the ability to access applications remotely using [port forwarding](https://kubernetes.io/docs/tasks/access-application-cluster/port-forward-access-application-cluster/).
|
In this section you will verify the ability to access applications remotely using [port forwarding](https://kubernetes.io/docs/tasks/access-application-cluster/port-forward-access-application-cluster/).
|
||||||
|
|
||||||
Retrieve the full name of the `nginx` pod:
|
Create a service to expose deployment nginx on node ports.
|
||||||
|
|
||||||
```
|
```
|
||||||
POD_NAME=$(kubectl get pods -l run=nginx -o jsonpath="{.items[0].metadata.name}")
|
kubectl expose deploy nginx --type=NodePort --port 80
|
||||||
```
|
```
|
||||||
|
|
||||||
Forward port `8080` on your local machine to port `80` of the `nginx` pod:
|
|
||||||
|
|
||||||
```
|
```
|
||||||
kubectl port-forward $POD_NAME 8080:80
|
PORT_NUMBER=$(kubectl get svc -l app=nginx -o jsonpath="{.items[0].spec.ports[0].nodePort}")
|
||||||
|
```
|
||||||
|
|
||||||
|
Test to view NGINX page
|
||||||
|
|
||||||
|
```
|
||||||
|
curl http://worker-1:$PORT_NUMBER
|
||||||
|
curl http://worker-2:$PORT_NUMBER
|
||||||
```
|
```
|
||||||
|
|
||||||
> output
|
> output
|
||||||
|
|
||||||
```
|
```
|
||||||
Forwarding from 127.0.0.1:8080 -> 80
|
<!DOCTYPE html>
|
||||||
Forwarding from [::1]:8080 -> 80
|
<html>
|
||||||
```
|
<head>
|
||||||
|
<title>Welcome to nginx!</title>
|
||||||
In a new terminal make an HTTP request using the forwarding address:
|
# Output Truncated for brevity
|
||||||
|
<body>
|
||||||
```
|
|
||||||
curl --head http://127.0.0.1:8080
|
|
||||||
```
|
|
||||||
|
|
||||||
> output
|
|
||||||
|
|
||||||
```
|
|
||||||
HTTP/1.1 200 OK
|
|
||||||
Server: nginx/1.15.4
|
|
||||||
Date: Sun, 30 Sep 2018 19:23:10 GMT
|
|
||||||
Content-Type: text/html
|
|
||||||
Content-Length: 612
|
|
||||||
Last-Modified: Tue, 25 Sep 2018 15:04:03 GMT
|
|
||||||
Connection: keep-alive
|
|
||||||
ETag: "5baa4e63-264"
|
|
||||||
Accept-Ranges: bytes
|
|
||||||
```
|
|
||||||
|
|
||||||
Switch back to the previous terminal and stop the port forwarding to the `nginx` pod:
|
|
||||||
|
|
||||||
```
|
|
||||||
Forwarding from 127.0.0.1:8080 -> 80
|
|
||||||
Forwarding from [::1]:8080 -> 80
|
|
||||||
Handling connection for 8080
|
|
||||||
^C
|
|
||||||
```
|
```
|
||||||
|
|
||||||
### Logs
|
### Logs
|
||||||
|
|
||||||
In this section you will verify the ability to [retrieve container logs](https://kubernetes.io/docs/concepts/cluster-administration/logging/).
|
In this section you will verify the ability to [retrieve container logs](https://kubernetes.io/docs/concepts/cluster-administration/logging/).
|
||||||
|
|
||||||
|
Retrieve the full name of the `nginx` pod:
|
||||||
|
|
||||||
|
```
|
||||||
|
POD_NAME=$(kubectl get pods -l app=nginx -o jsonpath="{.items[0].metadata.name}")
|
||||||
|
```
|
||||||
|
|
||||||
Print the `nginx` pod logs:
|
Print the `nginx` pod logs:
|
||||||
|
|
||||||
```
|
```
|
||||||
|
@ -138,7 +125,8 @@ kubectl logs $POD_NAME
|
||||||
> output
|
> output
|
||||||
|
|
||||||
```
|
```
|
||||||
127.0.0.1 - - [30/Sep/2018:19:23:10 +0000] "HEAD / HTTP/1.1" 200 0 "-" "curl/7.58.0" "-"
|
10.32.0.1 - - [20/Mar/2019:10:08:30 +0000] "GET / HTTP/1.1" 200 612 "-" "curl/7.58.0" "-"
|
||||||
|
10.40.0.0 - - [20/Mar/2019:10:08:55 +0000] "GET / HTTP/1.1" 200 612 "-" "curl/7.58.0" "-"
|
||||||
```
|
```
|
||||||
|
|
||||||
### Exec
|
### Exec
|
||||||
|
@ -154,175 +142,7 @@ kubectl exec -ti $POD_NAME -- nginx -v
|
||||||
> output
|
> output
|
||||||
|
|
||||||
```
|
```
|
||||||
nginx version: nginx/1.15.4
|
nginx version: nginx/1.15.9
|
||||||
```
|
```
|
||||||
|
|
||||||
## Services
|
Next: [End to End Tests](16-e2e-test.md)
|
||||||
|
|
||||||
In this section you will verify the ability to expose applications using a [Service](https://kubernetes.io/docs/concepts/services-networking/service/).
|
|
||||||
|
|
||||||
Expose the `nginx` deployment using a [NodePort](https://kubernetes.io/docs/concepts/services-networking/service/#type-nodeport) service:
|
|
||||||
|
|
||||||
```
|
|
||||||
kubectl expose deployment nginx --port 80 --type NodePort
|
|
||||||
```
|
|
||||||
|
|
||||||
> The LoadBalancer service type can not be used because your cluster is not configured with [cloud provider integration](https://kubernetes.io/docs/getting-started-guides/scratch/#cloud-provider). Setting up cloud provider integration is out of scope for this tutorial.
|
|
||||||
|
|
||||||
Retrieve the node port assigned to the `nginx` service:
|
|
||||||
|
|
||||||
```
|
|
||||||
NODE_PORT=$(kubectl get svc nginx \
|
|
||||||
--output=jsonpath='{range .spec.ports[0]}{.nodePort}')
|
|
||||||
```
|
|
||||||
|
|
||||||
Create a firewall rule that allows remote access to the `nginx` node port:
|
|
||||||
|
|
||||||
```
|
|
||||||
gcloud compute firewall-rules create kubernetes-the-hard-way-allow-nginx-service \
|
|
||||||
--allow=tcp:${NODE_PORT} \
|
|
||||||
--network kubernetes-the-hard-way
|
|
||||||
```
|
|
||||||
|
|
||||||
Retrieve the external IP address of a worker instance:
|
|
||||||
|
|
||||||
```
|
|
||||||
EXTERNAL_IP=$(gcloud compute instances describe worker-0 \
|
|
||||||
--format 'value(networkInterfaces[0].accessConfigs[0].natIP)')
|
|
||||||
```
|
|
||||||
|
|
||||||
Make an HTTP request using the external IP address and the `nginx` node port:
|
|
||||||
|
|
||||||
```
|
|
||||||
curl -I http://${EXTERNAL_IP}:${NODE_PORT}
|
|
||||||
```
|
|
||||||
|
|
||||||
> output
|
|
||||||
|
|
||||||
```
|
|
||||||
HTTP/1.1 200 OK
|
|
||||||
Server: nginx/1.15.4
|
|
||||||
Date: Sun, 30 Sep 2018 19:25:40 GMT
|
|
||||||
Content-Type: text/html
|
|
||||||
Content-Length: 612
|
|
||||||
Last-Modified: Tue, 25 Sep 2018 15:04:03 GMT
|
|
||||||
Connection: keep-alive
|
|
||||||
ETag: "5baa4e63-264"
|
|
||||||
Accept-Ranges: bytes
|
|
||||||
```
|
|
||||||
|
|
||||||
## Untrusted Workloads
|
|
||||||
|
|
||||||
This section will verify the ability to run untrusted workloads using [gVisor](https://github.com/google/gvisor).
|
|
||||||
|
|
||||||
Create the `untrusted` pod:
|
|
||||||
|
|
||||||
```
|
|
||||||
cat <<EOF | kubectl apply -f -
|
|
||||||
apiVersion: v1
|
|
||||||
kind: Pod
|
|
||||||
metadata:
|
|
||||||
name: untrusted
|
|
||||||
annotations:
|
|
||||||
io.kubernetes.cri.untrusted-workload: "true"
|
|
||||||
spec:
|
|
||||||
containers:
|
|
||||||
- name: webserver
|
|
||||||
image: gcr.io/hightowerlabs/helloworld:2.0.0
|
|
||||||
EOF
|
|
||||||
```
|
|
||||||
|
|
||||||
### Verification
|
|
||||||
|
|
||||||
In this section you will verify the `untrusted` pod is running under gVisor (runsc) by inspecting the assigned worker node.
|
|
||||||
|
|
||||||
Verify the `untrusted` pod is running:
|
|
||||||
|
|
||||||
```
|
|
||||||
kubectl get pods -o wide
|
|
||||||
```
|
|
||||||
```
|
|
||||||
NAME READY STATUS RESTARTS AGE IP NODE
|
|
||||||
busybox-68654f944b-djjjb 1/1 Running 0 5m 10.200.0.2 worker-0
|
|
||||||
nginx-65899c769f-xkfcn 1/1 Running 0 4m 10.200.1.2 worker-1
|
|
||||||
untrusted 1/1 Running 0 10s 10.200.0.3 worker-0
|
|
||||||
```
|
|
||||||
|
|
||||||
|
|
||||||
Get the node name where the `untrusted` pod is running:
|
|
||||||
|
|
||||||
```
|
|
||||||
INSTANCE_NAME=$(kubectl get pod untrusted --output=jsonpath='{.spec.nodeName}')
|
|
||||||
```
|
|
||||||
|
|
||||||
SSH into the worker node:
|
|
||||||
|
|
||||||
```
|
|
||||||
gcloud compute ssh ${INSTANCE_NAME}
|
|
||||||
```
|
|
||||||
|
|
||||||
List the containers running under gVisor:
|
|
||||||
|
|
||||||
```
|
|
||||||
sudo runsc --root /run/containerd/runsc/k8s.io list
|
|
||||||
```
|
|
||||||
```
|
|
||||||
I0930 19:27:13.255142 20832 x:0] ***************************
|
|
||||||
I0930 19:27:13.255326 20832 x:0] Args: [runsc --root /run/containerd/runsc/k8s.io list]
|
|
||||||
I0930 19:27:13.255386 20832 x:0] Git Revision: 50c283b9f56bb7200938d9e207355f05f79f0d17
|
|
||||||
I0930 19:27:13.255429 20832 x:0] PID: 20832
|
|
||||||
I0930 19:27:13.255472 20832 x:0] UID: 0, GID: 0
|
|
||||||
I0930 19:27:13.255591 20832 x:0] Configuration:
|
|
||||||
I0930 19:27:13.255654 20832 x:0] RootDir: /run/containerd/runsc/k8s.io
|
|
||||||
I0930 19:27:13.255781 20832 x:0] Platform: ptrace
|
|
||||||
I0930 19:27:13.255893 20832 x:0] FileAccess: exclusive, overlay: false
|
|
||||||
I0930 19:27:13.256004 20832 x:0] Network: sandbox, logging: false
|
|
||||||
I0930 19:27:13.256128 20832 x:0] Strace: false, max size: 1024, syscalls: []
|
|
||||||
I0930 19:27:13.256238 20832 x:0] ***************************
|
|
||||||
ID PID STATUS BUNDLE CREATED OWNER
|
|
||||||
79e74d0cec52a1ff4bc2c9b0bb9662f73ea918959c08bca5bcf07ddb6cb0e1fd 20449 running /run/containerd/io.containerd.runtime.v1.linux/k8s.io/79e74d0cec52a1ff4bc2c9b0bb9662f73ea918959c08bca5bcf07ddb6cb0e1fd 0001-01-01T00:00:00Z
|
|
||||||
af7470029008a4520b5db9fb5b358c65d64c9f748fae050afb6eaf014a59fea5 20510 running /run/containerd/io.containerd.runtime.v1.linux/k8s.io/af7470029008a4520b5db9fb5b358c65d64c9f748fae050afb6eaf014a59fea5 0001-01-01T00:00:00Z
|
|
||||||
I0930 19:27:13.259733 20832 x:0] Exiting with status: 0
|
|
||||||
```
|
|
||||||
|
|
||||||
Get the ID of the `untrusted` pod:
|
|
||||||
|
|
||||||
```
|
|
||||||
POD_ID=$(sudo crictl -r unix:///var/run/containerd/containerd.sock \
|
|
||||||
pods --name untrusted -q)
|
|
||||||
```
|
|
||||||
|
|
||||||
Get the ID of the `webserver` container running in the `untrusted` pod:
|
|
||||||
|
|
||||||
```
|
|
||||||
CONTAINER_ID=$(sudo crictl -r unix:///var/run/containerd/containerd.sock \
|
|
||||||
ps -p ${POD_ID} -q)
|
|
||||||
```
|
|
||||||
|
|
||||||
Use the gVisor `runsc` command to display the processes running inside the `webserver` container:
|
|
||||||
|
|
||||||
```
|
|
||||||
sudo runsc --root /run/containerd/runsc/k8s.io ps ${CONTAINER_ID}
|
|
||||||
```
|
|
||||||
|
|
||||||
> output
|
|
||||||
|
|
||||||
```
|
|
||||||
I0930 19:31:31.419765 21217 x:0] ***************************
|
|
||||||
I0930 19:31:31.419907 21217 x:0] Args: [runsc --root /run/containerd/runsc/k8s.io ps af7470029008a4520b5db9fb5b358c65d64c9f748fae050afb6eaf014a59fea5]
|
|
||||||
I0930 19:31:31.419959 21217 x:0] Git Revision: 50c283b9f56bb7200938d9e207355f05f79f0d17
|
|
||||||
I0930 19:31:31.420000 21217 x:0] PID: 21217
|
|
||||||
I0930 19:31:31.420041 21217 x:0] UID: 0, GID: 0
|
|
||||||
I0930 19:31:31.420081 21217 x:0] Configuration:
|
|
||||||
I0930 19:31:31.420115 21217 x:0] RootDir: /run/containerd/runsc/k8s.io
|
|
||||||
I0930 19:31:31.420188 21217 x:0] Platform: ptrace
|
|
||||||
I0930 19:31:31.420266 21217 x:0] FileAccess: exclusive, overlay: false
|
|
||||||
I0930 19:31:31.420424 21217 x:0] Network: sandbox, logging: false
|
|
||||||
I0930 19:31:31.420515 21217 x:0] Strace: false, max size: 1024, syscalls: []
|
|
||||||
I0930 19:31:31.420676 21217 x:0] ***************************
|
|
||||||
UID PID PPID C STIME TIME CMD
|
|
||||||
0 1 0 0 19:26 10ms app
|
|
||||||
I0930 19:31:31.422022 21217 x:0] Exiting with status: 0
|
|
||||||
```
|
|
||||||
|
|
||||||
Next: [Cleaning Up](14-cleanup.md)
|
|
||||||
|
|
Loading…
Reference in New Issue