Core Kubernetes Objects: Deployment, Service, Ingress, ConfigMap, Storage
Architecture
Section titled “Architecture”Physical Component
Section titled “Physical Component”A Kubernetes cluster splits into the control plane and worker nodes.
- Control plane:
kube-apiserveris the entry point for every request, and declared state is stored inetcd.kube-schedulerdecides which node a new Pod goes to, andkube-controller-managerruns controllers such as Deployment and ReplicaSet to bring the actual state in line with the declaration. - Worker node:
kubeletruns containers through the container runtime (containerd, etc.) according to the Pod spec from the apiserver and reports their status.kube-proxy(or an equivalent provided by the CNI) forwards traffic arriving at a Service to Pods.
In managed Kubernetes (AKS, EKS, GKE), the cloud provider runs the control plane, and users mainly manage worker nodes and the objects on them.

Logical Component
Section titled “Logical Component”From an application’s point of view, this flow is enough to read most deployments. External requests pass through an Ingress to a Service, and the Service spreads traffic across the Pods it selects by label. A Deployment keeps the desired number of Pods, configuration comes from ConfigMaps, and persistent data connects to a PV through a PVC.
K8S(kubernetes) Object
Section titled “K8S(kubernetes) Object”Each object can be created/modified by writing it in YAML format.
Manifest block
Section titled “Manifest block”apiVersion: apps/v1kind: [Deployment, StatefulSet, Service, Ingress, etc]metadata: name: [name] labels: [key]: [value] ... [key]: [value]
spec: ...Deployment(pod)
Section titled “Deployment(pod)”Defines the life cycle of a pod and the pod’s instances.
apiVersion: apps/v1kind: Deploymentmetadata: name: employees labels: app: employeesspec: replicas: 3 # define the initial number of pod instances selector: matchLabels: # specify target pods to manage by key:value app: employees strategy: # specify the update method when the container changes: rollingUpdate/Recreate rollingUpdate: maxSurge: 1 # number of pods rolled at a time during a rolling update maxUnavailable: 1 # number of pods killed during a rolling update type: RollingUpdate # replace multiple pods sequentially template: # pod definition metadata: labels: app: employees spec: containers: # container array info; defines container details - name: employees # container name image: nogada/employees # registry uri imagePullPolicy: IfNotPresent # specify the container image update method ports: - containerPort: 8080 # port used by the container name: tomcat # declaration to reference the port by name from outside resources: # container resource allocation; HPA computes CPU utilization against requests, so autoscaling needs requests limits: cpu: 500m memory: 512Mi requests: cpu: 300m memory: 256Mi livenessProbe: # defines how to check whether the pod is alive httpGet: path: / port: 8080 initialDelaySeconds: 5 periodSeconds: 60 readinessProbe: # checks whether the pod is ready for traffic; on failure it is removed from Service endpoints (slow starts belong to startupProbe) httpGet: path: / port: 8080 initialDelaySeconds: 30 periodSeconds: 5 volumeMounts: # mount info for using storage - name: spring-properties mountPath: /app/config volumes: # specify the type of mounted storage: PVC(PV), Configmap, Secret - name: spring-properties configMap: name: configService
Section titled “Service”Declaration that exposes a container so that it can communicate with the pod. Pod IPs change dynamically, so they must be connected through a service. Connections take the form client -> service -> pod, and pod -> service -> pod
apiVersion: v1kind: Servicemetadata: name: employeesspec: type: ClusterIP # NodePort, ClusterIP(default), LoadBalancer selector: app: employees # select target pods via the key value of the pod's metadata.labels. ports: - protocol: TCP # protocol TCP/UDP port: 80 # service port name: http # name of the port to reference; used by name when referencing the port from ingress, etc. targetPort: tomcat # specify the pod's port; designate by pod container port or port nameIngress
Section titled “Ingress”An Ingress is an object that declares HTTP(S) routing rules. What actually receives and handles requests is an Ingress controller (NGINX, Traefik, etc.) installed separately in the cluster; without a controller, creating an Ingress does nothing. It connects backend Services by host (domain) and sub-URL pattern, and can handle TLS termination (offload) with a certificate registered as a Secret.
apiVersion: networking.k8s.io/v1kind: Ingressmetadata: name: ingress-wildcard-hostspec: rules: - host: "foo.bar.com" # target domain name for the service http: paths: - pathType: Prefix path: "/bar" # sub-URL for routing distinction backend: service: name: service1 port: number: 80 - host: "*.foo.com" # target domain name for the service http: paths: - pathType: Prefix path: "/foo" # sub-URL for routing distinction backend: service: name: service2 port: number: 80configmap
Section titled “configmap”A Configmap is an Object used to store non-confidential data in key-value pairs. A Pod can consume a Configmap as environment variables, command-line arguments, or configuration files in a volume. Using a Configmap, you can separate environment-specific configuration from the container image, making your application easily portable.
apiVersion: v1kind: ConfigMapmetadata: name: game-demodata: # property-like keys; each key maps to a simple value player_initial_lives: "3" ui_properties_file_name: "user-interface.properties"
# file-like keys game.properties: | enemy.types=aliens,monsters player.maximum-lives=5 user-interface.properties: | color.good=purple color.bad=yellow allow.textmode=trueConfigmap usage example : as environment variables, or mounted as files in a directory (existing paths are replaced) To mount only a specific file into an existing path, specify the file name with subPath. The application-property ConfigMap in the example must contain an application.properties key.
apiVersion: v1kind: Podmetadata: name: configmap-demo-podspec: containers: - name: demo image: alpine command: ["sleep", "3600"] env: # define environment variables - name: PLAYER_INITIAL_LIVES # note that the ConfigMap key name here # differs in case. valueFrom: configMapKeyRef: name: game-demo # the ConfigMap for this value. key: player_initial_lives # the key to fetch. - name: UI_PROPERTIES_FILE_NAME valueFrom: configMapKeyRef: name: game-demo key: ui_properties_file_name volumeMounts: - name: config mountPath: "/config" readOnly: true - name: property mountPath: "/app/config/application.properties" subPath: application.properties volumes: # set the volume at the pod level, then mount it into the container within that pod. - name: property configMap: # provide the name of the ConfigMap to mount. name: application-property - name: config configMap: # provide the name of the ConfigMap to mount. name: game-demo # array of keys from the ConfigMap to create as files items: - key: "game.properties" path: "game.properties" - key: "user-interface.properties" path: "user-interface.properties"How to use Storage
Section titled “How to use Storage”ref) kubernetes
Components
Section titled “Components”- storage class : provides functionality to connect Block/File systems. Supports the storage Life cycle through CSI (Container Storage Interface)
- PV(Persistent Volume): a provided storage Instance that manages information such as accessmode (R/W/Once/Many), capacity, and reuse policy
apiVersion: v1kind: PersistentVolumemetadata:name: pv0003spec:capacity:storage: 5GivolumeMode: FilesystemaccessModes:- ReadWriteOncepersistentVolumeReclaimPolicy: Retain # Recycle is deprecated; dynamic provisioning usually uses DeletestorageClassName: slowmountOptions:- hard- nfsvers=4.1nfs:path: /tmpserver: 172.17.0.2
- PVC(Persistent Volume Claim) : maps the pod that uses the storage to the actual PV
This PVC looks for a PV of at least 8Gi labeledapiVersion: v1kind: PersistentVolumeClaimmetadata:name: myclaimspec:accessModes:- ReadWriteOncevolumeMode: Filesystemresources:requests:storage: 8GistorageClassName: slowselector:matchLabels:release: "stable"matchExpressions:- {key: environment, operator: In, values: [dev]}
release: stable. The examplepv0003has no labels and only 5Gi, so it won’t bind to this PVC. In practice, most clusters use dynamic provisioning by setting a storageClass, and the selector is left empty. - Usage example
apiVersion: v1kind: Podmetadata:name: mypodspec:containers:- name: myfrontendimage: nginxvolumeMounts:- mountPath: "/var/www/html"name: mypdvolumes:- name: mypdpersistentVolumeClaim:claimName: myclaim