---
apiVersion: apps/v1
kind: ReplicaSet
metadata:
  name: rs-httpd
spec:
  replicas: 2   # This sets the number of pods that needs to exist. 
  selector:
    matchLabels:
      component: httpd_webserver  # The rs object manages all pods that has this label
  template:  # this is used to nest a pode descriptor inside this rs descriptor. 
    metadata:
      labels:
        component: httpd_webserver  # this needs to be match with matchLabels above.
    spec: 
      containers:
        - name: cntr-httpd
          image: httpd:latest 
          ports:
            - containerPort: 80
          command: ["/bin/bash", "-c"]     # We have performed a command override here for testing purposes.
          args:
            - |
              /bin/echo "You've hit - $HOSTNAME" > /usr/local/apache2/htdocs/index.html
              /usr/local/bin/httpd-foreground  