Skip to content

Instantly share code, notes, and snippets.

@matharoo
matharoo / vpa.yaml
Created November 8, 2020 21:24
Vertical pod autoscaling in recommendation mode for a nodejs app
apiVersion: autoscaling.k8s.io/v1beta2
kind: VerticalPodAutoscaler
metadata:
name: mynode-app-vpa-recommender
spec:
targetRef:
apiVersion: "apps/v1"
kind: Deployment
name: mynode-app
updatePolicy:
@matharoo
matharoo / kind-config.yaml
Created November 1, 2020 21:52
config file for launching multiple nodes with kind (kubernetes in docker) tool.
kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
# patch the generated kubeadm config with some extra settings
kubeadmConfigPatches:
- |
apiVersion: kubelet.config.k8s.io/v1beta1
kind: KubeletConfiguration
evictionHard:
nodefs.available: "0%"
# patch it further using a JSON 6902 patch
@matharoo
matharoo / poddisruptionbudget.yaml
Last active November 1, 2020 22:43
Pod Disruption budget set in kubernetes to ensure certain number of percentage of replicas are always available in case of voluntary disruptions to cluster nodes.
apiVersion: policy/v1beta1
kind: PodDisruptionBudget
metadata:
name: mynode-pdb
spec:
minAvailable: 3
selector:
matchLabels:
app: mynode-app
@matharoo
matharoo / hpa.yaml
Created November 1, 2020 03:22
an example of horizontal pod autoscaler for K8s
apiVersion: autoscaling/v1
kind: HorizontalPodAutoscaler
metadata:
name: mynode-app-hpa
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: mynode-app
minReplicas: 2
@matharoo
matharoo / role-binding-mike.yaml
Created October 24, 2020 19:10
role binding yaml for mike
kind: RoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: read-pods
namespace: nodejs
subjects:
- kind: User
name: mike
apiGroup: rbac.authorization.k8s.io
roleRef:
@matharoo
matharoo / role.yaml
Created October 24, 2020 19:09
role to list pods in nodejs namespace
kind: Role
apiVersion: rbac.authorization.k8s.io/v1
metadata:
namespace: nodejs
name: pod-reader
rules:
- apiGroups: [""] # “” indicates the core API group
resources: ["pods"]
verbs: ["get", "watch", "list"]
@matharoo
matharoo / certificate.yaml
Created October 20, 2020 07:13
certificate resource that is also reference in ingress to invoke cert generation.
apiVersion: cert-manager.io/v1alpha2
kind: Certificate
metadata:
name: selfsigned-crt
spec:
secretName: tls-secret
duration: 170000h
renewBefore: 72h
issuerRef:
kind: Issuer
@matharoo
matharoo / mynode-ingress-tls.yaml
Last active October 24, 2020 21:07
ingress with tls self-signed
apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
name: mynode-ingress
annotations:
nginx.ingress.kubernetes.io/ssl-redirect: "false"
nginx.ingress.kubernetes.io/enable-cors: "true"
cert-manager.io/issuer: "selfsigned"
spec:
tls:
@matharoo
matharoo / letsencrypt-issuer-dns01.yaml
Last active October 24, 2020 21:07
LetsEncrypt issuer resource example using dns-01 method(route53) on their staging server to get the certificate
apiVersion: cert-manager.io/v1alpha2
kind: ClusterIssuer
metadata:
name: letsencrypt-prod
spec:
acme:
server: https://acme-v02.api.letsencrypt.org/directory
email: YOUR EMAIL ID
privateKeySecretRef:
name: letsencrypt-prod
@matharoo
matharoo / letsencrypt-issuer-http01.yaml
Last active October 24, 2020 21:07
LetsEncrypt issuer resource example using their staging server to get the certificate
apiVersion: cert-manager.io/v1alpha2
kind: Issuer
metadata:
name: letsencrypt
namespace: cert-manager
spec:
acme:
server: https://acme-staging-v02.api.letsencrypt.org/directory
privateKeySecretRef:
name: letsencrypt