apiVersion: v1 kind: ReplicationController metadata: name: nginx-controller spec: replicas: 1 # selector identifies the set of Pods that this # replication controller is responsible for managing selector: app: nginx # podTemplate defines the cookie cutter used for creating # new pods when necessary template: metadata: labels: # Important: these labels need to match the selector above # The api server enforces this constraint. app: nginx spec: containers: - name: nginx image: nginx ports: - containerPort: 80 --- apiVersion: v1 kind: Service metadata: name: nginx-service spec: ports: - port: 80 # the port that this service should serve on # the container on each pod to connect to, can be a name # (e.g. www) or a number (e.g. 80) targetPort: 80 protocol: TCP # just like the selector in the replication controller, # but this time it identifies the set of pods to load balance # traffic to. selector: app: nginx