- Minikube installed on your machine
- Install with Brew:
brew install minikube
- Install with Brew:
- Colima installed on your machine (as a replacement for Docker Desktop)
- Install with Brew:
brew install colima
- Start Colima to manage Docker:
colima start
- Install with Brew:
- Docker installed on your machine
- Install with Brew:
brew install docker
- Install with Brew:
- kubectl installed on your machine (comes with Minikube)
-
Start Colima Make sure Colima is running to use Docker as the runtime:
colima start
-
Set Docker Context to Colima Ensure Docker is using Colima as the active context:
docker context use colima
-
Start Minikube with Docker as the Driver Start Minikube using Docker:
minikube start --driver=docker
Note: The initial pull of the Minikube base image may take some time. Be patient if it appears to hang at this step.
-
Build and Tag Your Docker Image Build your Docker image and tag it for Docker Hub:
docker build -t oanda-trading-api . docker tag oanda-trading-api:latest <your-dockerhub-username>/oanda-trading-api:latest
-
Push the Image to Docker Hub Log in to Docker Hub and push your image:
docker login docker push <your-dockerhub-username>/oanda-trading-api:latest
-
Update Kubernetes Manifest Make sure your
deployment.yaml
is configured to pull the image from Docker Hub:spec: containers: - name: oanda-trading-api image: <your-dockerhub-username>/oanda-trading-api:latest ports: - containerPort: 8080
-
Deploy to Minikube Apply your Kubernetes configuration:
kubectl apply -f deployment.yaml kubectl apply -f service.yaml
-
Secrets
kubectl create secret generic oanda-api-secrets --from-literal=OANDA_API_KEY="$OANDA_API_KEY"
-
Access the Application
- Accessing and Testing Your Application on Minikube
Once your application is deployed, you can access it using various methods. Here are the most effective approaches:
Port Forwarding for Local Access Port forwarding provides a straightforward way to access your service on localhost without needing to know the Minikube IP or NodePort.
kubectl port-forward svc/oanda-trading-api-service 8080:80
Now, access the API at: http://localhost:8080/your-endpoint
- Using the Minikube Service Command Minikube’s built-in service command simplifies access by automatically opening your service’s URL or providing the correct IP and port.
minikube service oanda-trading-api-service
This command attempts to open the service in your default browser. If it cannot open a browser, it will output the URL, which you can paste into a browser or Postman.
-
Testing Internal Connectivity with BusyBox If you need to verify that services are reachable inside the Minikube cluster, you can use a temporary BusyBox container to test connectivity.
- Start a BusyBox Pod:
kubectl run -it --rm debug --image=busybox --restart=Never -- /bin/sh
-
Test Connectivity to Your Service:
- Inside the BusyBox shell, you can use wget or curl to check if your service is reachable:
- wget http://oanda-trading-api-service:80/your-endpoint
-
Minikube Tunnel for External Access
- If you need to expose Minikube services to external networks or specific ports, consider setting up a Minikube tunnel.
- Start the Tunnel:
minikube tunnel
- If you need to expose Minikube services to external networks or specific ports, consider setting up a Minikube tunnel.
This will create routes to expose Kubernetes services on your local network. Keep this terminal open to maintain the tunnel, and note that it may require administrative privileges.
- Waiting for Image Pull: If Minikube seems to hang while pulling the base image, wait patiently. The initial setup can take time, especially on a slow network.
- Docker Credential Issues: If you encounter errors related to
docker-credential-osxkeychain
, make sure to remove or update the"credsStore"
entry in~/.docker/config.json
. - Colima Resource Configuration: If you run into performance issues, allocate more resources to Colima:
colima stop colima start --cpu 4 --memory 4
- Manual Base Image Pull: If Minikube's image pull fails, you can manually pull the image:
docker pull gcr.io/k8s-minikube/kicbase:v0.0.45
- Docker Credential Issues: If you encounter errors related to