Skip to content

Instantly share code, notes, and snippets.

@mhausenblas
Last active July 3, 2020 13:30
Show Gist options
  • Save mhausenblas/07c03d4230a5e6ec3b46 to your computer and use it in GitHub Desktop.
Save mhausenblas/07c03d4230a5e6ec3b46 to your computer and use it in GitHub Desktop.
London MUG 2015-09-24: Kubernetes demo

Demo

  • Create a DCOS CE cluster
  • dcos package install kubernetes takes 1-2 min until UI is available
  • Install kubectl as per the docs
  • Set up K8S: export KUBERNETES_MASTER=$FQHN_OF_DASHBOARD/service/kubernetes/api
    $ dcos package list
    $ dcos marathon app add marathon-gen.json
    $ kubectl create -f k8s-webserver-pod.json
    $ kubectl get pods
    $ kubectl create -f k8s-webserver-service.json
    $ kubectl get services
    $ curl $FQHN_OF_DASHBOARD/service/kubernetes/api/v1/proxy/namespaces/default/services/nginx-service/
    $ kubectl delete service nginx-service
    $ kubectl delete pod nginx
#!/bin/sh
while true
do
timestamp=$(date +%s)
echo '<html><h1>Something important happened:' "$timestamp" '</h1>' > "$1"
sleep 2
done
{
"apiVersion": "v1",
"kind": "Pod",
"metadata": {
"labels": {
"name": "nginx"
},
"name": "nginx",
"namespace": "default"
},
"spec": {
"containers": [
{
"image": "nginx:latest",
"name": "nginx",
"ports": [
{
"containerPort": 80
}
],
"resources": {
"limits": {
"cpu": "500m",
"memory": "128Mi"
}
},
"volumeMounts": [
{
"mountPath": "/usr/share/nginx/html",
"name": "genvol",
"readOnly": true
}
]
}
],
"volumes": [
{
"hostPath": {
"path": "/tmp/gen/"
},
"name": "genvol"
}
]
}
}
{
"apiVersion": "v1",
"kind": "Service",
"metadata": {
"labels": {
"name": "nginx"
},
"name": "nginx-service",
"namespace": "default"
},
"spec": {
"ports": [
{
"port": 80
}
],
"selector": {
"name": "nginx"
}
}
}
{
"id": "generator",
"instances": 1,
"mem": 32.0,
"cmd": "chmod u+x gen.sh ; [ ! -d /tmp/gen ] && mkdir -p /tmp/gen ; ./gen.sh /tmp/gen/index.html",
"cpus": 0.5,
"uris": [
"https://dl.dropboxusercontent.com/u/10436738/london-mug-09-2015/gen.sh"
],
"constraints": [
[
"hostname",
"LIKE",
"ip-10-0-0-202.eu-west-1.compute.internal"
]
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment