🌀
Kubernetes (k8s) Notlarım - 1w2.net
  • Kubernetes Nedir?
  • Bileşenler
  • Kubectl ve Versiyon
  • Pod
  • Label ve Selector
  • Annotation
  • Namespaces
  • Deployments
  • ReplicaSet
  • Rollout & Rollback
  • Networking
  • Service
  • Liveness Probe & Readiness Probe
  • Resource Limits
  • Environment Variables
  • Ephemeral Volumes
  • CSI - Plugin
  • Secrets
  • ConfigMap
  • Node Affinity
  • Pod Affinity
  • Taint and Toleration
  • DaemonSet
  • PV/PVC
  • Storage Class
  • StatefulSet
  • Job & Cronjob
  • Authentication
  • Role-based access control (RBAC)
  • Service Account
  • Ingress
  • ImagePullPolicy & ImageSecret
  • Static Pods
  • Network Policy
  • CRD & Operator
  • Kubernetes Extra
    • Helm Nedir?
    • Prometheus Stack - Monitoring
    • EFK Stack - Monitoring
Powered by GitBook
On this page

ConfigMap

PreviousSecretsNextNode Affinity

Last updated 2 years ago

ConfigMap, gizli olmayan verileri key/value eşlenikleri şeklinde depolamak için kullanılan bir API nesnesidir. Podlar, ConfigMap'i environment variable, komut satırı argümanları veya yapılandırma dosyaları olarak kullanabilirler.

ConfigMap objeleri, secret objeleri ile birebir aynı işe yarar. Key/Value şeklinde veriler tutup, bunları podlara environment variable yada volume olarak aktarabiliriz. Kubelet ve yaml dosyalarıyla oluşturulur. Secret ile aynı şekilde oluşturulur.

ConfigMap de gizli olmayan, fakat yine de pod tanımından ayırmamız gereken konfigürasyon verileri tarzı bilgileri tutarız. Yani gizli olmasını istediğimiz veriyi, secret objesinde tutarız. Gizli olmasına gerek olmayan verileri "configmap" objesinde tutarız.

ConfigMap 'de veriler, base64 encode edilmiş şekilde saklanmaz.

Imperative olarak ConfigMap objelerinin oluşturulması,

kubectl create configmap "configmap_ismi" --from-literal="anahtar"="değer" --from-file="anahtar"="değerin_okunacagi_dosya" --from-file="değerin_okunacagi_dosya"

kubectl create configmap myconfigmap--from-literal=db_server=db.example.com --from-file=db_server=server.txt --from-file=config.json

ConfigMap objelerinin listelenmesi,

kubectl get configmap

ConfigMap objelerinin silinmesi,

kubectl delete configmap "configmap_ismi"

kubectl delete configmap my-configmap

Örnek, ConfigMap yaml dosyası.

apiVersion: v1
kind: ConfigMap
metadata:
  name: myconfigmap
data:
  db_server: "db.1w2.net"
  database: "mydatabase"
  site.settings: |
    color=blue
    padding:25px
---
apiVersion: v1
kind: Pod
metadata:
  name: configmappod
spec:
  containers:
  - name: configmapcontainer
    image: ubuntu
    env:
      - name: DB_SERVER
        valueFrom:
          configMapKeyRef:
            name: myconfigmap
            key: db_server
      - name: DATABASE
        valueFrom:
          configMapKeyRef:
            name: myconfigmap
            key: database
    volumeMounts:
      - name: config-vol
        mountPath: "/config"
        readOnly: true
  volumes:
    - name: config-vol
      configMap:
        name: myconfigmap