Skip to main content
Redhat Developers  Logo
  • Products

    Featured

    • Red Hat Enterprise Linux
      Red Hat Enterprise Linux Icon
    • Red Hat OpenShift AI
      Red Hat OpenShift AI
    • Red Hat Enterprise Linux AI
      Linux icon inside of a brain
    • Image mode for Red Hat Enterprise Linux
      RHEL image mode
    • Red Hat OpenShift
      Openshift icon
    • Red Hat Ansible Automation Platform
      Ansible icon
    • Red Hat Developer Hub
      Developer Hub
    • View All Red Hat Products
    • Linux

      • Red Hat Enterprise Linux
      • Image mode for Red Hat Enterprise Linux
      • Red Hat Universal Base Images (UBI)
    • Java runtimes & frameworks

      • JBoss Enterprise Application Platform
      • Red Hat build of OpenJDK
    • Kubernetes

      • Red Hat OpenShift
      • Microsoft Azure Red Hat OpenShift
      • Red Hat OpenShift Virtualization
      • Red Hat OpenShift Lightspeed
    • Integration & App Connectivity

      • Red Hat Build of Apache Camel
      • Red Hat Service Interconnect
      • Red Hat Connectivity Link
    • AI/ML

      • Red Hat OpenShift AI
      • Red Hat Enterprise Linux AI
    • Automation

      • Red Hat Ansible Automation Platform
      • Red Hat Ansible Lightspeed
    • Developer tools

      • Red Hat Trusted Software Supply Chain
      • Podman Desktop
      • Red Hat OpenShift Dev Spaces
    • Developer Sandbox

      Developer Sandbox
      Try Red Hat products and technologies without setup or configuration fees for 30 days with this shared Openshift and Kubernetes cluster.
    • Try at no cost
  • Technologies

    Featured

    • AI/ML
      AI/ML Icon
    • Linux
      Linux Icon
    • Kubernetes
      Cloud icon
    • Automation
      Automation Icon showing arrows moving in a circle around a gear
    • View All Technologies
    • Programming Languages & Frameworks

      • Java
      • Python
      • JavaScript
    • System Design & Architecture

      • Red Hat architecture and design patterns
      • Microservices
      • Event-Driven Architecture
      • Databases
    • Developer Productivity

      • Developer productivity
      • Developer Tools
      • GitOps
    • Secure Development & Architectures

      • Security
      • Secure coding
    • Platform Engineering

      • DevOps
      • DevSecOps
      • Ansible automation for applications and services
    • Automated Data Processing

      • AI/ML
      • Data Science
      • Apache Kafka on Kubernetes
      • View All Technologies
    • Start exploring in the Developer Sandbox for free

      sandbox graphic
      Try Red Hat's products and technologies without setup or configuration.
    • Try at no cost
  • Learn

    Featured

    • Kubernetes & Cloud Native
      Openshift icon
    • Linux
      Rhel icon
    • Automation
      Ansible cloud icon
    • Java
      Java icon
    • AI/ML
      AI/ML Icon
    • View All Learning Resources

    E-Books

    • GitOps Cookbook
    • Podman in Action
    • Kubernetes Operators
    • The Path to GitOps
    • View All E-books

    Cheat Sheets

    • Linux Commands
    • Bash Commands
    • Git
    • systemd Commands
    • View All Cheat Sheets

    Documentation

    • API Catalog
    • Product Documentation
    • Legacy Documentation
    • Red Hat Learning

      Learning image
      Boost your technical skills to expert-level with the help of interactive lessons offered by various Red Hat Learning programs.
    • Explore Red Hat Learning
  • Developer Sandbox

    Developer Sandbox

    • Access Red Hat’s products and technologies without setup or configuration, and start developing quicker than ever before with our new, no-cost sandbox environments.
    • Explore Developer Sandbox

    Featured Developer Sandbox activities

    • Get started with your Developer Sandbox
    • OpenShift virtualization and application modernization using the Developer Sandbox
    • Explore all Developer Sandbox activities

    Ready to start developing apps?

    • Try at no cost
  • Blog
  • Events
  • Videos

How to Set Up A Kubernetes Developer Box

June 8, 2016
Hemant Jain
Related topics:
ContainersLinux
Related products:
Red Hat Enterprise Linux

Share:

    Kubernetes is a great tool for container orchestration on a server cluster. It makes it easy to deploy lots of containers in a resource-efficient way using a simple interface.

    But one thing that is not easy to do with Kubernetes is to deploy it locally. Kubernetes is designed to run on an actual cluster, which means using it only on a single computer is tough.

    I know. You're probably wondering why you'd want to use Kubernetes locally in the first place. The whole point of Kubernetes is to simplify the management of containers on a cluster, right? So running it on a single server might seem like building a second kitchen inside your garage. You could do it, but would it really be that useful?

    Well, yes. There are actually some good reasons why you might want to run Kubernetes on a local test box. Maybe you need to test how your apps behave under Kubernetes before putting them into production. Or perhaps you just want to hone your skills, working with the kubectl CLI interface in a safe, sandboxed environment.

    Fortunately, it's possible to run Kubernetes locally for these purposes. In fact, it's so possible that there's more than one way to do it. But in this post I'll cover the most bare-metal route, which involves running Kubernetes through Docker on your local machine.

    (Another way to do this is with Vagrant, but that requires running a virtual machine through a traditional hypervisor. A local Kubernetes installation through Docker is much lighter on system resources.)

    (Lastly, the Red Hat recommended way is to use the Red Hat Container Development Kit, available here (free), from Red Hat Developers.)

    The only prerequisite — Your development box needs to be running a modern mainstream GNU/Linux distribution such as Red Hat Enterprise Linux, which is available for $0 for development use (you can download it here).

    Step 1: Install and Configure Docker and kubectl

    We need two tools for this to work. The first is Docker. The procedure for installing Docker varies according to your OS, but in most cases, it can be done easily through the package manager (yum and dnf on RHEL and Fedora). Check out the Docker installation documentation for specifics.

    The second tool to grab is kubectl, the Kubernetes CLI tool. You can get this with a quick curl (wget would work fine, too), followed by commands that make the downloaded file executable, and place it in your PATH. The following commands will get the job done:

    curl -O https://storage.googleapis.com/kubernetes-release/release/v1.2.2/bin/linux/amd64/kubectl
    chmod +x kubectl
    mv kubectl /usr/local/bin/kubectl

    Lastly, we need to set an environment variable specifying the Kubernetes version we're using. We just downloaded version 1.2.2, so enter:

    export K8S_VERSION=v1.2.2

    (If you have a different version of kubectl installed, then change the preceding command accordingly.)

    Step 2: Start Docker

    This next step is to start a Kubernetes master (using an image from the Google Cloud Platform repository) on your local machine via Docker. This single command will do it all for you:

    docker run \
    --volume=/:/rootfs:ro \
    --volume=/sys:/sys:ro \
    --volume=/var/lib/docker/:/var/lib/docker:rw \
    --volume=/var/lib/kubelet/:/var/lib/kubelet:rw \
    --volume=/var/run:/var/run:rw \
    --net=host \
    --pid=host \
    --privileged=true \
    --name=kubelet \
    -d \
    gcr.io/google_containers/hyperkube-amd64:${K8S_VERSION} \
    /hyperkube kubelet \
    --containerized \
    --hostname-override="127.0.0.1" \
    --address="0.0.0.0" \
    --api-servers=http://localhost:8080 \
    --config=/etc/kubernetes/manifests \
    --cluster-dns=10.0.0.10 \
    --cluster-domain=cluster.local \
    --allow-privileged=true --v=2

    Step 3: Create a Cluster

    The final step is to use kubectl to create a cluster for us to manage, like so:

    kubectl config set-cluster test-doc --server=http://localhost:8080
    kubectl config set-context test-doc --cluster=test-doc
    kubectl config use-context test-doc

    Step 4: Enjoy

    That's it! With your Kubernetes master running and kubectl installed in your PATH, you can now use the latter to orchestrate your local Kubernetes cluster.

    If you want to launch other apps in containers locally so that you can orchestrate them with Kubernetes, feel free to use Docker to do so. You can also check out the kubectl documentation for the complete list of commands available from the tool.

    Parting Thoughts

    This is a handy way to do some quick testing or experimentation with Kubernetes on a developer box. But it's also worth acknowledging the downsides of this approach so that you're aware of the limitations.

    The biggest limitation is that this setup doesn't make it easy to sync your development and testing environments. If you update your app code, you'll have to restart Docker with Kubernetes and the newer app images manually. If this is a real problem for you, you might have a better experience with Vagrant. Vagrant doesn't automate the process entirely, but it at least makes it a little faster to start up a new cluster.

    The other downside to this method is that it doesn't involve real networking. It does everything over localhost. In most situations, this should not be a problem. But if you need to test Kubernetes for the orchestration of apps in a cluster containing multiple nodes with different real IP addresses, this won't work well. In that case, you really need a real cluster (or a set of virtual machines, at least).

    Despite these drawbacks, the steps described above are useful if you need to do some quick Kubernetes testing, or if you just want to practice using kubectl.


    Hemant Jain

    Hemant Jain is the founder and owner of Rapidera Technologies, a full service software development shop. He and his team focus a lot on modern software delivery techniques and tools. Prior to Rapidera he managed large scale enterprise development projects at Autodesk and Deloitte.

    Last updated: January 19, 2023

    Recent Posts

    • Meet the Red Hat Node.js team at PowerUP 2025

    • How to use pipelines for AI/ML automation at the edge

    • What's new in network observability 1.8

    • LLM Compressor: Optimize LLMs for low-latency deployments

    • How to set up NVIDIA NIM on Red Hat OpenShift AI

    What’s up next?

     

    Red Hat Developers logo LinkedIn YouTube Twitter Facebook

    Products

    • Red Hat Enterprise Linux
    • Red Hat OpenShift
    • Red Hat Ansible Automation Platform

    Build

    • Developer Sandbox
    • Developer Tools
    • Interactive Tutorials
    • API Catalog

    Quicklinks

    • Learning Resources
    • E-books
    • Cheat Sheets
    • Blog
    • Events
    • Newsletter

    Communicate

    • About us
    • Contact sales
    • Find a partner
    • Report a website issue
    • Site Status Dashboard
    • Report a security problem

    RED HAT DEVELOPER

    Build here. Go anywhere.

    We serve the builders. The problem solvers who create careers with code.

    Join us if you’re a developer, software engineer, web designer, front-end designer, UX designer, computer scientist, architect, tester, product manager, project manager or team lead.

    Sign me up

    Red Hat legal and privacy links

    • About Red Hat
    • Jobs
    • Events
    • Locations
    • Contact Red Hat
    • Red Hat Blog
    • Inclusion at Red Hat
    • Cool Stuff Store
    • Red Hat Summit

    Red Hat legal and privacy links

    • Privacy statement
    • Terms of use
    • All policies and guidelines
    • Digital accessibility

    Report a website issue