Skip to content

Instantly share code, notes, and snippets.

@geodis
Last active May 19, 2023 11:50
Show Gist options
  • Save geodis/91e36c666585a0e6a48d0ea15b8e41f3 to your computer and use it in GitHub Desktop.
Save geodis/91e36c666585a0e6a48d0ea15b8e41f3 to your computer and use it in GitHub Desktop.
kubernetes examples

Pod with volumes

cat <<EOF |  kubectl apply -f -
apiVersion: v1
kind: Pod
metadata:
  name: restore
  namespace: monitoring
spec:
  securityContext:
    fsGroup: 1000       # GID del usuario del container tf-infra
  containers:
  - name: restore
    image: ubuntu:latest
    imagePullPolicy: IfNotPresent
    command: [ "/bin/sh", "-c", "--" ]
    args: [ "while true; do sleep 30; done;" ] 
    volumeMounts:
      - name: loki
        mountPath: /data/loki
      - name: prometheus
        mountPath: /data/prometheus
  restartPolicy: Never
  volumes:
  - name: loki
    persistentVolumeClaim:
      claimName: storage-loki-stack-0
  - name: prometheus
    persistentVolumeClaim:
      claimName: prometheus-kube-prometheus-stack-prometheus-db-prometheus-kube-prometheus-stack-prometheus-0
EOF

Whitelist and Maintenance mode to not allowed IPs

apiVersion: networking.k8s.io/v1 kind: Ingress metadata: annotations: # block not whitelilsted ips returns a 403 error nginx.ingress.kubernetes.io/whitelist-source-range: 1.1.1.1/32,2.2.2.2/32 nginx.ingress.kubernetes.io/server-snippet: | error_page 403 = @errorpages; # catch the error location @errorpages { return 503 "We are on maintenance mode.
Please come back later.
"; }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment