kubernetes , Start kubernetes container with specific command

Start kubernetes container with specific command


Tag: kubernetes

Using fleet I can specify a command to be run inside the container when it is started. It seems like this should be easily possible with Kubernetes as well, but I can't seem to find anything that says how. It seems like you have to create the container specifically to launch with a certain command.

Having a general purpose container and launching it with different arguments is far simpler than creating many different containers for specific cases, or setting and getting environment variables.

Is it possible to specify the command a kubernetes pod runs within the Docker image at startup?


I spend 45 minutes looking for this. Then I post a question about it and find the solution 9 minutes later.

There is an hint at what I wanted inside the Cassandra example. The command line below the image:

id: cassandra
kind: Pod
apiVersion: v1beta1
    version: v1beta1
    id: cassandra
      - name: cassandra
        image: kubernetes/cassandra
          - /run.sh
        cpu: 1000
          - name: cql
            containerPort: 9042
          - name: thrift
            containerPort: 9160
          - key: MAX_HEAP_SIZE
            value: 512M
          - key: HEAP_NEWSIZE
            value: 100M
  name: cassandra

Despite finding the solution, it would be nice if there was somewhere obvious in the Kubernetes project where I could see all of the possible options for the various configuration files (pod, service, replication controller).


Kubernetes Storage on bare-metal/private cloud

I'm just starting with Kubernetes on 2 node (master-minion) setup on 2 private cloud servers. I've installed it, did basic config and got it running some simple pods/services from the master to the minion. My question is: How can I use persistent storage with the pods when not using Google...

Openshift .kubeconfig file and certificate authentication

I have been messing around with openshift and reading as much documentation as i can. Yet, the authentication performed by default(using admin .kubeconfig) puzzles me. 1)Are client-certificate-data and client-key-data the same as the admin certificate and key? I ask this because the contents of the certificate/key files are not the...

Etcd is running but no etcd.service is found in systemd on coreos

So I'm trying to setup a master Kubernetes node on coreos in vagrant. I'm using the example master cloud-config, found here https://github.com/GoogleCloudPlatform/kubernetes/blob/master/docs/getting-started-guides/coreos/cloud-configs/master.yaml with the addition of this as the first units: - name: etcd.service command: start - name: fleet.service command: start - name: docker-tcp.socket command: start enable: true content: |...

Is there a way to tell kubernetes to update your containers?

I have a kubernetes cluster, and I am wondering how (best practice) to update containers. I know the idea is to tear down the old containers and put up new ones, but is there a one-liner I can use, do I have to remove the replication controller or pod(s) and...

How to check the containers running on a pod in kubernettes?

I am able to get a list of all pods running on a kubernetes cluster using: kubectl get pods How do I get all the containers running on a particular pod?...

Accessing Kubernetes API on Google Container Engine

According to Kubernetes API docs it is possible to create/list/delete pods, replication controllers and services: http://kubernetes.io/third_party/swagger-ui/#!/v1beta1 However in the Google Container Engine documentation they don't seem to expose this API. The only resources you can manage through a REST API are clusters. Pods, replication controllers and services have to be...

Is it possible to set a different host port than the container's exposed port in docker?

Is it possible to set a different host port than the container's exposed port in docker? For example docker run -name some_container -p 80:8080 -i -t some_img If so, is it -p host:container or -p container:host? I've looked through the docs and haven't found any examples of this nor details...

Run Kubernetes on EC2

I am trying to run kubernetes on EC2 and I used CoreOs alpha channel ami.I configured Kubectl ssh tunnel for the communication between Kubectl client and Kubernets API. But when I try kubectl api-versions command, I am getting following error. Couldn't get available api versions from server: Get http://MyIP:8080/api: dial...

Running Kubernetes locally

I am planning to test Kubernetes locally, but would like to ask some theoretic questions before. I created a pipeline in python that takes as input a whole bunch of files from a directory, and created a docker image out of it (this is my Pod) What I understood from...

Does the kubernetes scheduler support anti-affinity?

I'm looking at deploying Kubernetes on top of a CoreOS cluster, but I think I've run into a deal breaker of sorts. If I'm using just CoreOS and fleet, I can specify within the unit files that I want certain services to not run on the same physical machine as...

How to re-connect to Amazon kubernetes cluster after stopping & starting instances?

I create a cluster for trying out kubernetes using cluster/kube-up.sh in Amazon EC2. Then I stop it to save money when not using it. Next time I start the master & minion instances in amazon, *~/.kube/config has old IP-s for the cluster master as EC2 assigns new public IP to...

How does kubernetes replication controller handle data?

If I setup a replication controller for something like a database, how does it keep the data in the replicas in-sync? If one of the replica goes down, how does it bring it back up with the latest data?

Kubernetes/Container engine HTTP API for creating pods

I need to create pods using HTTP. I created cluster using: gcloud preview container clusters create and I can create pod using: gcloud preview container pods create But this is not what i want. I want to create pods with instance of my application via http API. There is API...

how to connect a kubernetes pod to the outside world without a forwarding rule (google container engine)

I'm using Google's Container Engine service, and got a pod running a server listening on port 3000. I set up the service to connect port 80 to that pod's port 3000. I am able to curl the service using its local and public ip from within the node, but not...

Kubernetes minion not completely connecting

I have a dev kubernetes cluster setup where I have a minion running kube-proxy and kubelet. Both only start if it can connect to the master's apiserver, which it can. Howerver I am getting error updating node status, will retry: error getting node "": minion "" not found I notice...

skydns troubles - i must not 'get it'?

I'm using google container engine and I can create pods and services in my cluster. But when I try to use the DNS feature (skydns) to lookup my services nothing is being found. If I log in to the non-master node, I can see the DNS container and can use...

Unable to access the internet from Kubernetes containers

I am working with the Vagrant Kubernetes 0.9.3 setup on Mac OSX. Environment: Kubernetes 0.9.3 Vagrant 1.7.2 VirtualBox-4.3.20-96996-OSX I am able to successfully deploy images and start containers in a single minion environment: master minion-1 I am unable to access the Internet from inside a running container. I can access...

Can I call rs.initiate() and rs.Add() from node.js using the MongoDb driver?

I'm looking to automate the process of setting up a MongoDb replica set via a sidecar when using Docker and Kubernetes. The above setup isn't terribly important, what it boils down to is that I need to be able to call the mongo replica set commands (e.g. rs.initiate(), rs.add('anotherserver'), rs.conf(),...

How do I access the Kubernetes api from within a pod container?

I used to be able to curl https://$KUBERNETES_SERVICE_HOST:$KUBERNETES_PORT_443_TCP_PORT/api/v1beta3/namespaces/default/ as my base URL, but in kubernetes 0.18.0 it gives me "unauthorized". The strange thing is that if I used the external ip address of the api machine (, it works just fine.

Is there a reliable way how to run virtualized Docker / Kubernetes stack on Windows?

Are there any up-to-date guides, or VM images of some Linux VM + Kubernetes that I could run on Windows? Both VMWare, VirtualBox or Vagrant images would help. I'm trying to set up a development environment. (There is no production environment yet, but it will be most likely self-hosted.) I...

Boot2Docker searching for docker-bootstrap.sock which does not exist

I am currently trying to set up kubernetes on a multi-docker container on CoreOS stack for AWS. To do this I need to set up etcd for flannel and am currently using this guide but am having problems at the first stage where I am suggested to run sudo sh...

Where does kubernete's kubelet create service environment variables?

I'm creating a kubernetes cluster, and in it I have several services. I know based on https://github.com/GoogleCloudPlatform/kubernetes/blob/master/docs/services.md#discovering-services I have two options. use the environment variables set by the kubelet. use skydns I want to try to use the environment variables first before I go adding another dependency into the mix....

How to run two pods in exclusive nodes?

I'd like to run two pods in exclusive nodes. For instance, I have 4 nodes (node-1, node-2, node-3, node-4) and 2 pods (pod-1, pod-2). I want only one pod to run in each node and each pod to run in two nodes, e.g. pod-1 in node-1 and node-2, pod-2 in...

How does Kubernetes' scheduler work?

How does Kubernetes' scheduler work? What I mean is that Kubernetes' scheduler appears to be very simple? My initial thought is that this scheduler is just a simple admission control system, not a real scheduler. Is it that correct? I found a short description, but it is not terribly informative:...

How to convert docker run command into json file?

I was wondering if anyone knows how to create a json file that would be the same as running: docker run -p 80:80 -p 443:443 starblade/pydio-v4 I trying something very ambitious, I want to start my docker container in kubernetes-mesos cluster but can't seem to get the ports correct in...

Using Kubernetes' hooks

I would like to try Kubernetes' hooks but I didn't find any example how I should do it. As far as I know, with this hooks I can run bash scripts in freshly created containers and prior to terminate them. I've found just a short documentation which say this is...

Does Kubernetes provision new VMs for pods on my cloud platform?

I'm currently learning about Kubernetes and still trying to figure it out. I get the general use of it but I think that there still plenty of things I'm missing, here's one of them. If I want to run Kubernetes on my public cloud, like GCE or AWS, will Kubernetes...

Access other containers of a pod in Kubernetes

When I define multiple containers in a pod/pod template like one container running nginx and another php-fpm, how can they access each other? Do I have to define some links in the definition (I could not find docs explaining all available config options) or can they each other by default?...

How do you update a node/minion's label in Kubernetes?

Anyone out there who succesfully updated a node/minion's label in Kubernetes? I can't seem to find any documentation for it. I tried: kubectl update -f minion.yaml with a template gotten from kubectl get minion -o yaml. I get the following error: minion "" is invalid: status: invalid value '{HostIP:

Start kubernetes container with specific command

Using fleet I can specify a command to be run inside the container when it is started. It seems like this should be easily possible with Kubernetes as well, but I can't seem to find anything that says how. It seems like you have to create the container specifically to...

Can kube-apiserver allow the unsecure connection outside of localhost?

I'm trying to setup a kubernetes cluster for a development environment (local vms). Because it's development I'm not using working certs for the api-server. It would seem I have to use the secure connection in order to connect minion daemons such as kube-proxy and kubelet to the master's kube-apiserver. Has...

How to know Pod's own IP address from the container in the Pod?

Kubernetes assigns an IP address for each container, but how can I acquire the IP address from the container in the Pod? I couldn't find the way from documentations.

How to update a set of pods running in kubernetes?

What is the preferred way of updating a set of pods (e.g. after making code changes & pushing underlying docker image to docker hub) controlled by a replication controller in kubernetes cluster? I can see 2 ways: Deleting & re-creating replication controller manually Using kubectl rolling-update With the rolling-update I...

When should you create more than one docker container image instance with Kubernetes Replication Controller?

When using Kubernetes to manage your docker containers, particularly when using the replication controller, when should you increase an images running container instances to more than 1? I understand that Kubernetes can spawn as many container replicas as needed in the replication controller configuration file, but why spawn multiple running...

Permissions error while setting up kubernetes pod

I am a newbie to kubernetes and docker and I am following the tutorial at https://cloud.google.com/container-engine/docs/tutorials/hello-wordpress which teaches how to setup a pod running wordpress. I have setup a GCE instance and have logged into my debian instance and installed docker and kubernetes. But when I specify a file to...

How to properly launch an OpenShift v3 app

As I am trying to launch a sample OpenShift v 3 (Docker/Kubernetes) app with this command: _output/local/go/bin/osc create -f examples/hello-openshift/hello-pod.json I am getting this error: Post https://localhost:8443/api/v1beta2/pods?namespace=default: x509: certificate signed by unknown authority which is also confirmed by this message: http: TLS handshake error from remote error: bad certificate...

Any suggestion for running Aerospike on Kubernetes on CoreOS on GCE?

I would like to run Aerospike cluster on Docker containers managed by Kubernetes on CoreOS on Google Compute Engine (GCE). But since GCE does not permit multicast, I have to use Mesh heartbeat as described here, which has to be set up by specifying all node's IP addresses and ports;...

Kubernetes cluster using Vagrant not working after restart

I installed a Kubernetes cluster by following the instruction here: https://github.com/GoogleCloudPlatform/kubernetes/blob/master/docs/getting-started-guides/vagrant.md Everything looks fine the first time. I'm able to see the nodes, pods, deploy new pods, etc. The problem shows up when I stop the cluster and try to start it again. I'm restarting the cluster as indicated on...

Google Container Engine (GKE): “Hello Wordpress” tutorial not working (ERR_CONNECTION_REFUSED)

I'm trying to setup example from Running Wordpress with a Single Pod. I've done Before You Begin section: $ gcloud config list [compute] zone = europe-west1-c [core] account = [email protected] disable_usage_reporting = False project = com-project-default I've done the steps from the tutorial: "Step 1: Create your cluster" logs here...