run an app on kubernetes

This commit is contained in:
G.J.C. Strikwerda 2018-10-30 16:00:32 +01:00
parent 42f002a4d8
commit 50e23a9233
1 changed files with 62 additions and 0 deletions

62
kubernetes.runapp Normal file
View File

@ -0,0 +1,62 @@
running application on kubernetes:
[ger@master ~]$ kubectl get nodes
NAME STATUS ROLES AGE VERSION
master.ger.test Ready master 7d1h v1.12.1
worker1.ger.test Ready worker 7d1h v1.12.1
worker2.ger.test Ready worker 7d1h v1.12.1
create deployment nginx:
[ger@master ~]$ kubectl run nginx --image nginx --port 80
kubectl run --generator=deployment/apps.v1beta1 is DEPRECATED and will be removed in a future version. Use kubectl create instead.
deployment.apps/nginx created
create service nginx and expose port 80:
[ger@master ~]$ kubectl expose deploy nginx --port 80 --target-port 80 --type NodePort
service/nginx exposed
[ger@master ~]$ kubectl get services
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
kubernetes ClusterIP 10.96.0.1 <none> 443/TCP 7d1h
nginx NodePort 10.109.244.16 <none> 80:32368/TCP 71s
port 80 nginx is now exposed on one of the nodes on port 32368:
[ger@master ~]$ curl worker2.ger.test:32368
<!DOCTYPE html>
<html>
<h1>Welcome to nginx!</h1>
<p>If you see this page, the nginx web server is successfully installed and
working. Further configuration is required.</p>
<p>For online documentation and support please refer to
<a href="http://nginx.org/">nginx.org</a>.<br/>
Commercial support is available at
<a href="http://nginx.com/">nginx.com</a>.</p>
<p><em>Thank you for using nginx.</em></p>
</body>
</html>
cleanup:
first delete service:
[ger@master ~]$ kubectl delete service nginx
service "nginx" deleted
[ger@master ~]$ kubectl get service
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
kubernetes ClusterIP 10.96.0.1 <none> 443/TCP 7d1h
then delete deployment:
[ger@master ~]$ kubectl delete deployment nginx
deployment.extensions "nginx" deleted
[ger@master ~]$ kubectl get deployment
No resources found.