Sobes.tech
Middle

What is needed to launch a service in Kubernetes?

sobes.tech AI

Answer from AI

To deploy a service in Kubernetes, you need to:

  1. Create a Docker image of your application.
  2. Write Kubernetes manifests — usually a Deployment to manage pods and a Service for access.
  3. Deploy the manifests to the cluster using kubectl apply -f.
  4. Check the status of pods and services with kubectl get pods and kubectl get svc.

Example of a simple Deployment for a Go service:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: my-go-service
spec:
  replicas: 3
  selector:
    matchLabels:
      app: my-go-service
  template:
    metadata:
      labels:
        app: my-go-service
    spec:
      containers:
      - name: my-go-service
        image: myrepo/my-go-service:latest
        ports:
        - containerPort: 8080

And a Service for access:

apiVersion: v1
kind: Service
metadata:
  name: my-go-service
spec:
  selector:
    app: my-go-service
  ports:
  - protocol: TCP
    port: 80
    targetPort: 8080
  type: ClusterIP

After this, the service will be accessible inside the cluster by the name my-go-service.

What is needed to launch a service in Kubernetes… - sobes.tech