k8a service yaml - back to basic

 Given the following deployment yaml. There service selector has to match ALL. If you have 2 label to match, it must match all before it can successfully link up the service to the pod

Please have a look at the service selector: 


apiVersion: v1
kind: ServiceAccount
metadata:
  name: httpbin
---
apiVersion: v1
kind: Service
metadata:
  name: httpbin
  labels:
    app: httpbin
    service: httpbin
    version: v1
spec:
  ports:
  - name: http
    port: 8000
    targetPort: 80
  selector:
    required: pr2 ## selector here
    app: httpbin1 ## selector here
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: httpbin
spec:
  replicas: 1
  selector:
    matchLabels:
      app: httpbin1
      version: v1
      required: pr
  template:
    metadata:
      labels:
        app: httpbin1
        version: v1
        required: pr
    spec:
      serviceAccountName: httpbin
      containers:
      - image: docker.io/kennethreitz/httpbin
        imagePullPolicy: IfNotPresent
        name: httpbin
        ports:
        - containerPort: 80






Comments

Popular posts from this blog

The specified initialization vector (IV) does not match the block size for this algorithm