Reputation: 5875
I've read the quick start guide and I've got as far as
kubectl run
command to start my container.I want to start a publicly available docker container, which I can start on any docker-enabled machine with this command
docker run -d \
-e DRONE_SERVER=wss://ci.fommil.com/ws/broker \
-e DRONE_SECRET=<redacted> \
-e DOCKER_MAX_PROCS=1 \
-e DRONE_TIMEOUT=30m \
-v /var/run/docker.sock:/var/run/docker.sock \
--restart=always \
--name=drone-agent \
drone/drone:0.5 agent
what is the equivalent Google Console / cubectl command? I've got as far as
kubectl run agent \
--image=drone/drone:0.5 \
--env="DRONE_SERVER=wss://ci.fommil.com/ws/broker" \
--env="DRONE_SECRET=<redacted>" \
--env="DOCKER_MAX_PROCS=1" \
--env="DRONE_TIMEOUT=30m" \
-v /var/run/docker.sock:/var/run/docker.sock
but this -v
line isn't quite right. I need to make sure that the /var/run/docker.sock
is mounted in the container as the sole purpose of it is to launch sub-processes in docker to run CI jobs.
Upvotes: 1
Views: 140
Reputation: 13867
you're right, creating volumes using the imperative commands to create volumes without config files isn't available in Kubernetes.
But it's easy to write some configuration. Based on this blog post and your requirements a "modern" config might look like.
deployment.yml:
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: agent
spec:
replicas: 1
template:
metadata:
labels:
app: agent
spec:
containers:
- env:
- name: DRONE_SERVER
value: "wss://ci.fommil.com/ws/broker"
- name: DRONE_SECRET
value: <redacted>
- name: DOCKER_MAX_PROCS
value: "1"
- name: DRONE_TIMEOUT
value: 30m
image: drone/drone:0.5
name: agent
args: ["agent"]
securityContext:
privileged: true
volumeMounts:
- mountPath: /var/run/docker.sock
name: docker-sock
- mountPath: /var/lib/docker
name: docker-lib
volumes:
- name: docker-sock
hostPath:
path: /var/run/docker.sock
- name: docker-lib
hostPath:
path: /var/lib/docker
This could now be used with kubectl create -f deployment.yml
and stopped with kubectl delete deployments -l app=agent
Upvotes: 1