kubectl etiketine sahip kayıtlar gösteriliyor. Tüm kayıtları göster
kubectl etiketine sahip kayıtlar gösteriliyor. Tüm kayıtları göster

6 Aralık 2021 Pazartesi

8 Şubat 2021 Pazartesi

kubectl scale seçeneği

--replicas seçeneği
pos sayısını artırmak için şöyle yaparız
kubectl scale --replicas=5 deployment/backend
5 tane pod olduğunu görmek için şöyle yaparız
kubectl get pods
pod sayısını düşürmek için şöyle yaparız
kubectl scale --replicas=1 deployment/backend
statefulsets seçeneği
Örnek
Şöyle yaparız
kubectl scale statefulsets <stateful-set-name> --replicas=<new-replicas>

kubectl get nodes seçeneği

Örnek
Şöyle yaparız
kubectl get nodes
NAME       STATUS    ROLES     AGE       VERSION
minikube   Ready     <none>    11m       v1.9.0
Örnek
Şöyle yaparız
$ minikube>~> kubectl get nodes
NAME           STATUS   ROLES                  AGE     VERSION
minikube       Ready    control-plane,master   4m36s   v1.21.2
minikube-m02   Ready    <none>                 3m36s   v1.21.2
minikube-m03   Ready    <none>                 2m55s   v1.21.2
minikube-m04   Ready    <none>                 2m11s   v1.21.2

24 Aralık 2020 Perşembe

kubectl get services seçeneği

Giriş
get services ve get svc aynı şeyler. 5 tane sütunlu bir çıktı verir. service ve pod farklı şeyler. Farkını gösteren bir şekil burada. Servis podlar tetikleyen yapıdır.
+---------------------+
| hello-world-service |
|                     |
|    10.15.242.210    |
+---------O-----------+
          |
          +-------------O--------------------------O
                        |                          |
              +---------O-----------+    +---------O-----------+
              |        pod 1        |    |        pod 2        |
              |                     |    |                     |
              |     hello-world     |    |     hello-world     |
              +---------------------+    +---------------------+
Örnek
Şöyle yaparız
kubectl get services --namespace yb-demo
Örnek
Şöyle yaparız
$ kubectl get svc
NAME                  TYPE        CLUSTER-IP      EXTERNAL-IP   PORT(S)    AGE
hello-world-service   ClusterIP   10.15.242.210   <none>        8080/TCP   5s
kubernetes            ClusterIP   10.15.240.1     <none>        443/TCP    7h
Örnek
Şöyle yaparız
kubectl get svc
NAME             TYPE           CLUSTER-IP      EXTERNAL-IP   PORT(S)        AGE
sa-frontend-lb   LoadBalancer   10.101.244.40   <pending>     80:30708/TCP   7m

6 Eylül 2020 Pazar

kubectl komutu

Giriş
cheatsheat burada


create
Şöyle yaparız
kubectl create -f hello-world.yaml
create deploy
create deploy yazısına taşıdım

create namespace
namespace farklı policy'ler için gerekir
Bir örnek şöyle
In a scenario where an organization is using a shared Kubernetes cluster for development and production use cases:

The development team would like to maintain a space in the cluster where they can get a view on the list of Pods, Services, and Deployments they use to build and run their application. In this space, Kubernetes resources come and go, and the restrictions on who can or cannot modify resources are relaxed to enable agile development.

The operations team would like to maintain a space in the cluster where they can enforce strict procedures on who can or cannot manipulate the set of Pods, Services, and Deployments that run the production site.

One pattern this organization could follow is to partition the Kubernetes cluster into two namespaces: development and production.
Örnek
Yeni bir namespace yaratmak için şöyle yaparız
kubectl create namespace yb-demo
create secret 
Örnek
Şöyle yaparız
kubectl create secret generic test --from-file=appsettings.json --dry-run -oyaml |
kubectl apply -f -
create serviceaccount
Açıklaması şöyle.
The command to create a ServiceAccount. The created secret holds the public CA of the API server and a signed JSON Web Token (JWT)
ServiceAccount ismi testuser olan girdi yaratmak için şöyle yaparız
kubectl create serviceaccount testuser
describe podname
İsmi belirtilen pod hakkında bilgi almak içindir.
Örnek
İsmi test-pod olan pod hakkında bilgi almak için şöyle yaparız
kubectl describe test-pod
exec -it podname
Interactive mod'a geçip shell açmak içindir.
Örnek
İsmi test-pod olan pod'a shell açmak için şöyle yaparız
kubectl exec -it test-pod -- sh
Örnek
namespace belirterek interactive shell açmak istersek şöyle yaparız. -n ile namespace belirtilir.
kubectl exec -n yb-demo -it yb-tserver-0 /bin/bash
get all
Tüm servis'leri listeler. 
-A seçeneği
Örnek
Yedekleme için şöyle yaparız
kubectl get all -A -o yaml > backup.yaml
get hostendpoint
Örnek
Şöyle yaparız
#!/bin/sh
kubectl get hostendpoint $NODE_NAME
if [ $? -eq 0 ]; then
  echo "Found hep for node $NODE_NAME"
  ...
fi
get nodes
get nodes yazısına taşıdım

get serviceaccount
Açıklaması şöyle.
The command to display the yaml revealing the associated secret:
Örnek
şöyle yaparız
kubectl get serviceaccount testuser -o yaml
get services
get services yazısına taşıdım

get pods
get pods yazısına taşıdım

get secret + serviceaccount
Açıklaması şöyle.
The command to obtain the encoded token data
Örnek
Şöyle yaparız
kubectl get secret testuser-token-mgtnp -o yaml
Örnek
Şöyle yaparız
kubctl get secret websitesslcert-staging -o yaml 

apiVersion: v1
data:
  tls.crt: REDACTED=
  tls.key: REDACTED=
kind: Secret
metadata:
  annotations:
    cert-manager.io/alt-names: mysite.com
    cert-manager.io/certificate-name: websitesslcert-staging
    cert-manager.io/common-name: mysite.com
    cert-manager.io/ip-sans: ""
    cert-manager.io/issuer-group: cert-manager.io
    cert-manager.io/issuer-kind: ClusterIssuer
    cert-manager.io/issuer-name: letsencrypt-staging
    cert-manager.io/uri-sans: ""
  creationTimestamp: "2021-10-17T00:00:00Z"
  name: websitesslcert-staging
  namespace: default
  resourceVersion: "123456"
  uid: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
type: kubernetes.io/tls
get secrets
Açıklaması şöyle.
The command to display available tokens
Şöyle yaparız
kubectl get secrets
scale seçeneği
scale seçeneği yazısına taşıdım