Running using minikube

2020-05-17

Dependencies

Steps

Install Minikube on your machine. Because you have Docker already installed, you should be fine without installing a hypervisor.

Open a shell and navigate to your project directory. Set up your docker environment to use the local minikube installation

minikube start
eval $(minikube docker-env)

Now your docker is operating within the minikube context. Build your application there, with the tag latest. Remember to replace rapu with your application's name.

docker build -t rapu:latest .

Create a deployment.yaml file

apiVersion: apps/v1
kind: Deployment
metadata:
  name: rapu
spec:
  selector:
    matchLabels:
      app: rapu
  template:
    metadata:
      labels:
        app: rapu
    spec:
      containers:
        - name: rapu
          image: rapu:latest
          imagePullPolicy: Never
          ports:
            - containerPort: 8080
          livenessProbe:
            httpGet:
              path: /status
              port: 8080
            initialDelaySeconds: 3
            periodSeconds: 3

Create a service.yaml file

apiVersion: v1
kind: Service
metadata:
  name: rapu
spec:
  selector:
    app: rapu
  ports:
    - port: 8080
      targetPort: 8080
  type: LoadBalancer

Apply the configurations and get the local service url

kubectl apply -f deployment.yaml
`kubectl apply -f service.yaml
minikube service your_service_name --url

Visit the provided URL to check out your application.

Optional