Each configuration has 3 parts

  1. Header and component type
    1. Api version
      1. Each component has a different api version. So look at documentation for it
    2. Component Types can be:
      1. Service
      2. Ingress
      3. Deployment
  2. Metadata
    1. name
    2. labels
  3. Specification
    1. Configurations
    2. replicas
    3. memory
    4. selectors
    5. ports
    6. template
      1. This has its own meta data and spec
      2. it is what tells what the pod would look like
      3. i.e. name of the container, image (like docker ocmpose)
    7. and more...
  4. Status
    1. This part is automatically generated by kubernetes
    2. This tells what is the desired state and what is the actual state
    3. This is the basis of self healing in kubernetes
    4. i.e. if spec: replica: 2 but status has just one replica then kubernetes will keep trying to create new replica

connecting with labels and selectors

# DEPLOYMENT
apiVersion: apps/v1
kind: Deployment
metadata:
	name: <u>***nginx-deployment***</u>
	labels:
		app: <u>***nginx***</u>
spec:
	replicas: 2
	selector:
		matchLabels:
			app: <u>***nginx***</u>
	template:
		metadata:
			labels:
				app: <u>***nginx***</u>
		spec:
			name: nginx
			image: nginx:1.16
			ports:
				- containerPort: <u>***8080***</u>
...
# SERVICE
apiVersion: v1
kind: Service
metadata:
	name: <u>***nginx-service***</u>
spec:
	selector:
		app: <u>***nginx***</u>
	ports:
		- protocol: TCP
			port: 80
			targetPort: <u>***8080***</u>