apiVersion: apps/v1
kind: Deployment
metadata:
  name: hello
spec:
  replicas: 1
  selector:
    matchLabels:
      app: hello
  template:
    metadata:
      labels:
        app: hello
    spec:
      containers:
      - name: hello
        image: buoyantio/helloworld:0.1.7
        args:
        - "-addr=:8888"
        - "-text=Hello"
        - "-target=world-svc:8889/testpath"
        ports:
        - name: service
          containerPort: 8888
---
apiVersion: v1
kind: Service
metadata:
  name: hello-svc
spec:
  selector:
    app: hello
  ports:
  - name: http
    port: 8888
    targetPort: 8888
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: world
spec:
  replicas: 1
  selector:
    matchLabels:
      app: world
  template:
    metadata:
      labels:
        app: world
    spec:
      containers:
      - name: world
        image: buoyantio/helloworld:0.1.7
        args:
        - "-addr=:8889"
        - "-text=World"
        - "-failure-rate=0.5"
        ports:
        - name: service
          containerPort: 8889
---
apiVersion: v1
kind: Service
metadata:
  name: world-svc
spec:
  selector:
    app: world
  ports:
  - name: http
    port: 8889
    targetPort: 8889
---
apiVersion: batch/v1
kind: Job
metadata:
  name: hello-slow-cooker
spec:
  template:
    metadata:
      labels:
        app: hello-slow-cooker
    spec:
      containers:
      - name: hello-slow-cooker
        image: buoyantio/slow_cooker:1.3.0
        command:
        - "/bin/sh"
        args:
        - "-c"
        - |
          sleep 15 # wait for pods to start
          /slow_cooker/slow_cooker -metric-addr 0.0.0.0:9998 http://hello-svc:8888/testpath
      restartPolicy: OnFailure
