Projects:Kubernetes: verschil tussen versies

Naar navigatie springen Naar zoeken springen
1.254 bytes toegevoegd ,  16 mrt 2019
geen bewerkingssamenvatting
Geen bewerkingssamenvatting
Regel 409: Regel 409:
</pre>
</pre>


Now, we'd like to see nginx in action! The pod is listening on an internal port 80 (according to its configuration and the default nginx config). If we want to access this from outside the cluster, there's three ways:


TODO: explain difference between apply and create
* <code>kubectl port-forward</code>, which listens to a local port on the machine where you run <code>kubectl port-forward</code>, and then forwards all connections to a deployment or a pod. (I've explained above how to configure kubectl so it can run on your own machine when the cluster runs elsewhere.)
TODO: explain port-forward
* Creating a Service
* Creating an Ingress
 
Let's try creating a port-forward to the pod first:
 
<pre>
$ kubectl port-forward pod/nginx-deployment-58b6c946d5-fnqr6 8080:80
Forwarding from 127.0.0.1:8080 -> 80
Forwarding from [::1]:8080 -> 80
</pre>
 
Now, visit <code>http://127.0.0.1:8080</code> in your browser and presto!
 
This, of course, will no longer work when this pod stops working, so normally we'd always do a port-forward to a deployment:
 
<pre>
$ kubectl port-forward deployment/nginx-deployment 8080:80
Forwarding from 127.0.0.1:8080 -> 80
Forwarding from [::1]:8080 -> 80
</pre>
 
Now, when you visit <code>http://127.0.0.1:8080</code>, you'll get a response from ''either'' of the two pods. If one of them is down, you'll get it from the one that's up. If both are down, you're out of luck...


= Creating your own pods =
= Creating your own pods =

Navigatiemenu