Skip to content

Instantly share code, notes, and snippets.

View kelseyhightower's full-sized avatar

Kelsey Hightower kelseyhightower

View GitHub Profile

Creating and Scheduling a Pod Manually

This tutorial demonstrates how to create a Pod and manually schedule it to a node using cURL. This guide assumes you don't have a scheduler running in your Kubernetes cluster.

Create a Pod

The following pod will run version 1.10.0 of nginx with a 100m CPU limit.

Create the nginx pod manifest and name it pod.json:

{
"apiVersion":"v1",
"kind":"Binding",
"metadata": {
"name":"nginx"
},
"target": {
"apiVersion":"v1",
"kind":"Node",
"name":"node1"
$ curl -H "Content-Type: application/merge-patch+json" -X PATCH http://127.0.0.1:8080/api/v1/namespaces/default/pods/nginx -d @pod-patch.json
{
"kind": "Status",
"apiVersion": "v1",
"metadata": {},
"status": "Failure",
"message": "Pod \"nginx\" is invalid: spec: Forbidden: pod updates may not change fields other than `containers[*].image` or `spec.activeDeadlineSeconds`",
"reason": "Invalid",
"details": {
"name": "nginx",
ackage main
import (
"log"
"net"
pb "github.com/kelseyhightower/helloworld/helloworld"
"golang.org/x/net/context"
"google.golang.org/grpc"
)
[Unit]
Description=Kubernetes Kubelet
Documentation=https://github.com/GoogleCloudPlatform/kubernetes
[Service]
ExecStart=/usr/bin/kubelet \
--hostname-override=<node-ip> \
--api-servers=http://<api-server-ip>:8080 \
--v=2
Restart=on-failure
[Unit]
Description=Kubernetes Kubelet
Documentation=https://github.com/GoogleCloudPlatform/kubernetes
[Service]
ExecStart=/usr/bin/kubelet \
--api-servers=http://<api-server-ip>:8080 \
--v=2
Restart=on-failure
RestartSec=5
[Unit]
Description=Docker Application Container Engine
Documentation=http://docs.docker.io
[Service]
ExecStart=/usr/bin/docker \
daemon \
--bip=10.200.0.1/24 \
--iptables=false \
--ip-masq=false \
[Unit]
Description=Kubernetes Proxy
Documentation=https://github.com/GoogleCloudPlatform/kubernetes
[Service]
ExecStart=/usr/bin/kube-proxy \
--master=http://127.0.0.1:8080 \
--v=2
Restart=on-failure
RestartSec=5
[Unit]
Description=Kubernetes Scheduler
Documentation=https://github.com/GoogleCloudPlatform/kubernetes
[Service]
ExecStart=/usr/bin/kube-scheduler \
--master=http://127.0.0.1:8080 \
--v=2
Restart=on-failure
RestartSec=5
[Unit]
Description=Kubernetes Controller Manager
Documentation=https://github.com/GoogleCloudPlatform/kubernetes
[Service]
ExecStart=/usr/bin/kube-controller-manager \
--master=http://127.0.0.1:8080 \
--v=2
Restart=on-failure
RestartSec=5