Kubernetes Imp
Kubernetes Imp
apps/nginx-deployment
===================================================================================
================================
openssl req -x509 -sha256 -newkey rsa:4096 -keyout ca.key -out ca.crt -days 356 -
nodes -subj '/CN=My Cert Authority'
openssl req -new -newkey rsa:4096 -keyout server.key -out server.csr -nodes -subj
'/CN=mydomain.com'
openssl x509 -req -sha256 -days 365 -in server.csr -CA ca.crt -CAkey ca.key -
set_serial 01 -out server.crt
openssl req -new -newkey rsa:4096 -keyout client.key -out client.csr -nodes -subj
'/CN=My Client'
openssl x509 -req -sha256 -days 365 -in client.csr -CA ca.crt -CAkey ca.key -
set_serial 02 -out client.crt
export PATH=$PWD/bin:$PATH
istioctl manifest generate --set profile=demo > temp/istio.yaml (copys the all the
manifest file to file)
portforwarding cmd:
===================
kubectl -n istio-system port-forward grafana-64986f9974-xgccq 3000:3000
Auto scaling
============
kubectl autoscale deploy nginx --min 10 --max --15 --cpu-percent 20
apiVersion: autoscaling/v2beta1
kind: HorizontalPodAutoscaler
metadata:
name: nodejs
spec:
maxReplicas: 12
minReplicas: 10
scaleTargetRef:
apiVersion: extensions/v1beta1
kind: Deployment
name: nodejs
metrics:
- type: Resource
resource:
name: memory
targetAverageUtilization: 50
apiVersion: autoscaling/v1
kind: HorizontalPodAutoscaler
metadata:
name: nodejs-cpu
spec:
maxReplicas: 4 # maximum replicas of pods
minReplicas: 1
scaleTargetRef:
apiVersion: extensions/v1v1beta1
kind: Deployment
name: nodejs
# TARGET name of the deployment the autoscaler need to be run on
targetCPUUtilizationPercentage: 30
# CPU maximum amount of use on the pod is set to 30%.
1 - avg(rate(node_cpu{mode="idle"}[1m]))
sum(node_load1)/sum(node:node_num_cpu:sum)
===================================================================================
=======
Ingress
apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
name: test-ingress
spec:
rules:
- http:
paths:
- path: /testpath
pathType: Prefix
backend:
serviceName: test
servicePort: 80
===================================
apiVersion: v1
kind: PersistentVolume
metadata:
name: pv-voll
spec:
capacity:
storage: 5Gi
volumeMode: Filesystem
accessModes:
- ReadWriteOnce
persistentVolumeReclaimPolicy: Recycle
awsElasticBlockStore:
volumeID: <volume-id>
fsType: ext4
================================
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: myclaim
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 500Mi
apiVersion: v1
kind: Secret
metadata:
name: mysecret
type: Opaque
data:
username: YWRtaW4=
password: MWYyZDFlMmU2N2Rm
================================