Difference between revisions of "K8"

From no name for this wiki
Jump to: navigation, search
(kubectl)
 
(8 intermediate revisions by the same user not shown)
Line 3: Line 3:
 
== kubectl ==
 
== kubectl ==
  
Default namespace setzen:
+
Nützliche kubectl Kommandos
 +
 
 +
===Default namespace setzen===
 
<pre>
 
<pre>
 
  kubectl config set-context minikube --namespace=mynamespace
 
  kubectl config set-context minikube --namespace=mynamespace
 +
</pre>
 +
 +
===Netzwerk image aufstarten mit bash===
 +
<pre>
 +
kubectl run my-shell --rm -it --image amouat/network-utils -- bash
 +
</pre>
 +
 +
https://hub.docker.com/r/amouat/network-utils/
 +
 +
=== Auf Container verbinden ===
 +
<pre>
 +
kubectl exec -it <pod-name> -- /bin/sh
 +
</pre>
 +
 +
=== Reverse Proxy zu einem pod erstellen ===
 +
<pre>
 +
kubectl port-forward <podname> 8000:80
 +
</pre>
 +
 +
== YAML Samples ==
 +
=== Einfaches Deployment ===
 +
<pre>
 +
apiVersion: apps/v1
 +
kind: Deployment
 +
metadata:
 +
  name: web
 +
spec:
 +
  selector:
 +
    matchLabels:
 +
      app: web
 +
  template:
 +
    metadata:
 +
      labels:
 +
        app: web
 +
    spec:
 +
      containers:
 +
        - name: web
 +
          image: nginx
 +
</pre>
 +
 +
== kustomize ==
 +
===  YAML Files generieren (in stdout) ===
 +
<pre>
 +
kubectl kustomize ./kostomize
 +
</pre>
 +
=== Apply kustomize ===
 +
kubectl apply -k ./kustomize/
 
</pre>
 
</pre>
  

Latest revision as of 11:03, 26 June 2021

Kubernetes

kubectl

Nützliche kubectl Kommandos

Default namespace setzen

 kubectl config set-context minikube --namespace=mynamespace

Netzwerk image aufstarten mit bash

kubectl run my-shell --rm -it --image amouat/network-utils -- bash

https://hub.docker.com/r/amouat/network-utils/

Auf Container verbinden

kubectl exec -it <pod-name> -- /bin/sh

Reverse Proxy zu einem pod erstellen

kubectl port-forward <podname> 8000:80

YAML Samples

Einfaches Deployment

apiVersion: apps/v1
kind: Deployment
metadata:
  name: web
spec:
  selector:
    matchLabels:
      app: web
  template:
    metadata:
      labels:
        app: web
    spec:
      containers:
        - name: web
          image: nginx

kustomize

YAML Files generieren (in stdout)

kubectl kustomize ./kostomize

Apply kustomize

kubectl apply -k ./kustomize/

microk8

minikube