Skip to content

Instantly share code, notes, and snippets.

@gnufied
Last active August 25, 2017 19:32
Show Gist options
  • Save gnufied/ddd08e1ee179f0beae825397cfc6df96 to your computer and use it in GitHub Desktop.
Save gnufied/ddd08e1ee179f0beae825397cfc6df96 to your computer and use it in GitHub Desktop.
Using Invoker to run kubernetes locally for development

I use Invoker for running Kubernetes locally while developing Kubernetes. It is relatively simple setup and unlike ./hack/local-up-cluster.sh doesn't involve any magical bits that my tiny brain can't understand. It is basically all kubernetes components started and running individually.

You can use following instructions for running kubenetes locally. Just don't forget to change hostname (xaos.lan to match your hostname). Similarly change ip address used here - "192.168.1.71" to your machine's IP address and similarly location of etcd and kubernetes binaries.

  1. Install Invoker ~> gem install invoker

  2. Compile kube ~> cd kube_home; make

  3. Create a directory for storing invoker's ini file and environment file and kubeconfig file.

~> mkdir ~/kube_invoker

  1. Create a file called invoker.ini in ~/kube_invoker directory:
[etcd]
command = /content/kube_bin/etcd --name=default --data-dir=/var/lib/etcd/default.etcd --listen-client-urls=http://0.0.0.0:4001 --listen-peer-urls=http://localhost:2380 --advertise-client-urls=http://0.0.0.0:4001
sleep = 10
index = 1

[api_server]
command = /home/shared/go_projects/src/k8s.io/kubernetes/_output/bin/kube-apiserver -v 2 $KUBE_LOGTOSTDERR $KUBE_LOG_LEVEL $KUBE_ETCD_SERVERS $KUBE_API_ADDRESS --insecure-port=8080 $KUBE_ALLOW_PRIV  $KUBE_SERVICE_ADDRESSES $KUBE_ADMISSION_CONTROL  $KUBE_API_ARGS --enable-swagger-ui=true --feature-gates ExpandPersistentVolumes=true
sleep = 10
index = 2

[controller]
command = /home/shared/go_projects/src/k8s.io/kubernetes/_output/bin/kube-controller-manager $KUBE_LOGTOSTDERR $KUBE_LOG_LEVEL --master=http://xaos.lan:8080 --feature-gates ExpandPersistentVolumes=true
index = 3

[scheduler]
command = /home/shared/go_projects/src/k8s.io/kubernetes/_output/bin/kube-scheduler -v 2 $KUBE_LOGTOSTDERR $KUBE_LOG_LEVEL --master=http://xaos.lan:8080 $KUBE_SCHEDULER_ARGS --feature-gates ExpandPersistentVolumes=true
index = 4

[proxy]
directory = /home/shared/go_projects/src/k8s.io/kubernetes/_output/bin
command = /home/shared/go_projects/src/k8s.io/kubernetes/_output/bin/kube-proxy $KUBE_LOGTOSTDERR $KUBE_LOG_LEVEL --master=http://xaos.lan:8080 $KUBE_PROXY_ARGS --feature-gates ExpandPersistentVolumes=true
index = 5

[kubelet]
directory = /home/shared/go_projects/src/k8s.io/kubernetes/_output/bin
command = /home/shared/go_projects/src/k8s.io/kubernetes/_output/bin/kubelet $KUBE_LOGTOSTDERR -v 5 --kubeconfig=/home/hekumar/redhat/kube_scripts/xaos_master_kube/xaos_kube_config $KUBELET_ADDRESS $KUBELET_PORT $KUBE_ALLOW_PRIV $KUBELET_ARGS --feature-gates ExpandPersistentVolumes=true --fail-swap-on=false
index = 6

  1. Also create a file called .env in same directory:
KUBE_ETCD_SERVERS="--etcd_servers=http://192.168.1.71:4001"

KUBE_LOGTOSTDERR="--logtostderr=true"

# journal message level, 0 is debug
KUBE_LOG_LEVEL="--v=5"

# Should this cluster be allowed to run privileged docker containers. REQUIRED for advanced volumes like Gluster and CEPH
KUBE_ALLOW_PRIV="--allow_privileged=true"

# How the controller-manager, scheduler, and proxy find the apiserver
KUBE_MASTER="--master=http://xaos.lan:8080"

KUBE_API_ADDRESS="--insecure-bind-address=0.0.0.0"

# The port on the local server to listen on.
# KUBE_API_PORT="--port=8080"

# Port minions listen on
# KUBELET_PORT="--kubelet_port=10250"

# Address range to use for services
KUBE_SERVICE_ADDRESSES="--service-cluster-ip-range=10.254.0.0/16"

# default admission control policies
KUBE_ADMISSION_CONTROL="--admission_control=NamespaceAutoProvision,LimitRanger,ResourceQuota"

# API level v1beta3 required for Gluster and CEPH
KUBE_API_ARGS=""


# The address for the info server to serve on (set to 0.0.0.0 or "" for all interfaces)
KUBELET_ADDRESS="--address=0.0.0.0"

# The port for the info server to serve on
# KUBELET_PORT="--port=10250"

# You may leave this blank to use the actual hostname
KUBELET_HOSTNAME="--hostname_override=xaos.lan"

#API Server
# location of the api-server
KUBELET_API_SERVER="--api_servers=http://xaos.lan:8080"

KUBELET_ARGS=""

# default config should be adequate

# Add your own!
KUBE_PROXY_ARGS=""

# Comma separated list of minions
KUBELET_ADDRESSES="--machines=xaos.lan"
# Add you own!
KUBE_CONTROLLER_MANAGER_ARGS=""

###
# kubernetes scheduler config
# default config should be adequate

# Add your own!
KUBE_SCHEDULER_ARGS=""

Change the .env file to suite your environment.

  1. Creating a file called "kube_config" in same directory with following content:
apiVersion: v1
clusters:
- cluster:
    server: xaos.lan:8080
  name: master
contexts:
- context:
    cluster: master
    user: ""
  name: master
current-context: master
kind: Config
preferences: {}
  1. Start Kubernetes:

As root run following command:

~> sudo invoker -s invoker.ini
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment