apiVersion: apps/v1
kind: Deployment
metadata:
  name: tcp-echo
  labels:
    app: tcp-echo
spec:
  replicas: 1
  selector:
    matchLabels:
      app: tcp-echo
  template:
    metadata:
      labels:
        app: tcp-echo
    spec:
      containers:
        - name: tcp-echo-container
          image: cjimti/go-echo:latest
          imagePullPolicy: Always
          env:
            - name: TCP_PORT
              value: "2701"
            - name: NODE_NAME
              valueFrom:
                fieldRef:
                  fieldPath: spec.nodeName
            - name: POD_NAME
              valueFrom:
                fieldRef:
                  fieldPath: metadata.name
            - name: POD_NAMESPACE
              valueFrom:
                fieldRef:
                  fieldPath: metadata.namespace
            - name: POD_IP
              valueFrom:
                fieldRef:
                  fieldPath: status.podIP
          ports:
            - name: tcp-echo-port
              containerPort: 2701
---
apiVersion: v1
kind: Service
metadata:
  name: tcp-echo
  labels:
    app: tcp-echo
spec:
  selector:
    app: "tcp-echo"
  ports:
    - protocol: "TCP"
      name: echo-2701
      port: 2701
      targetPort: 2701
    - protocol: "TCP"
      name: echo-9000
      port: 9000
      targetPort: 2701
    - protocol: "TCP"
      name: echo-9443
      port: 9443
      targetPort: 2701
