Örnek
Şöyle yaparız
kubectl cluster-info
kubectl scale --replicas=5 deployment/backendkubectl get podskubectl scale --replicas=1 deployment/backendkubectl scale statefulsets <stateful-set-name> --replicas=<new-replicas>Örnekkubectl get nodesNAME STATUS ROLES AGE VERSIONminikube Ready <none> 11m v1.9.0
$ 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
+---------------------+| hello-world-service || || 10.15.242.210 |+---------O-----------+|+-------------O--------------------------O| |+---------O-----------+ +---------O-----------+| pod 1 | | pod 2 || | | || hello-world | | hello-world |+---------------------+ +---------------------+
$ 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 7hkubectl get svcNAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGEsa-frontend-lb LoadBalancer 10.101.244.40 <pending> 80:30708/TCP 7m
kubectl create -f hello-world.yamlIn 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.
kubectl create namespace yb-demokubectl create secret generic test --from-file=appsettings.json --dry-run -oyaml |
kubectl apply -f -
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
kubectl describe test-pod
exec -it podnamekubectl exec -it test-pod -- sh
kubectl exec -n yb-demo -it yb-tserver-0 /bin/bashkubectl get all -A -o yaml > backup.yaml#!/bin/shkubectl get hostendpoint $NODE_NAMEif [ $? -eq 0 ]; then echo "Found hep for node $NODE_NAME" ...fi
The command to display the yaml revealing the associated secret:
kubectl get serviceaccount testuser -o yaml
The command to obtain the encoded token data
kubectl get secret testuser-token-mgtnp -o yaml
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/tlsThe command to display available tokensŞöyle yaparız
kubectl get secrets