1

I want to run a kloudless docker image with the command below in kubernetes. Just wanted to know it there was any straightforward solution.

docker run -d \
  --privileged
  --tmpfs /run  --tmpfs /run/lock  --tmpfs /tmp \
  --volume /sys/fs/cgroup:/sys/fs/cgroup:ro \
  --ulimit nofile=1024000:1024000 \
  --sysctl net.ipv4.ip_local_port_range='1025 65535' \
  --name kenterprise \
  --env KLOUDLESS_CONFIG="$(cat kloudless.yml)" \
  # [ports,/data volume|db config] \
  docker.kloudless.com/prod:1.29.0  docker_entry

I know we can run docker image in kubernetes with similar configure by configuring the container in pod yaml. Example if I wanted to give --privileged argument I could

containers:
    securityContext:
      privileged: true

Just wanted to know if there are any straightforward way.

mad_boy
  • 371
  • 4
  • 13

1 Answers1

4

kubectl run used to exist. It was probably what you were looking for. But it is depecrated now.

kubectl run -i --tty load-generator --image=busybox /bin/sh

The closest thing to running a pod/deployment from the command line without creating a file I could find is kubectl create

kubectl create deployment prod --image=busybox -o yaml
apiVersion: apps/v1
kind: Deployment
metadata:
  creationTimestamp: null
  labels:
    app: prod
  name: prod
spec:
  replicas: 1
  selector:
    matchLabels:
      app: prod
  strategy: {}
  template:
    metadata:
      creationTimestamp: null
      labels:
        app: prod
    spec:
      containers:
      - image: busybox
        name: busybox
        resources: {}
status: {}

Although, I would strongly advise against running one off commands like this as it goes against the concept of infrastructure as code which Kubernetes encourages through the use of manifests.

Using manifests in a Version Control System such as git allows you to explore the history of your commands and deployments easily and manage branches of changes to your deployment.

However, if what you are looking to do is abstract your deployment so that users don't have to get their hands dirty with the internals, then I would recommend a tool like Helm, which allows you to create charts and change simple values at release time like so:

helm install --set foo=bar ./mychart

yosefrow
  • 2,128
  • 20
  • 29
  • Thank you for the answer, I was actually using helm for all our deployments even the kloudless, But deployment like kloudless takes a lot of works, so I googled for the solution and couldn't get any, I think there in no other way – mad_boy Oct 11 '19 at 05:44
  • @mad_boy We've updated our Kubernetes deployment quick-start guides here: https://developers.kloudless.com/guides/enterprise/appendix_b.html Do you mind reaching out to us at support@kloudless.com to discuss deploying with a helm chart and k8s best practices? We'd be happy to assist. – vinod Nov 01 '19 at 23:27