← Back to Blog

πŸš€ How to Use Minikube with GitHub Codespaces

πŸš€ How to Use Minikube with GitHub Codespaces Setting up Minikube inside a GitHub Codespace is a great way to run a local Kubernetes cluster for testing and development. Here’s a step-by-step guide to get you up and running!

πŸš€ How to Use Minikube with GitHub Codespaces

Setting up Minikube inside a GitHub Codespace is a great way to run a local Kubernetes cluster for testing and development. Here’s a step-by-step guide to get you up and running! πŸ”§πŸ³

πŸ“ Prerequisites

Make sure you have the following:

  1. GitHub Codespaces: A Codespace instance ready to go. βœ…

  2. Minikube: You’ll install it inside the Codespace. πŸ—οΈ

  3. kubectl: Kubernetes CLI tool to manage your cluster. πŸ–₯️

πŸ› οΈ Steps to Set Up Minikube in GitHub Codespaces

1️⃣ Open a Codespace

Head to your repository on GitHub and:

β€’ Click the Code button.

β€’ Select Codespaces to start your development environment. βš™οΈ

2️⃣ Install Dependencies

Once your Codespace is ready, open the terminal and install Minikube, kubectl, and Docker.

# Update package lists πŸ“¦

sudo apt-get update

# Install kubectl πŸš€

sudo apt-get install -y kubectl

# Install Docker (Minikube needs Docker as a driver) 🐳

sudo apt-get install -y docker.io

# Install Minikube πŸ”¨

curl -Lo minikube https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64

chmod +x minikube

sudo mv minikube /usr/local/bin/

# Ensure Docker is running πŸƒβ€β™€οΈ

sudo service docker start

3️⃣ Start Minikube

Now, it’s time to fire up Minikube using Docker as the driver:

minikube start --driver=docker

Minikube will create a Kubernetes cluster for you. πŸ› οΈ If you hit any resource limits (CPU, memory), feel free to tweak Minikube’s settings, but defaults should work for most use cases. 🌟

4️⃣ Verify Kubernetes is Running

Once Minikube is started, check if your cluster is ready by running:

kubectl get nodes

You should see a list of nodes up and running. πŸŽ‰

5️⃣ (Optional) Access Kubernetes Dashboard πŸ–₯️

Minikube includes a built-in dashboard for managing your cluster visually. You can access it with:

minikube dashboard

This will open the dashboard in your browser. If Codespaces doesn’t allow direct browser access, use port forwarding to get a URL! 🌐

6️⃣ Run Kubernetes Workloads

You’re ready to deploy applications! πŸŽ‰ Here’s an example of creating and exposing a simple deployment:

# Deploy a simple hello-minikube application πŸ“¦

kubectl create deployment hello-minikube --image=k8s.gcr.io/echoserver:1.4

# Expose it on a NodePort so you can access it πŸ› οΈ

kubectl expose deployment hello-minikube --type=NodePort --port=8080

7️⃣ Access Services Running in Minikube

To access services running in your Minikube cluster, use:

minikube service hello-minikube

This will open the service in a browser, or provide a URL to access it. 🌍✨

🎯 Additional Tips

β€’ πŸ’‘ If you want to manage resources or check cluster health visually, the Kubernetes dashboard is a handy tool.

β€’ πŸ› οΈ Keep an eye on Codespace resource usage. Minikube can be demanding depending on your workloads, so adjust resources if necessary.

πŸŽ‰ And that’s it! Now you can easily run Minikube inside your GitHub Codespaces for all your Kubernetes development needs. 🌟


Imported from rifaterdemsahin.com Β· 2024