Defining our K8s Service

February 28, 2021

Course Instructor: Elliot Forbes

Hey Gophers! My name is Elliot and I'm the creator of TutorialEdge and I've been working with Go systems for roughly 5 years now. Feel free to reach out to me on twitter - @Elliot_F

The final piece of the puzzle is to define a k8s service:

apiVersion: v1
kind: Service
  name: comments-api
  type: NodePort
    name: comments-api
  - protocol: TCP
    port: 8080
    targetPort: 8080

With this in place, we can now apply this service using the following command:

kubectl apply -f config/service.yml

We can then set up port-forwarding on our local machine to map localhost:8080 through to the kubernetes service running on port 8080:

kubectl port-forward service/comments-api 8080:8080