input
stringclasses
1 value
output
stringlengths
30
28.3k
text
stringlengths
151
31.8k
instruction
stringlengths
49
30.3k
I won't get into reasoning about the convenience of instrumenting the process running into the pod to focus on the question. I'd avoid creating another process inside the container to expose data, or modify the current process just to expose health endpoint, so I'd choose the liveness check exec way. It doesn't gets into your application and hopefully, it will only consume some cycles of CPU periodically. Anyway, if you decide to expose health info from the pod, I'd use a multi-container pod, with the health exposing application as a sidecar and the working process in a different container.
###Instruction: I'm running a service written in go in a pod in Kubernetes. The service doesn't expose an HTTP interface; it's processing work from a queue. I could: Use an executable liveness check to see if the process is running Expose an HTTP health check endpoint Use expvars to expose basic health data. Is there a common / idiomatic way of doing this in go/Kubernetes? ### Response: I won't get into reasoning about the convenience of instrumenting the process running into the pod to focus on the question. I'd avoid creating another process inside the container to expose data, or modify the current process just to expose health endpoint, so I'd choose the liveness check exec way. It doesn't gets into your application and hopefully, it will only consume some cycles of CPU periodically. Anyway, if you decide to expose health info from the pod, I'd use a multi-container pod, with the health exposing application as a sidecar and the working process in a different container.
I'm running a service written in go in a pod in Kubernetes. The service doesn't expose an HTTP interface; it's processing work from a queue. I could: Use an executable liveness check to see if the process is running Expose an HTTP health check endpoint Use expvars to expose basic health data. Is there a common / idiomatic way of doing this in go/Kubernetes?
Deployments are a newer and higher level concept than Replication Controllers. They manage the deployment of Replica Sets (also a newer concept, but pretty much equivalent to Replication Controllers), and allow for easy updating of a Replica Set as well as the ability to roll back to a previous deployment. Previously this would have to be done with kubectl rolling-update which was not declarative and did not provide the rollback features. Kubernetes Dashboard has not yet been updated to support Deployments, and currently only supports Replication Controllers (see Deployments not visible in Kubernetes Dashboard). EDIT: The dashboard now supports Deployments.
###Instruction: I wanted to know what is the difference between a Replication Controller and a Deployment within Kubernetes (1.2). Going through the getting started document (http://kubernetes.io/docs/hellonode/) I have created a deployment - but it doesn't show up on the web UI. When I create apps from the web UI - they are created as replication controllers. Functionally though, they seem very similar (they both manage pods and have services). So - what is the difference and when should I use each? ### Response: Deployments are a newer and higher level concept than Replication Controllers. They manage the deployment of Replica Sets (also a newer concept, but pretty much equivalent to Replication Controllers), and allow for easy updating of a Replica Set as well as the ability to roll back to a previous deployment. Previously this would have to be done with kubectl rolling-update which was not declarative and did not provide the rollback features. Kubernetes Dashboard has not yet been updated to support Deployments, and currently only supports Replication Controllers (see Deployments not visible in Kubernetes Dashboard). EDIT: The dashboard now supports Deployments.
I wanted to know what is the difference between a Replication Controller and a Deployment within Kubernetes (1.2). Going through the getting started document (http://kubernetes.io/docs/hellonode/) I have created a deployment - but it doesn't show up on the web UI. When I create apps from the web UI - they are created as replication controllers. Functionally though, they seem very similar (they both manage pods and have services). So - what is the difference and when should I use each?
If your development machine is not part of the GCE cluster (i.e. a GCE VM), then you will not be able to directly mount it. Your best bet in that case would be to SSH to it via a machine it is mounted it (i.e the node your pod is scheduled to).
###Instruction: I have a Kubernetes cluster running on Google Cloud Platform. I have 3 nodes and several pods running on these nodes. One of the pods runs Ghost blog platform and has mounted a gcePersistentDisk volume. The manifest file to create the pod: apiVersion: extensions/v1beta1 kind: Deployment metadata: labels: name: ghost name: ghost spec: replicas: 1 template: metadata: labels: name: ghost spec: containers: - image: ghost:0.7 name: ghost env: - name: NODE_ENV value: production ports: - containerPort: 2368 name: http-server volumeMounts: - name: ghost mountPath: /var/lib/ghost volumes: - name: ghost gcePersistentDisk: pdName: ghost fsType: ext4 I'd like someway to access this volume from my development machine. Is there any way to mount this disk in my machine? ### Response: If your development machine is not part of the GCE cluster (i.e. a GCE VM), then you will not be able to directly mount it. Your best bet in that case would be to SSH to it via a machine it is mounted it (i.e the node your pod is scheduled to).
I have a Kubernetes cluster running on Google Cloud Platform. I have 3 nodes and several pods running on these nodes. One of the pods runs Ghost blog platform and has mounted a gcePersistentDisk volume. The manifest file to create the pod: apiVersion: extensions/v1beta1 kind: Deployment metadata: labels: name: ghost name: ghost spec: replicas: 1 template: metadata: labels: name: ghost spec: containers: - image: ghost:0.7 name: ghost env: - name: NODE_ENV value: production ports: - containerPort: 2368 name: http-server volumeMounts: - name: ghost mountPath: /var/lib/ghost volumes: - name: ghost gcePersistentDisk: pdName: ghost fsType: ext4 I'd like someway to access this volume from my development machine. Is there any way to mount this disk in my machine?
The documentation on putting different versions in different namespaces is a bit incorrect I think. It is actually the point of namespaces to separate things completely like this. You should put a complete version of each "track" or deployment stage of your app into its own namespace. You can then use hardcoded service names - "http://myservice/" - as the DNS will resolve on default to the local namespace. For ingresses I have copied my answer here from the GitHub issue on cross-namespace ingresses. You should use the approach that our group is using for Ingresses. Think of an Ingress not as much as a LoadBalancer but just a document specifying some mappings between URLs and services within the same namespace. An example, from a real document we use: apiVersion: extensions/v1beta1 kind: Ingress metadata: name: ingress namespace: dev-1 spec: rules: - host: api-gateway-dev-1.faceit.com http: paths: - backend: serviceName: api-gateway servicePort: 80 path: / - host: api-shop-dev-1.faceit.com http: paths: - backend: serviceName: api-shop servicePort: 80 path: / - host: api-search-dev-1.faceit.com http: paths: - backend: serviceName: api-search servicePort: 8080 path: / tls: - hosts: - api-gateway-dev-1.faceit.com - api-search-dev-1.faceit.com - api-shop-dev-1.faceit.com secretName: faceitssl We make one of these for each of our namespaces for each track. Then, we have a single namespace with an Ingress Controller which runs automatically configured NGINX pods. Another AWS Load balancer points to these pods which run on a NodePort using a DaemonSet to run at most and at least one on every node in our cluster. As such, the traffic is then routed: Internet -> AWS ELB -> NGINX (on node) -> Pod We keep the isolation between namespaces while using Ingresses as they were intended. It's not correct or even sensible to use one ingress to hit multiple namespaces. It just doesn't make sense, given how they are designed. The solution is to use one ingress per each namespace with a cluster-scope ingress controller which actually does the routing. All an Ingress is to Kubernetes is an object with some data on it. It's up to the Ingress Controller to do the routing. See the document here for more info on Ingress Controllers.
###Instruction: I'm working on an application deployment environment using Kubernetes where I want to be able to spin up copies of my entire application stack based on a Git reference for the primarily web application, e.g. "master" and "my-topic-branch". I want these copies of the app stack to coexist in the same cluster. I can create Kubernetes services, replication controllers, and pods that use a "gitRef" label to isolate the stacks from each other, but some of the pods in the stack depend on each other (via Kubernetes services), and I don't see an easy, clean way to restrict the services that are exposed to a pod. There a couple ways to achieve it that I can think of, but neither are ideal: Put each stack in a separate Kubernetes namespace. This provides the cleanest isolation, in that there are no resource name conflicts and the applications can have the DNS hostnames for the services they depend on hardcoded, but seems to violate what the documentation says about namespaces†: It is not necessary to use multiple namespaces just to separate slightly different resources, such as different versions of the same software: use labels to distinguish resources within the same namespace. This makes sense, as putting the app stacks in different resources would negate all the usefulness of label selectors. I'd just name the namespace with the Git reference and all the other resources wouldn't need to be filtered at all. Create a copy of each service for each copy of the application stack, e.g. "mysql-master" and "mysql-my-topic-branch". This has the advantage that all the app stacks can coexist in the same namespace, but the disadvantage of not being able to hardcode the DNS hostname for the service in the applications that need them, e.g. having a web app target the hostname "mysql" regardless of which instance of the MySQL Kubernetes service it actually resolves to. I would need to use some mechanism of injecting the correct hostname into the pods or having them figure it out for themselves somehow. Essentially what I want is a way of telling Kubernetes, "Expose this service's hostname only to pods with the given labels, and expose it to them with the given hostname" for a specific service. This would allow me to use the second approach without having to have application-level logic for determining the correct hostname to use. What's the best way to achieve what I'm after? [†] http://kubernetes.io/v1.1/docs/user-guide/namespaces.html ### Response: The documentation on putting different versions in different namespaces is a bit incorrect I think. It is actually the point of namespaces to separate things completely like this. You should put a complete version of each "track" or deployment stage of your app into its own namespace. You can then use hardcoded service names - "http://myservice/" - as the DNS will resolve on default to the local namespace. For ingresses I have copied my answer here from the GitHub issue on cross-namespace ingresses. You should use the approach that our group is using for Ingresses. Think of an Ingress not as much as a LoadBalancer but just a document specifying some mappings between URLs and services within the same namespace. An example, from a real document we use: apiVersion: extensions/v1beta1 kind: Ingress metadata: name: ingress namespace: dev-1 spec: rules: - host: api-gateway-dev-1.faceit.com http: paths: - backend: serviceName: api-gateway servicePort: 80 path: / - host: api-shop-dev-1.faceit.com http: paths: - backend: serviceName: api-shop servicePort: 80 path: / - host: api-search-dev-1.faceit.com http: paths: - backend: serviceName: api-search servicePort: 8080 path: / tls: - hosts: - api-gateway-dev-1.faceit.com - api-search-dev-1.faceit.com - api-shop-dev-1.faceit.com secretName: faceitssl We make one of these for each of our namespaces for each track. Then, we have a single namespace with an Ingress Controller which runs automatically configured NGINX pods. Another AWS Load balancer points to these pods which run on a NodePort using a DaemonSet to run at most and at least one on every node in our cluster. As such, the traffic is then routed: Internet -> AWS ELB -> NGINX (on node) -> Pod We keep the isolation between namespaces while using Ingresses as they were intended. It's not correct or even sensible to use one ingress to hit multiple namespaces. It just doesn't make sense, given how they are designed. The solution is to use one ingress per each namespace with a cluster-scope ingress controller which actually does the routing. All an Ingress is to Kubernetes is an object with some data on it. It's up to the Ingress Controller to do the routing. See the document here for more info on Ingress Controllers.
I'm working on an application deployment environment using Kubernetes where I want to be able to spin up copies of my entire application stack based on a Git reference for the primarily web application, e.g. "master" and "my-topic-branch". I want these copies of the app stack to coexist in the same cluster. I can create Kubernetes services, replication controllers, and pods that use a "gitRef" label to isolate the stacks from each other, but some of the pods in the stack depend on each other (via Kubernetes services), and I don't see an easy, clean way to restrict the services that are exposed to a pod. There a couple ways to achieve it that I can think of, but neither are ideal: Put each stack in a separate Kubernetes namespace. This provides the cleanest isolation, in that there are no resource name conflicts and the applications can have the DNS hostnames for the services they depend on hardcoded, but seems to violate what the documentation says about namespaces†: It is not necessary to use multiple namespaces just to separate slightly different resources, such as different versions of the same software: use labels to distinguish resources within the same namespace. This makes sense, as putting the app stacks in different resources would negate all the usefulness of label selectors. I'd just name the namespace with the Git reference and all the other resources wouldn't need to be filtered at all. Create a copy of each service for each copy of the application stack, e.g. "mysql-master" and "mysql-my-topic-branch". This has the advantage that all the app stacks can coexist in the same namespace, but the disadvantage of not being able to hardcode the DNS hostname for the service in the applications that need them, e.g. having a web app target the hostname "mysql" regardless of which instance of the MySQL Kubernetes service it actually resolves to. I would need to use some mechanism of injecting the correct hostname into the pods or having them figure it out for themselves somehow. Essentially what I want is a way of telling Kubernetes, "Expose this service's hostname only to pods with the given labels, and expose it to them with the given hostname" for a specific service. This would allow me to use the second approach without having to have application-level logic for determining the correct hostname to use. What's the best way to achieve what I'm after? [†] http://kubernetes.io/v1.1/docs/user-guide/namespaces.html
My colleague has a good blog post about this topic: http://blog.jonparrott.com/building-a-paas-on-kubernetes/ Basically, Kubernetes is not a Platform-as-a-Service, it's a toolkit on which you can build your own Platform-a-as-Service. It's not very opinionated by design, instead it focuses on solving some tricky problems with scheduling, networking, and coordinating containers, and lets you layer in your opinions on top of it. One of the simplest ways to automate the workflows you're describing is using a Makefile. A step up from that, you can design your own miniature PaaS, which the author of the first blog post did here: https://github.com/jonparrott/noel Or, you could get involved in more sophisticated efforts to build an open source PaaS on Kubernetes, like OpenShift: https://www.openshift.com/ or Deis, which is building a Heroku-like platform on Kubernetes: https://deis.com/ or Redspread, which is building "Git for Kubernetes cluster": https://redspread.com/ and there are many other examples of people building PaaS on top of Kubernetes. But I think it will be a long time, if ever, that there is an "industry standard" way to deploy to Kubernetes, since half the purpose is to enable multiple deployment workflows for different use cases. I do want to note that as far as building container images, Google Cloud Container Builder can be a useful tool, since you can do things like use it to automatically build an image any time you push to a repository which could then get deployed. Alternatively, Jenkins is a popular way to automate CI/CD flows with Kubernetes.
###Instruction: I am hoping to find a good way to automate the process of going from code to a deployed application on my kubernetes cluster. In order to build and deploy my app I need to first build the docker image, tag it, and then push it to ECR. I then need to update my deployment.yaml with the new tag for the docker image and run the deployment with kubectl apply -f deployment.yaml. This will go and perform a rolling deployment on the kubernetes cluster updating the pods to the new version of the container image, once this deployment has completed I may need to do other application specific things such as running database migrations, or cache clear/warming which may or may not need to run for a given deployment. I suppose I could just write a shell script that runs all of these commands, and run it whenever I want to start up a new deployment, but I am hoping there is a better/industry standard way to solve these problems that I have missed. As I was writing this question I noticed stackoverflow recommend this question: Kubernetes Deployments. One of the answers to it seems to imply at least some of what I am looking for is coming soon to kubernetes, but I want to make sure that if there is a better solution I could be using now that I at least know about it. ### Response: My colleague has a good blog post about this topic: http://blog.jonparrott.com/building-a-paas-on-kubernetes/ Basically, Kubernetes is not a Platform-as-a-Service, it's a toolkit on which you can build your own Platform-a-as-Service. It's not very opinionated by design, instead it focuses on solving some tricky problems with scheduling, networking, and coordinating containers, and lets you layer in your opinions on top of it. One of the simplest ways to automate the workflows you're describing is using a Makefile. A step up from that, you can design your own miniature PaaS, which the author of the first blog post did here: https://github.com/jonparrott/noel Or, you could get involved in more sophisticated efforts to build an open source PaaS on Kubernetes, like OpenShift: https://www.openshift.com/ or Deis, which is building a Heroku-like platform on Kubernetes: https://deis.com/ or Redspread, which is building "Git for Kubernetes cluster": https://redspread.com/ and there are many other examples of people building PaaS on top of Kubernetes. But I think it will be a long time, if ever, that there is an "industry standard" way to deploy to Kubernetes, since half the purpose is to enable multiple deployment workflows for different use cases. I do want to note that as far as building container images, Google Cloud Container Builder can be a useful tool, since you can do things like use it to automatically build an image any time you push to a repository which could then get deployed. Alternatively, Jenkins is a popular way to automate CI/CD flows with Kubernetes.
I am hoping to find a good way to automate the process of going from code to a deployed application on my kubernetes cluster. In order to build and deploy my app I need to first build the docker image, tag it, and then push it to ECR. I then need to update my deployment.yaml with the new tag for the docker image and run the deployment with kubectl apply -f deployment.yaml. This will go and perform a rolling deployment on the kubernetes cluster updating the pods to the new version of the container image, once this deployment has completed I may need to do other application specific things such as running database migrations, or cache clear/warming which may or may not need to run for a given deployment. I suppose I could just write a shell script that runs all of these commands, and run it whenever I want to start up a new deployment, but I am hoping there is a better/industry standard way to solve these problems that I have missed. As I was writing this question I noticed stackoverflow recommend this question: Kubernetes Deployments. One of the answers to it seems to imply at least some of what I am looking for is coming soon to kubernetes, but I want to make sure that if there is a better solution I could be using now that I at least know about it.
I believe you want to set maxUnavailable (which defaults to 1) to 0. This should prevent Kubernetes from taking down any existing pods prior bringing a healthy one up. maxSurge only specifies how many pods exceeding the desired count you are willing to see getting deployed during a rolling upgrade. Since you only tried to roll out a single updated pod in your third deployment, the increase of maxSurge beyond the default value of 1 did not make a difference. See also the Rolling Update Deployment section in the documentation.
###Instruction: I was playing around with this: http://kubernetes.io/docs/user-guide/deployments/ in my infrastructure. I have a few deployments where I need replicas - but I have a couple where i only want one replica inside the deployment - however having an easy way to change the image version is great and required. So I tried to see what would happen if you ran a broken update on a deployment with only 1 replica - if we do the following (from the documentation above): apiVersion: extensions/v1beta1 kind: Deployment metadata: name: nginx-deployment spec: replicas: 3 template: metadata: labels: app: nginx spec: containers: - name: nginx image: nginx:1.7.9 ports: - containerPort: 80 if we then run kubectl create -f nginx-deployment.yaml we see 3 healthy running replicas. If we then change the above file from replicas: 3 to replicas: 1 and run the apply command: kubectl apply -f nginx-deployment.yaml - we see 1 healthy replica. Now - if we change image: nginx:1.7.9 to something like image: nginx:1.7.9broken - and run kubectl apply -f nginx-deployment.yaml we see something like this: $ kubectl get rs NAME DESIRED CURRENT AGE nginx-deployment-2035384211 0 0 11m <- this is the first one we created with 3 replicas nginx-deployment-3257237551 1 1 8m <- this is the broken one we made with 1 replica and a bad image name nginx-deployment-3412426736 0 0 10m <- this is the 2nd one we created with 1 replica $ kubectl get pods NAME READY STATUS RESTARTS AGE nginx-deployment-3257237551-od22j 0/1 ImagePullBackOff 0 19s So what seems to have happened here is the deployment has run, and created a new broken pod, and destryed the old one - something which the documentation, linked above, tells me should not happen? My question is - is there some setting i can change so that, even with 1 replica, the deployment will still work as intended, i.e. if the new pod created by the deployment is bad, it will keep the old pod running, or is there something else i should be doing when updating the images of single pods? note - this all seems to work fine on 2+ many replicas, and i tried to set the maxSurge value to like 5 to see if that made a difference, but it did not. ### Response: I believe you want to set maxUnavailable (which defaults to 1) to 0. This should prevent Kubernetes from taking down any existing pods prior bringing a healthy one up. maxSurge only specifies how many pods exceeding the desired count you are willing to see getting deployed during a rolling upgrade. Since you only tried to roll out a single updated pod in your third deployment, the increase of maxSurge beyond the default value of 1 did not make a difference. See also the Rolling Update Deployment section in the documentation.
I was playing around with this: http://kubernetes.io/docs/user-guide/deployments/ in my infrastructure. I have a few deployments where I need replicas - but I have a couple where i only want one replica inside the deployment - however having an easy way to change the image version is great and required. So I tried to see what would happen if you ran a broken update on a deployment with only 1 replica - if we do the following (from the documentation above): apiVersion: extensions/v1beta1 kind: Deployment metadata: name: nginx-deployment spec: replicas: 3 template: metadata: labels: app: nginx spec: containers: - name: nginx image: nginx:1.7.9 ports: - containerPort: 80 if we then run kubectl create -f nginx-deployment.yaml we see 3 healthy running replicas. If we then change the above file from replicas: 3 to replicas: 1 and run the apply command: kubectl apply -f nginx-deployment.yaml - we see 1 healthy replica. Now - if we change image: nginx:1.7.9 to something like image: nginx:1.7.9broken - and run kubectl apply -f nginx-deployment.yaml we see something like this: $ kubectl get rs NAME DESIRED CURRENT AGE nginx-deployment-2035384211 0 0 11m <- this is the first one we created with 3 replicas nginx-deployment-3257237551 1 1 8m <- this is the broken one we made with 1 replica and a bad image name nginx-deployment-3412426736 0 0 10m <- this is the 2nd one we created with 1 replica $ kubectl get pods NAME READY STATUS RESTARTS AGE nginx-deployment-3257237551-od22j 0/1 ImagePullBackOff 0 19s So what seems to have happened here is the deployment has run, and created a new broken pod, and destryed the old one - something which the documentation, linked above, tells me should not happen? My question is - is there some setting i can change so that, even with 1 replica, the deployment will still work as intended, i.e. if the new pod created by the deployment is bad, it will keep the old pod running, or is there something else i should be doing when updating the images of single pods? note - this all seems to work fine on 2+ many replicas, and i tried to set the maxSurge value to like 5 to see if that made a difference, but it did not.
kubectl describe doesn't support -o or equivalent. It's meant to be human-readable rather than script-friendly. You can achieve what you described with kubectl get pods -l <selector_of_your_rc> -o <output_format>, for example: $ kubectl get pods -l app=guestbook,tier=frontend -o name pod/frontend-a4kjz pod/frontend-am1ua pod/frontend-yz2dq
###Instruction: kubectl get command has this flag -o to format the output. Is there a similar way to format the output of the kubectl describe command? For example: kubectl describe -o="jsonpath={...}" pods my-rc would print a JSON format for the list of pods in my-rc replication controller. But -o is not accepted for the describe command. ### Response: kubectl describe doesn't support -o or equivalent. It's meant to be human-readable rather than script-friendly. You can achieve what you described with kubectl get pods -l <selector_of_your_rc> -o <output_format>, for example: $ kubectl get pods -l app=guestbook,tier=frontend -o name pod/frontend-a4kjz pod/frontend-am1ua pod/frontend-yz2dq
kubectl get command has this flag -o to format the output. Is there a similar way to format the output of the kubectl describe command? For example: kubectl describe -o="jsonpath={...}" pods my-rc would print a JSON format for the list of pods in my-rc replication controller. But -o is not accepted for the describe command.
Update #2: Kubernetes 1.5 will ship with a much better version of kubectl rollout status and improve even further in 1.6, possibly replacing my custom solution/script laid out below. Update #1: I have turned my answer into a script hosted on Github which has received a small number of improving PRs by now. Original answer: First of all, I believe the kubectl command you got is not correct: It replaces all white spaces by commas but then tries to get the 4th field after separating by white spaces. In order to validate that a deployment (or upgrade thereof) made it to all pods, I think you should check whether the number of available replicas matches the number of desired replicas. That is, whether the AVAILABLE and DESIRED columns in the kubectl output are equal. While you could get the number of available replicas (the 5th column) through kubectl get deployment nginx | tail -n +2 | awk '{print $5}' and the number of desired replicas (2nd column) through kubectl get deployment nginx | tail -n +2 | awk '{print $2}' a cleaner way is to use kubectl's jsonpath output, especially if you want to take the generation requirement that the official documentation mentions into account as well. Here's a quick bash script I wrote that expects to be given the deployment name on the command line, waits for the observed generation to become the specified one, and then waits for the available replicas to reach the number of the specified ones: #!/bin/bash set -o errexit set -o pipefail set -o nounset deployment= get_generation() { get_deployment_jsonpath '{.metadata.generation}' } get_observed_generation() { get_deployment_jsonpath '{.status.observedGeneration}' } get_replicas() { get_deployment_jsonpath '{.spec.replicas}' } get_available_replicas() { get_deployment_jsonpath '{.status.availableReplicas}' } get_deployment_jsonpath() { local readonly _jsonpath="$1" kubectl get deployment "${deployment}" -o "jsonpath=${_jsonpath}" } if [[ $# != 1 ]]; then echo "usage: $(basename $0) <deployment>" >&2 exit 1 fi readonly deployment="$1" readonly generation=$(get_generation) echo "waiting for specified generation ${generation} to be observed" while [[ $(get_observed_generation) -lt ${generation} ]]; do sleep .5 done echo "specified generation observed." readonly replicas="$(get_replicas)" echo "specified replicas: ${replicas}" available=-1 while [[ ${available} -ne ${replicas} ]]; do sleep .5 available=$(get_available_replicas) echo "available replicas: ${available}" done echo "deployment complete."
###Instruction: The status of a deployment indicates that you can look at a deployments observedGeneration vs generation and when observedGeneration >= generation then the deployment succeeded. That's fine, but I'm interested in knowing when the new container is actually running in all of my pods, so that if I hit a service I know for sure I'm hitting a server that represents the latest deployed container. Another tip from a K8S Slack member: kubectl get deployments | grep <deployment-name> | sed 's/ /,/g' | cut -d ' ' -f 4 I deployed a bad image, resulting in ErrImagePull, yet the deployment still reported the correct number of 8 up-date-date replicas (available replicas was 7). ### Response: Update #2: Kubernetes 1.5 will ship with a much better version of kubectl rollout status and improve even further in 1.6, possibly replacing my custom solution/script laid out below. Update #1: I have turned my answer into a script hosted on Github which has received a small number of improving PRs by now. Original answer: First of all, I believe the kubectl command you got is not correct: It replaces all white spaces by commas but then tries to get the 4th field after separating by white spaces. In order to validate that a deployment (or upgrade thereof) made it to all pods, I think you should check whether the number of available replicas matches the number of desired replicas. That is, whether the AVAILABLE and DESIRED columns in the kubectl output are equal. While you could get the number of available replicas (the 5th column) through kubectl get deployment nginx | tail -n +2 | awk '{print $5}' and the number of desired replicas (2nd column) through kubectl get deployment nginx | tail -n +2 | awk '{print $2}' a cleaner way is to use kubectl's jsonpath output, especially if you want to take the generation requirement that the official documentation mentions into account as well. Here's a quick bash script I wrote that expects to be given the deployment name on the command line, waits for the observed generation to become the specified one, and then waits for the available replicas to reach the number of the specified ones: #!/bin/bash set -o errexit set -o pipefail set -o nounset deployment= get_generation() { get_deployment_jsonpath '{.metadata.generation}' } get_observed_generation() { get_deployment_jsonpath '{.status.observedGeneration}' } get_replicas() { get_deployment_jsonpath '{.spec.replicas}' } get_available_replicas() { get_deployment_jsonpath '{.status.availableReplicas}' } get_deployment_jsonpath() { local readonly _jsonpath="$1" kubectl get deployment "${deployment}" -o "jsonpath=${_jsonpath}" } if [[ $# != 1 ]]; then echo "usage: $(basename $0) <deployment>" >&2 exit 1 fi readonly deployment="$1" readonly generation=$(get_generation) echo "waiting for specified generation ${generation} to be observed" while [[ $(get_observed_generation) -lt ${generation} ]]; do sleep .5 done echo "specified generation observed." readonly replicas="$(get_replicas)" echo "specified replicas: ${replicas}" available=-1 while [[ ${available} -ne ${replicas} ]]; do sleep .5 available=$(get_available_replicas) echo "available replicas: ${available}" done echo "deployment complete."
The status of a deployment indicates that you can look at a deployments observedGeneration vs generation and when observedGeneration >= generation then the deployment succeeded. That's fine, but I'm interested in knowing when the new container is actually running in all of my pods, so that if I hit a service I know for sure I'm hitting a server that represents the latest deployed container. Another tip from a K8S Slack member: kubectl get deployments | grep <deployment-name> | sed 's/ /,/g' | cut -d ' ' -f 4 I deployed a bad image, resulting in ErrImagePull, yet the deployment still reported the correct number of 8 up-date-date replicas (available replicas was 7).
This sounds like a prime example for a readiness probe: It tells Kubernetes to not take a pod into load balancing until a certain condition holds, often an HTTP endpoint that returns positively. Here's an example probe defined along a Deployment specification: apiVersion: extensions/v1beta1 kind: Deployment metadata: name: nginx spec: template: metadata: labels: app: nginx spec: containers: - name: nginx image: nginx ports: - containerPort: 80 readinessProbe: httpGet: path: /index.html port: 80 initialDelaySeconds: 30 timeoutSeconds: 1 See the user guide for a starter and follow-up links contained.
###Instruction: I have a ruby on rails app on kubernetes. Here's what I do kubernetes rolling-update new_file Kubernetes began to create new pods When the new pods are ready, Kubernetes kills the old pod. However, although my new pod are in ready state, they are actually doing rails assets build/compressing. They aren't ready yet. How can I let kubernetes know that it's not ready yet? ### Response: This sounds like a prime example for a readiness probe: It tells Kubernetes to not take a pod into load balancing until a certain condition holds, often an HTTP endpoint that returns positively. Here's an example probe defined along a Deployment specification: apiVersion: extensions/v1beta1 kind: Deployment metadata: name: nginx spec: template: metadata: labels: app: nginx spec: containers: - name: nginx image: nginx ports: - containerPort: 80 readinessProbe: httpGet: path: /index.html port: 80 initialDelaySeconds: 30 timeoutSeconds: 1 See the user guide for a starter and follow-up links contained.
I have a ruby on rails app on kubernetes. Here's what I do kubernetes rolling-update new_file Kubernetes began to create new pods When the new pods are ready, Kubernetes kills the old pod. However, although my new pod are in ready state, they are actually doing rails assets build/compressing. They aren't ready yet. How can I let kubernetes know that it's not ready yet?
The 503 from Elasticsearch is likely the issue. It should be returning a 200 if all is well. Your first step should be to look at the Elasticsearch logs. You can do this with the kubectl logs POD command. Your es-controller and es-service YAML appears to be correct. One thing to note is that the fluentd-elasticsearch container you are using provides a configuration suitable for systems using syslog, whereas CoreOS uses systemd/journald. That configuration will likely still provide you logs from your docker containers, as long as you are using the default json-file log driver, but will not provide system logs. To get the system logs, you have to use other means, e.g., https://github.com/reevoo/fluent-plugin-systemd or https://github.com/mheese/journalbeat.
###Instruction: I am trying to implement logging on my AWS/CoreOS/Kubernetes (1.1) setup, which I've set up without kube-up. So far I've installed fluentd as a static pod on all nodes and the Fluentd-Elasticsearch addon replication controllers and services. However, it doesn't yet work. Specifically, Kibana crashes like this: ELASTICSEARCH_URL=http://elasticsearch-logging.kube-system:9200 {"@timestamp":"2016-03-14T22:54:04.906Z","level":"error","message":"Service Unavailable","node_env":"production","error":{"message":"Service Unavailable","name":"Error","stack":"Error: Service Unavailable\n at respond (/kibana-4.0.2-linux-x64/src/node_modules/elasticsearch/src/lib/transport.js:235:15)\n at checkRespForFailure (/kibana-4.0.2-linux-x64/src/node_modules/elasticsearch/src/lib/transport.js:203:7)\n at HttpConnector.<anonymous> (/kibana-4.0.2-linux-x64/src/node_modules/elasticsearch/src/lib/connectors/http.js:156:7)\n at IncomingMessage.bound (/kibana-4.0.2-linux-x64/src/node_modules/elasticsearch/node_modules/lodash-node/modern/internals/baseBind.js:56:17)\n at IncomingMessage.emit (events.js:117:20)\n at _stream_readable.js:944:16\n at process._tickCallback (node.js:442:13)\n"}} {"@timestamp":"2016-03-14T22:54:04.908Z","level":"fatal","message":"Service Unavailable","node_env":"production","error":{"message":"Service Unavailable","name":"Error","stack":"Error: Service Unavailable\n at respond (/kibana-4.0.2-linux-x64/src/node_modules/elasticsearch/src/lib/transport.js:235:15)\n at checkRespForFailure (/kibana-4.0.2-linux-x64/src/node_modules/elasticsearch/src/lib/transport.js:203:7)\n at HttpConnector.<anonymous> (/kibana-4.0.2-linux-x64/src/node_modules/elasticsearch/src/lib/connectors/http.js:156:7)\n at IncomingMessage.bound (/kibana-4.0.2-linux-x64/src/node_modules/elasticsearch/node_modules/lodash-node/modern/internals/baseBind.js:56:17)\n at IncomingMessage.emit (events.js:117:20)\n at _stream_readable.js:944:16\n at process._tickCallback (node.js:442:13)\n"}} What should I do? FWIW, Elasticsearch is connectable at http://elasticsearch-logging.kube-system:9200/, although it does return status 503. That could be the issue for all I know. # curl http://elasticsearch-logging.kube-system:9200/ { "status" : 503, "name" : "Puppet Master", "cluster_name" : "kubernetes-logging", "version" : { "number" : "1.5.2", "build_hash" : "62ff9868b4c8a0c45860bebb259e21980778ab1c", "build_timestamp" : "2015-04-27T09:21:06Z", "build_snapshot" : false, "lucene_version" : "4.10.4" }, "tagline" : "You Know, for Search" } fluentd-es.yaml apiVersion: v1 kind: Pod metadata: name: fluentd-elasticsearch namespace: kube-system spec: containers: - name: fluentd-elasticsearch image: gcr.io/google_containers/fluentd-elasticsearch:1.13 resources: limits: cpu: 100m args: - -q volumeMounts: - name: varlog mountPath: /var/log - name: varlibdockercontainers mountPath: /var/lib/docker/containers readOnly: true terminationGracePeriodSeconds: 30 volumes: - name: varlog hostPath: path: /var/log - name: varlibdockercontainers hostPath: path: /var/lib/docker/containers es-controller.yaml apiVersion: v1 kind: ReplicationController metadata: name: elasticsearch-logging-v1 namespace: kube-system labels: k8s-app: elasticsearch-logging version: v1 kubernetes.io/cluster-service: "true" spec: replicas: 2 selector: k8s-app: elasticsearch-logging version: v1 template: metadata: labels: k8s-app: elasticsearch-logging version: v1 kubernetes.io/cluster-service: "true" spec: containers: - image: gcr.io/google_containers/elasticsearch:1.7 name: elasticsearch-logging resources: limits: cpu: 100m ports: - containerPort: 9200 name: db protocol: TCP - containerPort: 9300 name: transport protocol: TCP volumeMounts: - name: es-persistent-storage mountPath: /data volumes: - name: es-persistent-storage emptyDir: {} es-service.yaml apiVersion: v1 kind: Service metadata: name: elasticsearch-logging namespace: kube-system labels: k8s-app: elasticsearch-logging kubernetes.io/cluster-service: "true" kubernetes.io/name: "Elasticsearch" spec: ports: - port: 9200 protocol: TCP targetPort: db selector: k8s-app: elasticsearch-logging kibana-controller.yaml apiVersion: v1 kind: ReplicationController metadata: name: kibana-logging-v1 namespace: kube-system labels: k8s-app: kibana-logging version: v1 kubernetes.io/cluster-service: "true" spec: replicas: 1 selector: k8s-app: kibana-logging version: v1 template: metadata: labels: k8s-app: kibana-logging version: v1 kubernetes.io/cluster-service: "true" spec: containers: - name: kibana-logging image: gcr.io/google_containers/kibana:1.3 resources: limits: cpu: 100m env: - name: "ELASTICSEARCH_URL" value: "http://elasticsearch-logging.kube-system:9200" ports: - containerPort: 5601 name: ui protocol: TCP kibana-service.yaml apiVersion: v1 kind: Service metadata: name: kibana-logging namespace: kube-system labels: k8s-app: kibana-logging kubernetes.io/cluster-service: "true" kubernetes.io/name: "Kibana" spec: ports: - port: 5601 protocol: TCP targetPort: ui selector: k8s-app: kibana-logging ### Response: The 503 from Elasticsearch is likely the issue. It should be returning a 200 if all is well. Your first step should be to look at the Elasticsearch logs. You can do this with the kubectl logs POD command. Your es-controller and es-service YAML appears to be correct. One thing to note is that the fluentd-elasticsearch container you are using provides a configuration suitable for systems using syslog, whereas CoreOS uses systemd/journald. That configuration will likely still provide you logs from your docker containers, as long as you are using the default json-file log driver, but will not provide system logs. To get the system logs, you have to use other means, e.g., https://github.com/reevoo/fluent-plugin-systemd or https://github.com/mheese/journalbeat.
I am trying to implement logging on my AWS/CoreOS/Kubernetes (1.1) setup, which I've set up without kube-up. So far I've installed fluentd as a static pod on all nodes and the Fluentd-Elasticsearch addon replication controllers and services. However, it doesn't yet work. Specifically, Kibana crashes like this: ELASTICSEARCH_URL=http://elasticsearch-logging.kube-system:9200 {"@timestamp":"2016-03-14T22:54:04.906Z","level":"error","message":"Service Unavailable","node_env":"production","error":{"message":"Service Unavailable","name":"Error","stack":"Error: Service Unavailable\n at respond (/kibana-4.0.2-linux-x64/src/node_modules/elasticsearch/src/lib/transport.js:235:15)\n at checkRespForFailure (/kibana-4.0.2-linux-x64/src/node_modules/elasticsearch/src/lib/transport.js:203:7)\n at HttpConnector.<anonymous> (/kibana-4.0.2-linux-x64/src/node_modules/elasticsearch/src/lib/connectors/http.js:156:7)\n at IncomingMessage.bound (/kibana-4.0.2-linux-x64/src/node_modules/elasticsearch/node_modules/lodash-node/modern/internals/baseBind.js:56:17)\n at IncomingMessage.emit (events.js:117:20)\n at _stream_readable.js:944:16\n at process._tickCallback (node.js:442:13)\n"}} {"@timestamp":"2016-03-14T22:54:04.908Z","level":"fatal","message":"Service Unavailable","node_env":"production","error":{"message":"Service Unavailable","name":"Error","stack":"Error: Service Unavailable\n at respond (/kibana-4.0.2-linux-x64/src/node_modules/elasticsearch/src/lib/transport.js:235:15)\n at checkRespForFailure (/kibana-4.0.2-linux-x64/src/node_modules/elasticsearch/src/lib/transport.js:203:7)\n at HttpConnector.<anonymous> (/kibana-4.0.2-linux-x64/src/node_modules/elasticsearch/src/lib/connectors/http.js:156:7)\n at IncomingMessage.bound (/kibana-4.0.2-linux-x64/src/node_modules/elasticsearch/node_modules/lodash-node/modern/internals/baseBind.js:56:17)\n at IncomingMessage.emit (events.js:117:20)\n at _stream_readable.js:944:16\n at process._tickCallback (node.js:442:13)\n"}} What should I do? FWIW, Elasticsearch is connectable at http://elasticsearch-logging.kube-system:9200/, although it does return status 503. That could be the issue for all I know. # curl http://elasticsearch-logging.kube-system:9200/ { "status" : 503, "name" : "Puppet Master", "cluster_name" : "kubernetes-logging", "version" : { "number" : "1.5.2", "build_hash" : "62ff9868b4c8a0c45860bebb259e21980778ab1c", "build_timestamp" : "2015-04-27T09:21:06Z", "build_snapshot" : false, "lucene_version" : "4.10.4" }, "tagline" : "You Know, for Search" } fluentd-es.yaml apiVersion: v1 kind: Pod metadata: name: fluentd-elasticsearch namespace: kube-system spec: containers: - name: fluentd-elasticsearch image: gcr.io/google_containers/fluentd-elasticsearch:1.13 resources: limits: cpu: 100m args: - -q volumeMounts: - name: varlog mountPath: /var/log - name: varlibdockercontainers mountPath: /var/lib/docker/containers readOnly: true terminationGracePeriodSeconds: 30 volumes: - name: varlog hostPath: path: /var/log - name: varlibdockercontainers hostPath: path: /var/lib/docker/containers es-controller.yaml apiVersion: v1 kind: ReplicationController metadata: name: elasticsearch-logging-v1 namespace: kube-system labels: k8s-app: elasticsearch-logging version: v1 kubernetes.io/cluster-service: "true" spec: replicas: 2 selector: k8s-app: elasticsearch-logging version: v1 template: metadata: labels: k8s-app: elasticsearch-logging version: v1 kubernetes.io/cluster-service: "true" spec: containers: - image: gcr.io/google_containers/elasticsearch:1.7 name: elasticsearch-logging resources: limits: cpu: 100m ports: - containerPort: 9200 name: db protocol: TCP - containerPort: 9300 name: transport protocol: TCP volumeMounts: - name: es-persistent-storage mountPath: /data volumes: - name: es-persistent-storage emptyDir: {} es-service.yaml apiVersion: v1 kind: Service metadata: name: elasticsearch-logging namespace: kube-system labels: k8s-app: elasticsearch-logging kubernetes.io/cluster-service: "true" kubernetes.io/name: "Elasticsearch" spec: ports: - port: 9200 protocol: TCP targetPort: db selector: k8s-app: elasticsearch-logging kibana-controller.yaml apiVersion: v1 kind: ReplicationController metadata: name: kibana-logging-v1 namespace: kube-system labels: k8s-app: kibana-logging version: v1 kubernetes.io/cluster-service: "true" spec: replicas: 1 selector: k8s-app: kibana-logging version: v1 template: metadata: labels: k8s-app: kibana-logging version: v1 kubernetes.io/cluster-service: "true" spec: containers: - name: kibana-logging image: gcr.io/google_containers/kibana:1.3 resources: limits: cpu: 100m env: - name: "ELASTICSEARCH_URL" value: "http://elasticsearch-logging.kube-system:9200" ports: - containerPort: 5601 name: ui protocol: TCP kibana-service.yaml apiVersion: v1 kind: Service metadata: name: kibana-logging namespace: kube-system labels: k8s-app: kibana-logging kubernetes.io/cluster-service: "true" kubernetes.io/name: "Kibana" spec: ports: - port: 5601 protocol: TCP targetPort: ui selector: k8s-app: kibana-logging
Are you querying on the tcp port or the udp port? I changed my kube-dns to be a NodePort service: $ kubectl describe services kube-dns --namespace kube-system Name: kube-dns Namespace: kube-system Labels: k8s-app=kube-dns kubernetes.io/cluster-service=true kubernetes.io/name=KubeDNS Selector: k8s-app=kube-dns Type: NodePort IP: 10.171.240.10 Port: dns 53/UDP NodePort: dns 30100/UDP Endpoints: 10.168.0.6:53 Port: dns-tcp 53/TCP NodePort: dns-tcp 30490/TCP Endpoints: 10.168.0.6:53 Session Affinity: None and then queried on the udp port from outside of the cluster and everything appeared to work: $ dig -p 30100 @10.240.0.4 kubernetes.default.svc.cluster.local ; <<>> DiG 9.9.5-9+deb8u6-Debian <<>> -p 30100 @10.240.0.4 kubernetes.default.svc.cluster.local ; (1 server found) ;; global options: +cmd ;; Got answer: ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 45472 ;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0 ;; QUESTION SECTION: ;kubernetes.default.svc.cluster.local. IN A ;; ANSWER SECTION: kubernetes.default.svc.cluster.local. 30 IN A 10.171.240.1 ;; Query time: 3 msec ;; SERVER: 10.240.0.4#30100(10.240.0.4) ;; WHEN: Thu May 26 18:27:32 UTC 2016 ;; MSG SIZE rcvd: 70 Right now, Kubernetes does not allow NodePort services to share the same port for tcp & udp (see Issue #20092). That makes this a little funky for something like DNS. EDIT: The bug was fixed in Kubernetes 1.3.
###Instruction: I'm trying to expose the "kube-dns" service to be available to be queried outside of the Kubernetes cluster. In order to do this I edited the "Service" definition to change "type" from "ClusterIP" to "NodePort" which seemed to work fine. However, when I attempt to query on the node port, I'm able to get a TCP session (testing with Telnet) but can't seem to get any response from the DNS server (testing with dig). I've had a look through the logs on each of the containers on the "kube-dns" Pod but can't see anything untoward. Additionally, querying the DNS from within the cluster (from a running container) appears to work without any issues. Has anyone tried to expose the kube-dns service before? If so, are there any additional setup steps or do you have any debugging advice for me? The service definition is as follows: $ kubectl get service kube-dns -o yaml --namespace kube-system apiVersion: v1 kind: Service metadata: ... spec: clusterIP: 10.0.0.10 ports: - name: dns nodePort: 31257 port: 53 protocol: UDP targetPort: 53 - name: dns-tcp nodePort: 31605 port: 53 protocol: TCP targetPort: 53 selector: k8s-app: kube-dns sessionAffinity: None type: NodePort status: loadBalancer: {} ### Response: Are you querying on the tcp port or the udp port? I changed my kube-dns to be a NodePort service: $ kubectl describe services kube-dns --namespace kube-system Name: kube-dns Namespace: kube-system Labels: k8s-app=kube-dns kubernetes.io/cluster-service=true kubernetes.io/name=KubeDNS Selector: k8s-app=kube-dns Type: NodePort IP: 10.171.240.10 Port: dns 53/UDP NodePort: dns 30100/UDP Endpoints: 10.168.0.6:53 Port: dns-tcp 53/TCP NodePort: dns-tcp 30490/TCP Endpoints: 10.168.0.6:53 Session Affinity: None and then queried on the udp port from outside of the cluster and everything appeared to work: $ dig -p 30100 @10.240.0.4 kubernetes.default.svc.cluster.local ; <<>> DiG 9.9.5-9+deb8u6-Debian <<>> -p 30100 @10.240.0.4 kubernetes.default.svc.cluster.local ; (1 server found) ;; global options: +cmd ;; Got answer: ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 45472 ;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0 ;; QUESTION SECTION: ;kubernetes.default.svc.cluster.local. IN A ;; ANSWER SECTION: kubernetes.default.svc.cluster.local. 30 IN A 10.171.240.1 ;; Query time: 3 msec ;; SERVER: 10.240.0.4#30100(10.240.0.4) ;; WHEN: Thu May 26 18:27:32 UTC 2016 ;; MSG SIZE rcvd: 70 Right now, Kubernetes does not allow NodePort services to share the same port for tcp & udp (see Issue #20092). That makes this a little funky for something like DNS. EDIT: The bug was fixed in Kubernetes 1.3.
I'm trying to expose the "kube-dns" service to be available to be queried outside of the Kubernetes cluster. In order to do this I edited the "Service" definition to change "type" from "ClusterIP" to "NodePort" which seemed to work fine. However, when I attempt to query on the node port, I'm able to get a TCP session (testing with Telnet) but can't seem to get any response from the DNS server (testing with dig). I've had a look through the logs on each of the containers on the "kube-dns" Pod but can't see anything untoward. Additionally, querying the DNS from within the cluster (from a running container) appears to work without any issues. Has anyone tried to expose the kube-dns service before? If so, are there any additional setup steps or do you have any debugging advice for me? The service definition is as follows: $ kubectl get service kube-dns -o yaml --namespace kube-system apiVersion: v1 kind: Service metadata: ... spec: clusterIP: 10.0.0.10 ports: - name: dns nodePort: 31257 port: 53 protocol: UDP targetPort: 53 - name: dns-tcp nodePort: 31605 port: 53 protocol: TCP targetPort: 53 selector: k8s-app: kube-dns sessionAffinity: None type: NodePort status: loadBalancer: {}
In Swarm the rescheduling of containers is supported as a stable feature since v1.2.0, before that containers would only restart on the same host, and disappear if the host was terminated. There is no building block similar to replication controllers, but if you manage your containers using Docker Compose you can scale your services from the CLI. E.g. docker-compose scale web=3. That's as close as you can get I'm afraid.
###Instruction: In kubernetes we got this replication controller which takes care of maintaining specified number of pods running in a given cluster. What is equivalent in docker-swarm world, do we have any? There is container restart option, does it work if one machine in the cluster goes down. ### Response: In Swarm the rescheduling of containers is supported as a stable feature since v1.2.0, before that containers would only restart on the same host, and disappear if the host was terminated. There is no building block similar to replication controllers, but if you manage your containers using Docker Compose you can scale your services from the CLI. E.g. docker-compose scale web=3. That's as close as you can get I'm afraid.
In kubernetes we got this replication controller which takes care of maintaining specified number of pods running in a given cluster. What is equivalent in docker-swarm world, do we have any? There is container restart option, does it work if one machine in the cluster goes down.
You can confirm which process is hogging file descriptors by running: lsof | awk '{print $2}' | sort | uniq -c | sort -n That will give you a sorted list of open FD counts with the pid of the process. Then you can look up each process w/ ps -p <pid> If the main hogs are docker/kubernetes, then I would recommend following along on the issue that caesarxuchao referenced.
###Instruction: I am trying create a bunch of pods, services and deployment using Kubernetes, but keep hitting the following errors when I run the kubectl describe command. for "POD" with RunContainerError: "runContainer: API error (500): Cannot start container bbdb58770a848733bf7130b1b230d809fcec3062b2b16748c5e4a8b12cc0533a: [8] System error: too many open files in system\n" I have already terminated all pods and try restarting the machine, but it doesn't solve the issue. I am not an Linux expert, so I am just wondering how shall find all the open files and close them? ### Response: You can confirm which process is hogging file descriptors by running: lsof | awk '{print $2}' | sort | uniq -c | sort -n That will give you a sorted list of open FD counts with the pid of the process. Then you can look up each process w/ ps -p <pid> If the main hogs are docker/kubernetes, then I would recommend following along on the issue that caesarxuchao referenced.
I am trying create a bunch of pods, services and deployment using Kubernetes, but keep hitting the following errors when I run the kubectl describe command. for "POD" with RunContainerError: "runContainer: API error (500): Cannot start container bbdb58770a848733bf7130b1b230d809fcec3062b2b16748c5e4a8b12cc0533a: [8] System error: too many open files in system\n" I have already terminated all pods and try restarting the machine, but it doesn't solve the issue. I am not an Linux expert, so I am just wondering how shall find all the open files and close them?
The native GKE Ingress controller do not support ClusterIP, only NodePort is working. Non-native Ingress controllers such as the nginx one do work with ClusterIP services.
###Instruction: I've setup some services and ingresses to try out the SSL termination. I had no problem at all with LoadBalancer and NodePort services as backend but it's not working at all with ClusterIP service. Although the Ingress' backend is described as healthy, I get an HTTP error that do not come from my application. $ kubectl describe ing nginx-cluster-ssl-ingress Name: nginx-cluster-ssl-ingress Namespace: default Address: X.X.X.X Default backend: nginx-cluster-svc:80 (...) TLS: ssl-certificate terminates Rules: Host Path Backends ---- ---- -------- Annotations: https-target-proxy: k8s-tps-default-nginx-cluster-ssl-ingress static-ip: k8s-fw-default-nginx-cluster-ssl-ingress target-proxy: k8s-tp-default-nginx-cluster-ssl-ingress url-map: k8s-um-default-nginx-cluster-ssl-ingress backends: {"k8s-be-30825":"HEALTHY"} forwarding-rule: k8s-fw-default-nginx-cluster-ssl-ingress https-forwarding-rule: k8s-fws-default-nginx-cluster-ssl-ingress Events: FirstSeen LastSeen Count From SubobjectPath Type Reason Message --------- -------- ----- ---- ------------- -------- ------ ------- 28m 28m 1 {loadbalancer-controller } Normal ADD default/nginx-cluster-ssl-ingress 27m 27m 1 {loadbalancer-controller } Normal CREATE ip: X.X.X.X The HTTP error is the following: $ curl http://X.X.X.X/ default backend - 404% My question is quite simple: is it supposed to work with ClusterIP services? If it is supposed to as more or less written in the documentation, where should I have a look to resolve that issue? Thank you! ### Response: The native GKE Ingress controller do not support ClusterIP, only NodePort is working. Non-native Ingress controllers such as the nginx one do work with ClusterIP services.
I've setup some services and ingresses to try out the SSL termination. I had no problem at all with LoadBalancer and NodePort services as backend but it's not working at all with ClusterIP service. Although the Ingress' backend is described as healthy, I get an HTTP error that do not come from my application. $ kubectl describe ing nginx-cluster-ssl-ingress Name: nginx-cluster-ssl-ingress Namespace: default Address: X.X.X.X Default backend: nginx-cluster-svc:80 (...) TLS: ssl-certificate terminates Rules: Host Path Backends ---- ---- -------- Annotations: https-target-proxy: k8s-tps-default-nginx-cluster-ssl-ingress static-ip: k8s-fw-default-nginx-cluster-ssl-ingress target-proxy: k8s-tp-default-nginx-cluster-ssl-ingress url-map: k8s-um-default-nginx-cluster-ssl-ingress backends: {"k8s-be-30825":"HEALTHY"} forwarding-rule: k8s-fw-default-nginx-cluster-ssl-ingress https-forwarding-rule: k8s-fws-default-nginx-cluster-ssl-ingress Events: FirstSeen LastSeen Count From SubobjectPath Type Reason Message --------- -------- ----- ---- ------------- -------- ------ ------- 28m 28m 1 {loadbalancer-controller } Normal ADD default/nginx-cluster-ssl-ingress 27m 27m 1 {loadbalancer-controller } Normal CREATE ip: X.X.X.X The HTTP error is the following: $ curl http://X.X.X.X/ default backend - 404% My question is quite simple: is it supposed to work with ClusterIP services? If it is supposed to as more or less written in the documentation, where should I have a look to resolve that issue? Thank you!
By default, pods run with unbounded CPU and memory limits. This means that any pod in the system will be able to consume as much CPU and memory on the node that executes the pod. http://kubernetes.io/docs/admin/limitrange/ When you don't specify the CPU limit kubernetes will not know how much CPU resources are required and will try to create pods in one node. Here is an example of Deployment apiVersion: extensions/v1beta1 kind: Deployment metadata: name: jenkins spec: replicas: 4 template: metadata: labels: app: jenkins spec: containers: - name: jenkins image: quay.io/naveensrinivasan/jenkins:0.4 ports: - containerPort: 8080 resources: limits: cpu: "400m" # volumeMounts: # - mountPath: /var/jenkins_home # name: jenkins-volume # volumes: # - name: jenkins-volume # awsElasticBlockStore: # volumeID: vol-29c4b99f # fsType: ext4 imagePullSecrets: - name: registrypullsecret Here is the output of the kubectl describe po | grep Node after creating the deployment. ~ aws_kubernetes naveen@GuessWho  ~/revature/devops/jenkins   jenkins ● k describe po | grep Node Node: ip-172-20-0-26.us-west-2.compute.internal/172.20.0.26 Node: ip-172-20-0-29.us-west-2.compute.internal/172.20.0.29 Node: ip-172-20-0-27.us-west-2.compute.internal/172.20.0.27 Node: ip-172-20-0-29.us-west-2.compute.internal/172.20.0.29 It is now created in 4 different nodes. It is based on cpu limits on your cluster. You could increase / decrease replicas to see it being deployed in different nodes. This isn't GKE or AWS specific.
###Instruction: I have a Kubernetes cluster on GKE. I know Kubernetes will spread pods with the same labels, but this isn't happening for me. Here is my node description. Name: gke-pubnation-cluster-prod-high-cpu-14a766ad-node-dpob Conditions: Type Status LastHeartbeatTime LastTransitionTime Reason Message ---- ------ ----------------- ------------------ ------ ------- OutOfDisk False Fri, 27 May 2016 21:11:17 -0400 Thu, 26 May 2016 22:16:27 -0400 KubeletHasSufficientDisk kubelet has sufficient disk space available Ready True Fri, 27 May 2016 21:11:17 -0400 Thu, 26 May 2016 22:17:02 -0400 KubeletReady kubelet is posting ready status. WARNING: CPU hardcapping unsupported Capacity: cpu: 2 memory: 1848660Ki pods: 110 System Info: Machine ID: Kernel Version: 3.16.0-4-amd64 OS Image: Debian GNU/Linux 7 (wheezy) Container Runtime Version: docker://1.9.1 Kubelet Version: v1.2.4 Kube-Proxy Version: v1.2.4 Non-terminated Pods: (2 in total) Namespace Name CPU Requests CPU Limits Memory Requests Memory Limits --------- ---- ------------ ---------- --------------- ------------- kube-system fluentd-cloud-logging-gke-pubnation-cluster-prod-high-cpu-14a766ad-node-dpob 80m (4%) 0 (0%) 200Mi (11%) 200Mi (11%) kube-system kube-proxy-gke-pubnation-cluster-prod-high-cpu-14a766ad-node-dpob 20m (1%) 0 (0%) 0 (0%) 0 (0%) Allocated resources: (Total limits may be over 100%, i.e., overcommitted. More info: http://releases.k8s.io/HEAD/docs/user-guide/compute-resources.md) CPU Requests CPU Limits Memory Requests Memory Limits ------------ ---------- --------------- ------------- 100m (5%) 0 (0%) 200Mi (11%) 200Mi (11%) No events. Name: gke-pubnation-cluster-prod-high-cpu-14a766ad-node-qhw2 Conditions: Type Status LastHeartbeatTime LastTransitionTime Reason Message ---- ------ ----------------- ------------------ ------ ------- OutOfDisk False Fri, 27 May 2016 21:11:17 -0400 Fri, 27 May 2016 18:16:38 -0400 KubeletHasSufficientDisk kubelet has sufficient disk space available Ready True Fri, 27 May 2016 21:11:17 -0400 Fri, 27 May 2016 18:17:12 -0400 KubeletReady kubelet is posting ready status. WARNING: CPU hardcapping unsupported Capacity: pods: 110 cpu: 2 memory: 1848660Ki System Info: Machine ID: Kernel Version: 3.16.0-4-amd64 OS Image: Debian GNU/Linux 7 (wheezy) Container Runtime Version: docker://1.9.1 Kubelet Version: v1.2.4 Kube-Proxy Version: v1.2.4 Non-terminated Pods: (10 in total) Namespace Name CPU Requests CPU Limits Memory Requests Memory Limits --------- ---- ------------ ---------- --------------- ------------- default pn-minions-deployment-prod-3923308490-axucq 100m (5%) 0 (0%) 0 (0%) 0 (0%) default pn-minions-deployment-prod-3923308490-mvn54 100m (5%) 0 (0%) 0 (0%) 0 (0%) default pn-minions-deployment-staging-2522417973-8cq5p 100m (5%) 0 (0%) 0 (0%) 0 (0%) default pn-minions-deployment-staging-2522417973-9yatt 100m (5%) 0 (0%) 0 (0%) 0 (0%) kube-system fluentd-cloud-logging-gke-pubnation-cluster-prod-high-cpu-14a766ad-node-qhw2 80m (4%) 0 (0%) 200Mi (11%) 200Mi (11%) kube-system heapster-v1.0.2-1246684275-a8eab 150m (7%) 150m (7%) 308Mi (17%) 308Mi (17%) kube-system kube-dns-v11-uzl1h 310m (15%) 310m (15%) 170Mi (9%) 920Mi (50%) kube-system kube-proxy-gke-pubnation-cluster-prod-high-cpu-14a766ad-node-qhw2 20m (1%) 0 (0%) 0 (0%) 0 (0%) kube-system kubernetes-dashboard-v1.0.1-3co2b 100m (5%) 100m (5%) 50Mi (2%) 50Mi (2%) kube-system l7-lb-controller-v0.6.0-o5ojv 110m (5%) 110m (5%) 70Mi (3%) 120Mi (6%) Allocated resources: (Total limits may be over 100%, i.e., overcommitted. More info: http://releases.k8s.io/HEAD/docs/user-guide/compute-resources.md) CPU Requests CPU Limits Memory Requests Memory Limits ------------ ---------- --------------- ------------- 1170m (58%) 670m (33%) 798Mi (44%) 1598Mi (88%) No events. Here is the description for deployments: Name: pn-minions-deployment-prod Namespace: default Labels: app=pn-minions,environment=production Selector: app=pn-minions,environment=production Replicas: 2 updated | 2 total | 2 available | 0 unavailable OldReplicaSets: <none> NewReplicaSet: pn-minions-deployment-prod-3923308490 (2/2 replicas created) Name: pn-minions-deployment-staging Namespace: default Labels: app=pn-minions,environment=staging Selector: app=pn-minions,environment=staging Replicas: 2 updated | 2 total | 2 available | 0 unavailable OldReplicaSets: <none> NewReplicaSet: pn-minions-deployment-staging-2522417973 (2/2 replicas created) As you can see, all four pods are on the same node. Should I do something in additional to make this work? ### Response: By default, pods run with unbounded CPU and memory limits. This means that any pod in the system will be able to consume as much CPU and memory on the node that executes the pod. http://kubernetes.io/docs/admin/limitrange/ When you don't specify the CPU limit kubernetes will not know how much CPU resources are required and will try to create pods in one node. Here is an example of Deployment apiVersion: extensions/v1beta1 kind: Deployment metadata: name: jenkins spec: replicas: 4 template: metadata: labels: app: jenkins spec: containers: - name: jenkins image: quay.io/naveensrinivasan/jenkins:0.4 ports: - containerPort: 8080 resources: limits: cpu: "400m" # volumeMounts: # - mountPath: /var/jenkins_home # name: jenkins-volume # volumes: # - name: jenkins-volume # awsElasticBlockStore: # volumeID: vol-29c4b99f # fsType: ext4 imagePullSecrets: - name: registrypullsecret Here is the output of the kubectl describe po | grep Node after creating the deployment. ~ aws_kubernetes naveen@GuessWho  ~/revature/devops/jenkins   jenkins ● k describe po | grep Node Node: ip-172-20-0-26.us-west-2.compute.internal/172.20.0.26 Node: ip-172-20-0-29.us-west-2.compute.internal/172.20.0.29 Node: ip-172-20-0-27.us-west-2.compute.internal/172.20.0.27 Node: ip-172-20-0-29.us-west-2.compute.internal/172.20.0.29 It is now created in 4 different nodes. It is based on cpu limits on your cluster. You could increase / decrease replicas to see it being deployed in different nodes. This isn't GKE or AWS specific.
I have a Kubernetes cluster on GKE. I know Kubernetes will spread pods with the same labels, but this isn't happening for me. Here is my node description. Name: gke-pubnation-cluster-prod-high-cpu-14a766ad-node-dpob Conditions: Type Status LastHeartbeatTime LastTransitionTime Reason Message ---- ------ ----------------- ------------------ ------ ------- OutOfDisk False Fri, 27 May 2016 21:11:17 -0400 Thu, 26 May 2016 22:16:27 -0400 KubeletHasSufficientDisk kubelet has sufficient disk space available Ready True Fri, 27 May 2016 21:11:17 -0400 Thu, 26 May 2016 22:17:02 -0400 KubeletReady kubelet is posting ready status. WARNING: CPU hardcapping unsupported Capacity: cpu: 2 memory: 1848660Ki pods: 110 System Info: Machine ID: Kernel Version: 3.16.0-4-amd64 OS Image: Debian GNU/Linux 7 (wheezy) Container Runtime Version: docker://1.9.1 Kubelet Version: v1.2.4 Kube-Proxy Version: v1.2.4 Non-terminated Pods: (2 in total) Namespace Name CPU Requests CPU Limits Memory Requests Memory Limits --------- ---- ------------ ---------- --------------- ------------- kube-system fluentd-cloud-logging-gke-pubnation-cluster-prod-high-cpu-14a766ad-node-dpob 80m (4%) 0 (0%) 200Mi (11%) 200Mi (11%) kube-system kube-proxy-gke-pubnation-cluster-prod-high-cpu-14a766ad-node-dpob 20m (1%) 0 (0%) 0 (0%) 0 (0%) Allocated resources: (Total limits may be over 100%, i.e., overcommitted. More info: http://releases.k8s.io/HEAD/docs/user-guide/compute-resources.md) CPU Requests CPU Limits Memory Requests Memory Limits ------------ ---------- --------------- ------------- 100m (5%) 0 (0%) 200Mi (11%) 200Mi (11%) No events. Name: gke-pubnation-cluster-prod-high-cpu-14a766ad-node-qhw2 Conditions: Type Status LastHeartbeatTime LastTransitionTime Reason Message ---- ------ ----------------- ------------------ ------ ------- OutOfDisk False Fri, 27 May 2016 21:11:17 -0400 Fri, 27 May 2016 18:16:38 -0400 KubeletHasSufficientDisk kubelet has sufficient disk space available Ready True Fri, 27 May 2016 21:11:17 -0400 Fri, 27 May 2016 18:17:12 -0400 KubeletReady kubelet is posting ready status. WARNING: CPU hardcapping unsupported Capacity: pods: 110 cpu: 2 memory: 1848660Ki System Info: Machine ID: Kernel Version: 3.16.0-4-amd64 OS Image: Debian GNU/Linux 7 (wheezy) Container Runtime Version: docker://1.9.1 Kubelet Version: v1.2.4 Kube-Proxy Version: v1.2.4 Non-terminated Pods: (10 in total) Namespace Name CPU Requests CPU Limits Memory Requests Memory Limits --------- ---- ------------ ---------- --------------- ------------- default pn-minions-deployment-prod-3923308490-axucq 100m (5%) 0 (0%) 0 (0%) 0 (0%) default pn-minions-deployment-prod-3923308490-mvn54 100m (5%) 0 (0%) 0 (0%) 0 (0%) default pn-minions-deployment-staging-2522417973-8cq5p 100m (5%) 0 (0%) 0 (0%) 0 (0%) default pn-minions-deployment-staging-2522417973-9yatt 100m (5%) 0 (0%) 0 (0%) 0 (0%) kube-system fluentd-cloud-logging-gke-pubnation-cluster-prod-high-cpu-14a766ad-node-qhw2 80m (4%) 0 (0%) 200Mi (11%) 200Mi (11%) kube-system heapster-v1.0.2-1246684275-a8eab 150m (7%) 150m (7%) 308Mi (17%) 308Mi (17%) kube-system kube-dns-v11-uzl1h 310m (15%) 310m (15%) 170Mi (9%) 920Mi (50%) kube-system kube-proxy-gke-pubnation-cluster-prod-high-cpu-14a766ad-node-qhw2 20m (1%) 0 (0%) 0 (0%) 0 (0%) kube-system kubernetes-dashboard-v1.0.1-3co2b 100m (5%) 100m (5%) 50Mi (2%) 50Mi (2%) kube-system l7-lb-controller-v0.6.0-o5ojv 110m (5%) 110m (5%) 70Mi (3%) 120Mi (6%) Allocated resources: (Total limits may be over 100%, i.e., overcommitted. More info: http://releases.k8s.io/HEAD/docs/user-guide/compute-resources.md) CPU Requests CPU Limits Memory Requests Memory Limits ------------ ---------- --------------- ------------- 1170m (58%) 670m (33%) 798Mi (44%) 1598Mi (88%) No events. Here is the description for deployments: Name: pn-minions-deployment-prod Namespace: default Labels: app=pn-minions,environment=production Selector: app=pn-minions,environment=production Replicas: 2 updated | 2 total | 2 available | 0 unavailable OldReplicaSets: <none> NewReplicaSet: pn-minions-deployment-prod-3923308490 (2/2 replicas created) Name: pn-minions-deployment-staging Namespace: default Labels: app=pn-minions,environment=staging Selector: app=pn-minions,environment=staging Replicas: 2 updated | 2 total | 2 available | 0 unavailable OldReplicaSets: <none> NewReplicaSet: pn-minions-deployment-staging-2522417973 (2/2 replicas created) As you can see, all four pods are on the same node. Should I do something in additional to make this work?
You could setup ABAC (http://kubernetes.io/docs/admin/authorization/) and limit users to namespaces: In the policy file you would have something like this if your user was bob and you wanted to limit him to the namespace projectCaribou: { "apiVersion": "abac.authorization.kubernetes.io/v1beta1", "kind": "Policy", "spec": { "namespace": "projectCaribou", "readonly": true, "resource": "pods", "user": "bob" } }
###Instruction: I have a hard time trying to set up my (test) Kubernetes cluster so that it have a few users and a few namespaces, and a user can only see specific namespaces. Is there a way to do that? If yes, what is needed to Create a user Limit a user to a specific namespace or namespaces Use Kubernetes (via kubectl) as a specific user ### Response: You could setup ABAC (http://kubernetes.io/docs/admin/authorization/) and limit users to namespaces: In the policy file you would have something like this if your user was bob and you wanted to limit him to the namespace projectCaribou: { "apiVersion": "abac.authorization.kubernetes.io/v1beta1", "kind": "Policy", "spec": { "namespace": "projectCaribou", "readonly": true, "resource": "pods", "user": "bob" } }
I have a hard time trying to set up my (test) Kubernetes cluster so that it have a few users and a few namespaces, and a user can only see specific namespaces. Is there a way to do that? If yes, what is needed to Create a user Limit a user to a specific namespace or namespaces Use Kubernetes (via kubectl) as a specific user
Is there a way to point a Kubernetes to point to an Ingress controller or use a service type LoadBalancer with an Ingress controller to terminate SSL. You can simply deploy the on metal (nginx, haproxy, traefic...) ingress controllers as a pod/daemonset/rc in your cluster, and front it with a service of type=loadbalancer. You can find these controllers in various places like: https://github.com/kubernetes/contrib/tree/master/ingress/controllers/nginx, https://libraries.io/go/github.com%2Ftimelinelabs%2Fromulus, https://github.com/containous/traefik/blob/fa25c8ef221d89719bd0c491b66bbf54e3d40438/docs/toml.md#kubernetes-ingress-backend,
###Instruction: I've been using Kubernete's LoadBalancer type service for incoming traffic on AWS. However, it is hard to terminate SSL at a service level, thus the idea of using an Ingress. However, a LoadBalancer service allows us to make as many rolling changes as we like to our deployments without having to configure our DNS. By using Ingress, you can only use NodePort and while we would like to use Ingress, mapping DNS to new node when the pod is deployed on another node is a problem. Is there a way to point a Kubernetes to point to an Ingress controller or use a service type LoadBalancer with an Ingress controller to terminate SSL. We do not want to put our SSL certificates in a container, which is why this trouble. ### Response: Is there a way to point a Kubernetes to point to an Ingress controller or use a service type LoadBalancer with an Ingress controller to terminate SSL. You can simply deploy the on metal (nginx, haproxy, traefic...) ingress controllers as a pod/daemonset/rc in your cluster, and front it with a service of type=loadbalancer. You can find these controllers in various places like: https://github.com/kubernetes/contrib/tree/master/ingress/controllers/nginx, https://libraries.io/go/github.com%2Ftimelinelabs%2Fromulus, https://github.com/containous/traefik/blob/fa25c8ef221d89719bd0c491b66bbf54e3d40438/docs/toml.md#kubernetes-ingress-backend,
I've been using Kubernete's LoadBalancer type service for incoming traffic on AWS. However, it is hard to terminate SSL at a service level, thus the idea of using an Ingress. However, a LoadBalancer service allows us to make as many rolling changes as we like to our deployments without having to configure our DNS. By using Ingress, you can only use NodePort and while we would like to use Ingress, mapping DNS to new node when the pod is deployed on another node is a problem. Is there a way to point a Kubernetes to point to an Ingress controller or use a service type LoadBalancer with an Ingress controller to terminate SSL. We do not want to put our SSL certificates in a container, which is why this trouble.
You are correct, one EBS volume can only be mounted on a single EC2 at a given time. To solve you have the following options: Use multiple EBS volumes with multiple Replication Controllers Use a distributed file system (e.g. Gluster) and avoid EBS issue Follow along with PetSet (https://github.com/kubernetes/kubernetes/issues/260)
###Instruction: I'm trying to create a Cassandra cluster in Kubernetes. I want to use awsElasticBlockStore to make the data persistent. As a result, I've written a YAML file like following for the corresponding Replication Controller: apiVersion: v1 kind: ReplicationController metadata: name: cassandra-rc spec: # Question: How can I do this? replicas: 2 selector: name: cassandra template: metadata: labels: name: cassandra spec: containers: - resources: limits : cpu: 1.0 image: cassandra:2.2.6 name: cassandra ports: - containerPort: 7000 name: comm - containerPort: 9042 name: cql - containerPort: 9160 name: thrift volumeMounts: - name: cassandra-persistent-storage mountPath: /cassandra_data volumes: - name: cassandra-persistent-storage awsElasticBlockStore: volumeID: aws://ap-northeast-1c/vol-xxxxxxxx fsType: ext4 However, only one pod can be properly launched with this configuration. $ kubectl get pods NAME READY STATUS RESTARTS AGE cassandra-rc-xxxxx 0/1 ContainerCreating 0 5m cassandra-rc-yyyyy 1/1 Running 0 5m When I run $ kubectl describe pod cassandra-rc-xxxxx, I see an error like following: Error syncing pod, skipping: Could not attach EBS Disk "aws://ap-northeast-1c/vol-xxxxxxxx": Error attaching EBS volume: VolumeInUse: vol-xxxxxxxx is already attached to an instance It's understandable because an ELB Volume can be mounted from only one node. So only one pod can successfully mount the volume and bootup, while others just fail. Is there any good solution for this? Do I need to create multiple Replication Controllers for each pod? ### Response: You are correct, one EBS volume can only be mounted on a single EC2 at a given time. To solve you have the following options: Use multiple EBS volumes with multiple Replication Controllers Use a distributed file system (e.g. Gluster) and avoid EBS issue Follow along with PetSet (https://github.com/kubernetes/kubernetes/issues/260)
I'm trying to create a Cassandra cluster in Kubernetes. I want to use awsElasticBlockStore to make the data persistent. As a result, I've written a YAML file like following for the corresponding Replication Controller: apiVersion: v1 kind: ReplicationController metadata: name: cassandra-rc spec: # Question: How can I do this? replicas: 2 selector: name: cassandra template: metadata: labels: name: cassandra spec: containers: - resources: limits : cpu: 1.0 image: cassandra:2.2.6 name: cassandra ports: - containerPort: 7000 name: comm - containerPort: 9042 name: cql - containerPort: 9160 name: thrift volumeMounts: - name: cassandra-persistent-storage mountPath: /cassandra_data volumes: - name: cassandra-persistent-storage awsElasticBlockStore: volumeID: aws://ap-northeast-1c/vol-xxxxxxxx fsType: ext4 However, only one pod can be properly launched with this configuration. $ kubectl get pods NAME READY STATUS RESTARTS AGE cassandra-rc-xxxxx 0/1 ContainerCreating 0 5m cassandra-rc-yyyyy 1/1 Running 0 5m When I run $ kubectl describe pod cassandra-rc-xxxxx, I see an error like following: Error syncing pod, skipping: Could not attach EBS Disk "aws://ap-northeast-1c/vol-xxxxxxxx": Error attaching EBS volume: VolumeInUse: vol-xxxxxxxx is already attached to an instance It's understandable because an ELB Volume can be mounted from only one node. So only one pod can successfully mount the volume and bootup, while others just fail. Is there any good solution for this? Do I need to create multiple Replication Controllers for each pod?
After much research and trial and error I managed to solve this. First I changed the pod specification to: spec: containers: - name: nginx image: "nginx:1.10.0" ports: - containerPort: 8080 name: "external" protocol: "TCP" - name: dnsmasq image: "janeczku/go-dnsmasq:release-1.0.5" args: - --listen - "127.0.0.1:53" - --default-resolver - --append-search-domains - --hostsfile=/etc/hosts - --verbose then I also had to disable the ipv6 for the resolver in nginx: location ~ ^/(.+)$ { resolver 127.0.0.1:53 ipv6=off; set $backend "http://$1:80"; proxy_pass $backend; } Then it works as expected!
###Instruction: I'm trying to create an nginx proxy that forwards requests to /<service> to http://<service>. I first tried the following: location ~ ^/(.+)$ { set $backend "http://$1:80"; proxy_pass $backend; } But it fails saying something like (when calling /myservice): [error] 7741#0: *1 no resolver defined to resolve http://myservice Since myservice is not externally accessible I've tried to install go-dnsmasq as a sidecar in the same pod and I try to use it for DNS resolution (like I've seen in this example) and change my nginx config to look like this: location ~ ^/(.+)$ { resolver 127.0.0.1:53; set $backend "http://$1:80"; proxy_pass $backend; } But now nginx fails with: [error] 9#9: *734 myservice could not be resolved (2: Server failure), client: 127.0.0.1, server: nginx-proxy, request: "GET /myservice HTTP/1.1", host: "localhost:8080" 127.0.0.1 - xxx [30/May/2016:10:34:23 +0000] "GET /myservice HTTP/1.1" 502 173 "-" "curl/7.38.0" "-" My Kubernetes pod looks like this: spec: containers: - name: nginx image: "nginx:1.10.0" ports: - containerPort: 8080 name: "external" protocol: "TCP" - name: dnsmasq image: "janeczku/go-dnsmasq:release-1.0.5" args: - --listen - "0.0.0.0:53" Running netstat -ntlp in the dnsmasq container gives me: Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name tcp 0 0 0.0.0.0:8080 0.0.0.0:* LISTEN - tcp 0 0 :::53 :::* LISTEN 1/go-dnsmasq And running nmap --min-parallelism 100 -sT -sU localhost in the nginx container: Starting Nmap 6.47 ( http://nmap.org ) at 2016-05-30 10:33 UTC Nmap scan report for localhost (127.0.0.1) Host is up (0.00055s latency). Other addresses for localhost (not scanned): 127.0.0.1 Not shown: 1997 closed ports PORT STATE SERVICE 53/tcp open domain 8080/tcp open http-proxy 53/udp open domain So it seems that dnsmasq and nginx are indeed up and running? What could I be doing wrong? ### Response: After much research and trial and error I managed to solve this. First I changed the pod specification to: spec: containers: - name: nginx image: "nginx:1.10.0" ports: - containerPort: 8080 name: "external" protocol: "TCP" - name: dnsmasq image: "janeczku/go-dnsmasq:release-1.0.5" args: - --listen - "127.0.0.1:53" - --default-resolver - --append-search-domains - --hostsfile=/etc/hosts - --verbose then I also had to disable the ipv6 for the resolver in nginx: location ~ ^/(.+)$ { resolver 127.0.0.1:53 ipv6=off; set $backend "http://$1:80"; proxy_pass $backend; } Then it works as expected!
I'm trying to create an nginx proxy that forwards requests to /<service> to http://<service>. I first tried the following: location ~ ^/(.+)$ { set $backend "http://$1:80"; proxy_pass $backend; } But it fails saying something like (when calling /myservice): [error] 7741#0: *1 no resolver defined to resolve http://myservice Since myservice is not externally accessible I've tried to install go-dnsmasq as a sidecar in the same pod and I try to use it for DNS resolution (like I've seen in this example) and change my nginx config to look like this: location ~ ^/(.+)$ { resolver 127.0.0.1:53; set $backend "http://$1:80"; proxy_pass $backend; } But now nginx fails with: [error] 9#9: *734 myservice could not be resolved (2: Server failure), client: 127.0.0.1, server: nginx-proxy, request: "GET /myservice HTTP/1.1", host: "localhost:8080" 127.0.0.1 - xxx [30/May/2016:10:34:23 +0000] "GET /myservice HTTP/1.1" 502 173 "-" "curl/7.38.0" "-" My Kubernetes pod looks like this: spec: containers: - name: nginx image: "nginx:1.10.0" ports: - containerPort: 8080 name: "external" protocol: "TCP" - name: dnsmasq image: "janeczku/go-dnsmasq:release-1.0.5" args: - --listen - "0.0.0.0:53" Running netstat -ntlp in the dnsmasq container gives me: Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name tcp 0 0 0.0.0.0:8080 0.0.0.0:* LISTEN - tcp 0 0 :::53 :::* LISTEN 1/go-dnsmasq And running nmap --min-parallelism 100 -sT -sU localhost in the nginx container: Starting Nmap 6.47 ( http://nmap.org ) at 2016-05-30 10:33 UTC Nmap scan report for localhost (127.0.0.1) Host is up (0.00055s latency). Other addresses for localhost (not scanned): 127.0.0.1 Not shown: 1997 closed ports PORT STATE SERVICE 53/tcp open domain 8080/tcp open http-proxy 53/udp open domain So it seems that dnsmasq and nginx are indeed up and running? What could I be doing wrong?
We are using https://github.com/ElasticBox/elastickube to manage users and permissions to deploy services and pods.
###Instruction: Are there any third party tools for Kubernetes UI? Such as to view pods on the main page or to edit the config of an object? ### Response: We are using https://github.com/ElasticBox/elastickube to manage users and permissions to deploy services and pods.
Are there any third party tools for Kubernetes UI? Such as to view pods on the main page or to edit the config of an object?
Sounds like you want to setup a multi-node cluster, there are numerous ways to do that (http://kubernetes.io/docs/getting-started-guides/). If you want a local solution on your machine, the vagrant way or the docker way is pretty straight forward. If looking for a cloud, then GCE is the next easiest (https://cloud.google.com/container-engine/). Once you have your multi-node cluster setup, then when you deploy your pod, it will be scheduled to a node in the cluster. The only gotcha to be careful of given your manifest above, is you are using HostPaths for all your volume mounts. This is fine when you know what machine you are running the pod on, however, you should be abstracting yourself away from that. To better solve you'll need to look into some persistent volumes that are not host specific. BUT for now, you can get it working. =)
###Instruction: I've setup Kubernetes with the steps below. Everything looks fine - but it's running on a single node/server. Now I want to take the next step for running on multiple nodes. I wonder where should I configure my physical servers ip's so I could create the pod in more than one physical server. I run: hack/local-up-cluster.sh then (In another terminal): cluster/kubectl.sh config set-cluster local --server=http://127.0.0.1:8080 --insecure-skip-tls-verify=true cluster/kubectl.sh config set-context local --cluster=local cluster/kubectl.sh config use-context local And: cluster/kubectl.sh create -f run-aii.yaml my run-aii.yaml: apiVersion: extensions/v1beta1 kind: Deployment metadata: name: aii spec: replicas: 1 template: metadata: labels: run: aii spec: containers: - name: aii image: localhost:5000/dev/aii ports: - containerPort: 5144 env: - name: KAFKA_IP value: kafka volumeMounts: - mountPath: /root/script name: scripts-data readOnly: true - mountPath: /home/aii/core name: core-aii readOnly: false - mountPath: /home/aii/genome name: genome-aii readOnly: true - mountPath: /home/aii/main name: main-aii readOnly: false - name: kafka image: localhost:5000/dev/kafkazoo volumeMounts: - mountPath: /root/script name: scripts-data readOnly: true - mountPath: /root/config name: config-data readOnly: true volumes: - name: scripts-data hostPath: path: /home/aii/general/infra/script - name: config-data hostPath: path: /home/aii/general/infra/config - name: core-aii hostPath: path: /home/aii/general/core - name: genome-aii hostPath: path: /home/aii/general/genome - name: main-aii hostPath: path: /home/aii/general/main - mountPath: /home/aii/main name: main-aii readOnly: false - name: kafka image: localhost:5000/dev/kafkazoo volumeMounts: - mountPath: /root/script name: scripts-data readOnly: true - mountPath: /root/config name: config-data readOnly: true volumes: - name: scripts-data hostPath: path: /home/aii/general/infra/script - name: config-data hostPath: path: /home/aii/general/infra/config - name: core-aii hostPath: path: /home/aii/general/core - name: genome-aii hostPath: path: /home/aii/general/genome - name: main-aii hostPath: path: /home/aii/general/main Additional info: [aii@localhost kubernetes]$ cluster/kubectl.sh get pod NAME READY STATUS RESTARTS AGE aii-3934754246-yilg3 2/2 Running 0 59s [aii@localhost kubernetes]$ cluster/kubectl.sh describe pod aii-3934754246-yilg3 Name: aii-3934754246-yilg3 Namespace: default Node: 127.0.0.1/127.0.0.1 Start Time: Sun, 29 May 2016 16:58:20 +0300 Labels: pod-template-hash=3934754246,run=aii Status: Running IP: 172.17.0.4 Controllers: ReplicaSet/aii-3934754246 Containers: aii: Container ID: docker://71609cfd8e33c01a81a36770d12d884443a12b4c2969b95e3042d9dee4fb455b Image: localhost:5000/dev/aii Image ID: docker://sha256:7e70fbb724962b2f23c9439a1c00356deb551fd96ffd27a8afa6340fc903e735 Port: 5144/TCP QoS Tier: memory: BestEffort cpu: BestEffort State: Running Started: Sun, 29 May 2016 16:58:23 +0300 Ready: True Restart Count: 0 Environment Variables: KAFKA_IP: kafka kafka: Container ID: docker://6eb891e5968cf1106b26a9f3f7db881683a8e15dd59b1858435715580c90656c Image: localhost:5000/dev/kafkazoo Image ID: docker://sha256:b78e60582cbc8d3c4946807baf59552d110c7802c8204157e6fba509b96bc11c Port: QoS Tier: cpu: BestEffort memory: BestEffort State: Running Started: Sun, 29 May 2016 16:58:24 +0300 Ready: True Restart Count: 0 Environment Variables: Conditions: Type Status Ready True Volumes: scripts-data: Type: HostPath (bare host directory volume) Path: /home/aii/general/infra/script config-data: Type: HostPath (bare host directory volume) Path: /home/aii/general/infra/config core-aii: Type: HostPath (bare host directory volume) Path: /home/aii/general/core genome-aii: Type: HostPath (bare host directory volume) Path: /home/aii/general/genome main-aii: Type: HostPath (bare host directory volume) Path: /home/aii/general/main default-token-5z9rd: Type: Secret (a volume populated by a Secret) SecretName: default-token-5z9rd Events: FirstSeen LastSeen Count From SubobjectPath Type Reason Message --------- -------- ----- ---- ------------- -------- ------ ------- 1m 1m 1 {default-scheduler } Normal Scheduled Successfully assigned aii-3934754246-yilg3 to 127.0.0.1 1m 1m 1 {kubelet 127.0.0.1} spec.containers{aii} Normal Pulling pulling image "localhost:5000/dev/aii" 1m 1m 1 {kubelet 127.0.0.1} spec.containers{aii} Normal Pulled Successfully pulled image "localhost:5000/dev/aii" 1m 1m 1 {kubelet 127.0.0.1} spec.containers{aii} Normal Created Created container with docker id 71609cfd8e33 1m 1m 1 {kubelet 127.0.0.1} spec.containers{aii} Normal Started Started container with docker id 71609cfd8e33 1m 1m 1 {kubelet 127.0.0.1} spec.containers{kafka} Normal Pulling pulling image "localhost:5000/dev/kafkazoo" 1m 1m 1 {kubelet 127.0.0.1} spec.containers{kafka} Normal Pulled Successfully pulled image "localhost:5000/dev/kafkazoo" 1m 1m 1 {kubelet 127.0.0.1} spec.containers{kafka} Normal Created Created container with docker id 6eb891e5968c 1m 1m 1 {kubelet 127.0.0.1} spec.containers{kafka} Normal Started Started container with docker id 6eb891e5968c ### Response: Sounds like you want to setup a multi-node cluster, there are numerous ways to do that (http://kubernetes.io/docs/getting-started-guides/). If you want a local solution on your machine, the vagrant way or the docker way is pretty straight forward. If looking for a cloud, then GCE is the next easiest (https://cloud.google.com/container-engine/). Once you have your multi-node cluster setup, then when you deploy your pod, it will be scheduled to a node in the cluster. The only gotcha to be careful of given your manifest above, is you are using HostPaths for all your volume mounts. This is fine when you know what machine you are running the pod on, however, you should be abstracting yourself away from that. To better solve you'll need to look into some persistent volumes that are not host specific. BUT for now, you can get it working. =)
I've setup Kubernetes with the steps below. Everything looks fine - but it's running on a single node/server. Now I want to take the next step for running on multiple nodes. I wonder where should I configure my physical servers ip's so I could create the pod in more than one physical server. I run: hack/local-up-cluster.sh then (In another terminal): cluster/kubectl.sh config set-cluster local --server=http://127.0.0.1:8080 --insecure-skip-tls-verify=true cluster/kubectl.sh config set-context local --cluster=local cluster/kubectl.sh config use-context local And: cluster/kubectl.sh create -f run-aii.yaml my run-aii.yaml: apiVersion: extensions/v1beta1 kind: Deployment metadata: name: aii spec: replicas: 1 template: metadata: labels: run: aii spec: containers: - name: aii image: localhost:5000/dev/aii ports: - containerPort: 5144 env: - name: KAFKA_IP value: kafka volumeMounts: - mountPath: /root/script name: scripts-data readOnly: true - mountPath: /home/aii/core name: core-aii readOnly: false - mountPath: /home/aii/genome name: genome-aii readOnly: true - mountPath: /home/aii/main name: main-aii readOnly: false - name: kafka image: localhost:5000/dev/kafkazoo volumeMounts: - mountPath: /root/script name: scripts-data readOnly: true - mountPath: /root/config name: config-data readOnly: true volumes: - name: scripts-data hostPath: path: /home/aii/general/infra/script - name: config-data hostPath: path: /home/aii/general/infra/config - name: core-aii hostPath: path: /home/aii/general/core - name: genome-aii hostPath: path: /home/aii/general/genome - name: main-aii hostPath: path: /home/aii/general/main - mountPath: /home/aii/main name: main-aii readOnly: false - name: kafka image: localhost:5000/dev/kafkazoo volumeMounts: - mountPath: /root/script name: scripts-data readOnly: true - mountPath: /root/config name: config-data readOnly: true volumes: - name: scripts-data hostPath: path: /home/aii/general/infra/script - name: config-data hostPath: path: /home/aii/general/infra/config - name: core-aii hostPath: path: /home/aii/general/core - name: genome-aii hostPath: path: /home/aii/general/genome - name: main-aii hostPath: path: /home/aii/general/main Additional info: [aii@localhost kubernetes]$ cluster/kubectl.sh get pod NAME READY STATUS RESTARTS AGE aii-3934754246-yilg3 2/2 Running 0 59s [aii@localhost kubernetes]$ cluster/kubectl.sh describe pod aii-3934754246-yilg3 Name: aii-3934754246-yilg3 Namespace: default Node: 127.0.0.1/127.0.0.1 Start Time: Sun, 29 May 2016 16:58:20 +0300 Labels: pod-template-hash=3934754246,run=aii Status: Running IP: 172.17.0.4 Controllers: ReplicaSet/aii-3934754246 Containers: aii: Container ID: docker://71609cfd8e33c01a81a36770d12d884443a12b4c2969b95e3042d9dee4fb455b Image: localhost:5000/dev/aii Image ID: docker://sha256:7e70fbb724962b2f23c9439a1c00356deb551fd96ffd27a8afa6340fc903e735 Port: 5144/TCP QoS Tier: memory: BestEffort cpu: BestEffort State: Running Started: Sun, 29 May 2016 16:58:23 +0300 Ready: True Restart Count: 0 Environment Variables: KAFKA_IP: kafka kafka: Container ID: docker://6eb891e5968cf1106b26a9f3f7db881683a8e15dd59b1858435715580c90656c Image: localhost:5000/dev/kafkazoo Image ID: docker://sha256:b78e60582cbc8d3c4946807baf59552d110c7802c8204157e6fba509b96bc11c Port: QoS Tier: cpu: BestEffort memory: BestEffort State: Running Started: Sun, 29 May 2016 16:58:24 +0300 Ready: True Restart Count: 0 Environment Variables: Conditions: Type Status Ready True Volumes: scripts-data: Type: HostPath (bare host directory volume) Path: /home/aii/general/infra/script config-data: Type: HostPath (bare host directory volume) Path: /home/aii/general/infra/config core-aii: Type: HostPath (bare host directory volume) Path: /home/aii/general/core genome-aii: Type: HostPath (bare host directory volume) Path: /home/aii/general/genome main-aii: Type: HostPath (bare host directory volume) Path: /home/aii/general/main default-token-5z9rd: Type: Secret (a volume populated by a Secret) SecretName: default-token-5z9rd Events: FirstSeen LastSeen Count From SubobjectPath Type Reason Message --------- -------- ----- ---- ------------- -------- ------ ------- 1m 1m 1 {default-scheduler } Normal Scheduled Successfully assigned aii-3934754246-yilg3 to 127.0.0.1 1m 1m 1 {kubelet 127.0.0.1} spec.containers{aii} Normal Pulling pulling image "localhost:5000/dev/aii" 1m 1m 1 {kubelet 127.0.0.1} spec.containers{aii} Normal Pulled Successfully pulled image "localhost:5000/dev/aii" 1m 1m 1 {kubelet 127.0.0.1} spec.containers{aii} Normal Created Created container with docker id 71609cfd8e33 1m 1m 1 {kubelet 127.0.0.1} spec.containers{aii} Normal Started Started container with docker id 71609cfd8e33 1m 1m 1 {kubelet 127.0.0.1} spec.containers{kafka} Normal Pulling pulling image "localhost:5000/dev/kafkazoo" 1m 1m 1 {kubelet 127.0.0.1} spec.containers{kafka} Normal Pulled Successfully pulled image "localhost:5000/dev/kafkazoo" 1m 1m 1 {kubelet 127.0.0.1} spec.containers{kafka} Normal Created Created container with docker id 6eb891e5968c 1m 1m 1 {kubelet 127.0.0.1} spec.containers{kafka} Normal Started Started container with docker id 6eb891e5968c
There is the dashboard (https://github.com/kubernetes/dashboard) or the now deprecated kube-ui (https://github.com/kubernetes/kube-ui). Also I've played with Weave Scope which has a pretty cool integration with k8s: https://www.weave.works/products/weave-scope/
###Instruction: Are there any third party tools for Kubernetes UI? Such as to view pods on the main page or to edit the config of an object? ### Response: There is the dashboard (https://github.com/kubernetes/dashboard) or the now deprecated kube-ui (https://github.com/kubernetes/kube-ui). Also I've played with Weave Scope which has a pretty cool integration with k8s: https://www.weave.works/products/weave-scope/
Are there any third party tools for Kubernetes UI? Such as to view pods on the main page or to edit the config of an object?
The fabric8 console provides a console to manage resources as well as full continuous delivery pipelines built on top of Kubernetes. Some great articles & blog posts about it here.
###Instruction: Are there any third party tools for Kubernetes UI? Such as to view pods on the main page or to edit the config of an object? ### Response: The fabric8 console provides a console to manage resources as well as full continuous delivery pipelines built on top of Kubernetes. Some great articles & blog posts about it here.
Are there any third party tools for Kubernetes UI? Such as to view pods on the main page or to edit the config of an object?
Bearer token authentication in the URL is not supported in Kubernetes currently, only as an Authorization header.
###Instruction: I want to use websocket to access Kubernetes API, and so it is more convenient to send token like wss://example.com" + url + "&access_token=blahblahblah. The official API doc sends token in header. Where can I find such a token and send it with url? What I want to do is to exec pods via a web page through websocket: Container-Terminal via Websocket Support exec and pod logging over WebSockets ### Response: Bearer token authentication in the URL is not supported in Kubernetes currently, only as an Authorization header.
I want to use websocket to access Kubernetes API, and so it is more convenient to send token like wss://example.com" + url + "&access_token=blahblahblah. The official API doc sends token in header. Where can I find such a token and send it with url? What I want to do is to exec pods via a web page through websocket: Container-Terminal via Websocket Support exec and pod logging over WebSockets
I think you are mentioning these fields. https://github.com/kubernetes/kubernetes/blob/master/pkg/apis/core/types.go#L2081-L2088 You can define stdin and tty in yaml file. apiVersion: v1 kind: Pod metadata: name: test spec: containers: - name: test image: test stdin: true tty: true
###Instruction: I've been using "kubectl run" with assorted flags to run Jobs interactively, but have recently outgrown what I can do with those flags, and have graduated to using YAML config files to describe my jobs. However, I can't find an equivalent to the "-i" and "--tty" flags, to attach to the Job I'm creating. Is there an equivalent YAML spec for: kubectl run myjob \ -i \ --tty \ --image=grc.io/myproj/myimg:mytag \ --restart=Never \ --rm \ -- \ my_command Or is this maybe not the right approach? ### Response: I think you are mentioning these fields. https://github.com/kubernetes/kubernetes/blob/master/pkg/apis/core/types.go#L2081-L2088 You can define stdin and tty in yaml file. apiVersion: v1 kind: Pod metadata: name: test spec: containers: - name: test image: test stdin: true tty: true
I've been using "kubectl run" with assorted flags to run Jobs interactively, but have recently outgrown what I can do with those flags, and have graduated to using YAML config files to describe my jobs. However, I can't find an equivalent to the "-i" and "--tty" flags, to attach to the Job I'm creating. Is there an equivalent YAML spec for: kubectl run myjob \ -i \ --tty \ --image=grc.io/myproj/myimg:mytag \ --restart=Never \ --rm \ -- \ my_command Or is this maybe not the right approach?
Most probably heapster is running in a wrong namespace ("default"). HPA expects heapster to be in "kube-system" namespace. Please, add --namespace=kube-system to kubectl run heapster command.
###Instruction: I have a replication controller running with the following spec: apiVersion: v1 kind: ReplicationController metadata: name: owncloud-controller spec: replicas: 1 selector: app: owncloud template: metadata: labels: app: owncloud spec: containers: - name: owncloud image: adimania/owncloud9-centos7 ports: - containerPort: 80 volumeMounts: - name: userdata mountPath: /var/www/html/owncloud/data resources: requests: cpu: 400m volumes: - name: userdata hostPath: path: /opt/data Now I run a hpa using autoscale command. $ kubectl autoscale rc owncloud-controller --max=5 --cpu-percent=10 I have also started heapster using kubernetes run command. $ kubectl run heapster --image=gcr.io/google_containers/heapster:v1.0.2 --command -- /heapster --source=kubernetes:http://192.168.0.103:8080?inClusterConfig=false --sink=log After all this, the autoscaling never kicks in. From logs, it seems that the actual CPU utilization is not getting reported. $ kubectl describe hpa owncloud-controller Name: owncloud-controller Namespace: default Labels: <none> Annotations: <none> CreationTimestamp: Thu, 26 May 2016 14:24:51 +0530 Reference: ReplicationController/owncloud-controller/scale Target CPU utilization: 10% Current CPU utilization: <unset> Min replicas: 1 Max replicas: 5 ReplicationController pods: 1 current / 1 desired Events: FirstSeen LastSeen Count From SubobjectPath Type Reason Message --------- -------- ----- ---- ------------- -------- ------ ------- 44m 8s 92 {horizontal-pod-autoscaler } Warning FailedGetMetrics failed to get CPU consumption and request: metrics obtained for 0/1 of pods 44m 8s 92 {horizontal-pod-autoscaler } Warning FailedComputeReplicas failed to get CPU utilization: failed to get CPU consumption and request: metrics obtained for 0/1 of pods What am I missing here? ### Response: Most probably heapster is running in a wrong namespace ("default"). HPA expects heapster to be in "kube-system" namespace. Please, add --namespace=kube-system to kubectl run heapster command.
I have a replication controller running with the following spec: apiVersion: v1 kind: ReplicationController metadata: name: owncloud-controller spec: replicas: 1 selector: app: owncloud template: metadata: labels: app: owncloud spec: containers: - name: owncloud image: adimania/owncloud9-centos7 ports: - containerPort: 80 volumeMounts: - name: userdata mountPath: /var/www/html/owncloud/data resources: requests: cpu: 400m volumes: - name: userdata hostPath: path: /opt/data Now I run a hpa using autoscale command. $ kubectl autoscale rc owncloud-controller --max=5 --cpu-percent=10 I have also started heapster using kubernetes run command. $ kubectl run heapster --image=gcr.io/google_containers/heapster:v1.0.2 --command -- /heapster --source=kubernetes:http://192.168.0.103:8080?inClusterConfig=false --sink=log After all this, the autoscaling never kicks in. From logs, it seems that the actual CPU utilization is not getting reported. $ kubectl describe hpa owncloud-controller Name: owncloud-controller Namespace: default Labels: <none> Annotations: <none> CreationTimestamp: Thu, 26 May 2016 14:24:51 +0530 Reference: ReplicationController/owncloud-controller/scale Target CPU utilization: 10% Current CPU utilization: <unset> Min replicas: 1 Max replicas: 5 ReplicationController pods: 1 current / 1 desired Events: FirstSeen LastSeen Count From SubobjectPath Type Reason Message --------- -------- ----- ---- ------------- -------- ------ ------- 44m 8s 92 {horizontal-pod-autoscaler } Warning FailedGetMetrics failed to get CPU consumption and request: metrics obtained for 0/1 of pods 44m 8s 92 {horizontal-pod-autoscaler } Warning FailedComputeReplicas failed to get CPU utilization: failed to get CPU consumption and request: metrics obtained for 0/1 of pods What am I missing here?
I'm running a kubernetes cluster on GKE and I would like to discover and access the etcd API from a service pod. The reason I want to do this is to add keys to the SkyDNS hierarchy. It sounds like you want direct access to the etcd instance that is backing the DNS service (not the etcd instance that is backing the Kubernetes apiserver, which is separate). Is there a way to discover (or create/expose) and interact with the etcd service API endpoint on a GKE cluster from application pods? The etcd instance for the DNS service is an internal implementation detail for the DNS service and isn't designed to be directly accessed. In fact, it's really just a convenient communication mechanism between the kube2sky binary and the skydns binary so that skydns wouldn't need to understand that it was running in a Kubernetes cluster. I wouldn't recommend attempting to access it directly. In addition, this etcd instance won't even exist in Kubernetes 1.3 installs, since skydns is being replaced by a new DNS binary kubedns. We have IoT gateway nodes that connect to our cloud services via an SSL VPN to ease management and comms. When a device connects to the VPN I want to update an entry in SkyDNS with the hostname and VPN IP address of the device. If you create a new service, that will cause the cluster DNS to have a new entry created mapping the service name to the endpoints that back the service. What if you programmatically add a service each time a new IoT device registers rather than trying to configure DNS directly?
###Instruction: I'm running a kubernetes cluster on GKE and I would like to discover and access the etcd API from a service pod. The reason I want to do this is to add keys to the SkyDNS hierarchy. Is there a way to discover (or create/expose) and interact with the etcd service API endpoint on a GKE cluster from application pods? We have IoT gateway nodes that connect to our cloud services via an SSL VPN to ease management and comms. When a device connects to the VPN I want to update an entry in SkyDNS with the hostname and VPN IP address of the device. It doesn't make sense to spin another clustered DNS setup since SkyDNS will work great for this and all of the pods in the cluster are already automatically configured to query it first. ### Response: I'm running a kubernetes cluster on GKE and I would like to discover and access the etcd API from a service pod. The reason I want to do this is to add keys to the SkyDNS hierarchy. It sounds like you want direct access to the etcd instance that is backing the DNS service (not the etcd instance that is backing the Kubernetes apiserver, which is separate). Is there a way to discover (or create/expose) and interact with the etcd service API endpoint on a GKE cluster from application pods? The etcd instance for the DNS service is an internal implementation detail for the DNS service and isn't designed to be directly accessed. In fact, it's really just a convenient communication mechanism between the kube2sky binary and the skydns binary so that skydns wouldn't need to understand that it was running in a Kubernetes cluster. I wouldn't recommend attempting to access it directly. In addition, this etcd instance won't even exist in Kubernetes 1.3 installs, since skydns is being replaced by a new DNS binary kubedns. We have IoT gateway nodes that connect to our cloud services via an SSL VPN to ease management and comms. When a device connects to the VPN I want to update an entry in SkyDNS with the hostname and VPN IP address of the device. If you create a new service, that will cause the cluster DNS to have a new entry created mapping the service name to the endpoints that back the service. What if you programmatically add a service each time a new IoT device registers rather than trying to configure DNS directly?
I'm running a kubernetes cluster on GKE and I would like to discover and access the etcd API from a service pod. The reason I want to do this is to add keys to the SkyDNS hierarchy. Is there a way to discover (or create/expose) and interact with the etcd service API endpoint on a GKE cluster from application pods? We have IoT gateway nodes that connect to our cloud services via an SSL VPN to ease management and comms. When a device connects to the VPN I want to update an entry in SkyDNS with the hostname and VPN IP address of the device. It doesn't make sense to spin another clustered DNS setup since SkyDNS will work great for this and all of the pods in the cluster are already automatically configured to query it first.
GCE's admin panel doesn't have a "download" button for persistent disks, but gcloud makes it easy to copy files from an instance to your local machine: gcloud compute copy-files example-instance:~/REMOTE-DIR ~/LOCAL-DIR --zone us-central1-a This will copy ~/REMOTE-DIR from a remote instance into ~/LOCAL-DIR on your machine. Just replace the directory names, example-instance with your instances name, and adjust your zone if necessary. More info here in the docs.
###Instruction: I have linked a Persistent Volume to my Kubernetes Neo4j Replication Controller to store the DB data. Now I would like to download that data locally to run the production DB on my system. I can't find the way to download the Disk content. Can someone point me in the right direction? Updates (Persistent Volume Creation with Kubernetes): persistent-volume-db.json { "kind": "PersistentVolume", "apiVersion": "v1", "metadata": { "name": "pv-db" }, "spec": { "capacity": { "storage": "500Gi" }, "accessModes": [ "ReadWriteMany" ], "gcePersistentDisk": { "pdName": "tuwa-db-data-disk", "fsType": "ext4" } } } persistent-volume-claim-db.json { "kind": "PersistentVolumeClaim", "apiVersion": "v1", "metadata": { "name": "pvc" }, "spec": { "accessModes": [ "ReadWriteMany" ], "resources": { "requests": { "storage": "500Gi" } } } } And then the usage: neo4j-controller.json { "kind": "ReplicationController", "apiVersion": "v1", "metadata": { "name": "neo4j-controller", "labels": { "name": "neo4j" } }, "spec": { "replicas": 1, "template": { "metadata": { "labels": { "name": "neo4j" } }, "spec": { "containers": [ { "name": "neo4j", "image": "neo4j/neo4j", "ports": [ { "name": "neo4j-server", "containerPort": 7474 } ], "volumeMounts": [ { "mountPath": "/data/databases", "name": "pv-db" } ] } ], "volumes": [ { "name": "pv-db", "persistentVolumeClaim": { "claimName": "pvc-db" } } ] } } } } ### Response: GCE's admin panel doesn't have a "download" button for persistent disks, but gcloud makes it easy to copy files from an instance to your local machine: gcloud compute copy-files example-instance:~/REMOTE-DIR ~/LOCAL-DIR --zone us-central1-a This will copy ~/REMOTE-DIR from a remote instance into ~/LOCAL-DIR on your machine. Just replace the directory names, example-instance with your instances name, and adjust your zone if necessary. More info here in the docs.
I have linked a Persistent Volume to my Kubernetes Neo4j Replication Controller to store the DB data. Now I would like to download that data locally to run the production DB on my system. I can't find the way to download the Disk content. Can someone point me in the right direction? Updates (Persistent Volume Creation with Kubernetes): persistent-volume-db.json { "kind": "PersistentVolume", "apiVersion": "v1", "metadata": { "name": "pv-db" }, "spec": { "capacity": { "storage": "500Gi" }, "accessModes": [ "ReadWriteMany" ], "gcePersistentDisk": { "pdName": "tuwa-db-data-disk", "fsType": "ext4" } } } persistent-volume-claim-db.json { "kind": "PersistentVolumeClaim", "apiVersion": "v1", "metadata": { "name": "pvc" }, "spec": { "accessModes": [ "ReadWriteMany" ], "resources": { "requests": { "storage": "500Gi" } } } } And then the usage: neo4j-controller.json { "kind": "ReplicationController", "apiVersion": "v1", "metadata": { "name": "neo4j-controller", "labels": { "name": "neo4j" } }, "spec": { "replicas": 1, "template": { "metadata": { "labels": { "name": "neo4j" } }, "spec": { "containers": [ { "name": "neo4j", "image": "neo4j/neo4j", "ports": [ { "name": "neo4j-server", "containerPort": 7474 } ], "volumeMounts": [ { "mountPath": "/data/databases", "name": "pv-db" } ] } ], "volumes": [ { "name": "pv-db", "persistentVolumeClaim": { "claimName": "pvc-db" } } ] } } } }
The customization that is built into the install script is in the environment variables that you can set to change behavior (see cluster/gce/config-default.sh). If overriding one of these variables doesn't work (which I believe is the case for ABAC), then your only option is to manually modify the salt files. If you are comfortable building Kubernetes from source, your easiest path would be to clone the github repository at the desired release version, modify the salt files locally, and then run make quick-release and then ./cluster/kube-up.sh. This will build a release (from source), bundle in your locally modified salt files, generate a checksum, upload the salt files to Google Cloud Storage, and then launch a cluster with the correct salt files & checksum in your cluster. If you don't want to build from source, rather than adjusting the kube-env metadata entry on all instances, you can fix it in the instance template and then delete each instance. They will get automatically replaced by new instances which will inherit the changes you made to the instance template. Your current mechanism won't really mess with upgrades, because upgrades create a new instance template at the new version. Any changes that you've made to the old instance template (or old nodes directly) won't be carried forward to the new nodes (for better or worse).
###Instruction: I've used curl -sS https://get.k8s.io | bash to create a cluster on Google Compute Engine using Kubernetes 1.2.4. This worked great. I wanted to enable ABAC authorization mode by adding a few flags to the kube-apiserver command specified in kube-apiserver pod spec. I'm unclear if I should adjust the salt files once they're tar/gzipped. The salt file that the pod spec is generated from is here, but editing this after the cluster is stood up has a few additional requirements: I have to unpack the salt tarball that the install script uploaded to Google Cloud Storage for me Edit the salt files Tar/gzip them back up, generate a new checksum file Push these to GCS Update all of the instances' kube-metadata so that SALT_TAR_HASH is now correct It feels like I'm going down the wrong path with this, as this also will collide with upgrades. Is there a better way to configure pods, services, etc that are baked into the install script without having to do all of this? ### Response: The customization that is built into the install script is in the environment variables that you can set to change behavior (see cluster/gce/config-default.sh). If overriding one of these variables doesn't work (which I believe is the case for ABAC), then your only option is to manually modify the salt files. If you are comfortable building Kubernetes from source, your easiest path would be to clone the github repository at the desired release version, modify the salt files locally, and then run make quick-release and then ./cluster/kube-up.sh. This will build a release (from source), bundle in your locally modified salt files, generate a checksum, upload the salt files to Google Cloud Storage, and then launch a cluster with the correct salt files & checksum in your cluster. If you don't want to build from source, rather than adjusting the kube-env metadata entry on all instances, you can fix it in the instance template and then delete each instance. They will get automatically replaced by new instances which will inherit the changes you made to the instance template. Your current mechanism won't really mess with upgrades, because upgrades create a new instance template at the new version. Any changes that you've made to the old instance template (or old nodes directly) won't be carried forward to the new nodes (for better or worse).
I've used curl -sS https://get.k8s.io | bash to create a cluster on Google Compute Engine using Kubernetes 1.2.4. This worked great. I wanted to enable ABAC authorization mode by adding a few flags to the kube-apiserver command specified in kube-apiserver pod spec. I'm unclear if I should adjust the salt files once they're tar/gzipped. The salt file that the pod spec is generated from is here, but editing this after the cluster is stood up has a few additional requirements: I have to unpack the salt tarball that the install script uploaded to Google Cloud Storage for me Edit the salt files Tar/gzip them back up, generate a new checksum file Push these to GCS Update all of the instances' kube-metadata so that SALT_TAR_HASH is now correct It feels like I'm going down the wrong path with this, as this also will collide with upgrades. Is there a better way to configure pods, services, etc that are baked into the install script without having to do all of this?
The "data-cassandra-keys" pod gets recreated by the Kubernetes Job controller, but should probably have its restart policy changed to avoid creating too many dead pods. It retries for some time because Cassandra can take a while to startup, and therefore shouldn't fail after the first attempt to create the keyspaces. A known issue is that Cassandra fails to start correctly when configured to use persistent disks due to a permissions issue. Have you checked the logs for the Cassandra pod? data-cassandra-v000-xxxx
###Instruction: I want to deploy spinnaker into our company kubernetes cluster. I've cloned the master branch of spinnaker and modified the spinnaker-local files accordingly. We use an internal docker registry so I copied the required images from dockerhub into our own one. When I start the "startup-all.sh" script it seems the redis images fire up. Then it tries to start the cassandra databases. Creating the Job "data-cassandra-keys" does not finish. It creates new pods over and over again. I tried to get some logs using: c:\spinnaker\experimental\kubernetes>kubectl log data-cassandra-keys-w4yil W0601 16:20:02.457396 10336 cmd.go:207] log is DEPRECATED and will be removed in a future version. Use logs instead. Connecting to... 172.23.77.106 9042 Connection error: ('Unable to connect to any servers', {'172.23.77.106': error(None, "Tried connecting to [('172.23.77.106', 9042)]. Last error: timed out")}) Failed to add keyspace create_echo_keyspace.cql There are dozens of data-cassandra-keys-xxxxx - all show the same and kubernetes keeps creating new ones. The startup scripts are stuck at: SUCCESS=$(kubectl get job data-cassandra-keys --namespace=spinnaker -o=jsonpath="{.status.succeeded}") while [ $SUCCESS -ne "1" ]; do SUCCESS=$(kubectl get job data-cassandra-keys --namespace=spinnaker -o=jsonpath="{.status.succeeded}") done I can't figure out what setting I have to change to make this work (how cassandra knows what host to connect). I also don't really understand why the "data-cassandra-keys" job is recreated over and over again. The events are full of: 6m 6m 1 data-cassandra-keys-sxp3o Pod Normal Scheduled {default-scheduler } Successfully assigned data-cassandra-keys-sxp3o to ld9c0193.corp.test 6m 6m 1 data-cassandra-keys-sxp3o Pod spec.containers{cassandra-keys} Normal Pulled {kubelet ld9c0193.corp.test} Container image "docker-registry.corp.ch/kubernetes-spinnaker/cassandra-keys:v2" already present on machine 6m 6m 1 data-cassandra-keys-sxp3o Pod spec.containers{cassandra-keys} Normal Created {kubelet ld9c0193.corp.test} Created container with docker id 46de7bd5f425 6m 6m 1 data-cassandra-keys-sxp3o Pod spec.containers{cassandra-keys} Normal Started {kubelet ld9c0193.corp.test} Started container with docker id 46de7bd5f425 Any hint on whats going on or where to look at is appreciated :) Thanks! ### Response: The "data-cassandra-keys" pod gets recreated by the Kubernetes Job controller, but should probably have its restart policy changed to avoid creating too many dead pods. It retries for some time because Cassandra can take a while to startup, and therefore shouldn't fail after the first attempt to create the keyspaces. A known issue is that Cassandra fails to start correctly when configured to use persistent disks due to a permissions issue. Have you checked the logs for the Cassandra pod? data-cassandra-v000-xxxx
I want to deploy spinnaker into our company kubernetes cluster. I've cloned the master branch of spinnaker and modified the spinnaker-local files accordingly. We use an internal docker registry so I copied the required images from dockerhub into our own one. When I start the "startup-all.sh" script it seems the redis images fire up. Then it tries to start the cassandra databases. Creating the Job "data-cassandra-keys" does not finish. It creates new pods over and over again. I tried to get some logs using: c:\spinnaker\experimental\kubernetes>kubectl log data-cassandra-keys-w4yil W0601 16:20:02.457396 10336 cmd.go:207] log is DEPRECATED and will be removed in a future version. Use logs instead. Connecting to... 172.23.77.106 9042 Connection error: ('Unable to connect to any servers', {'172.23.77.106': error(None, "Tried connecting to [('172.23.77.106', 9042)]. Last error: timed out")}) Failed to add keyspace create_echo_keyspace.cql There are dozens of data-cassandra-keys-xxxxx - all show the same and kubernetes keeps creating new ones. The startup scripts are stuck at: SUCCESS=$(kubectl get job data-cassandra-keys --namespace=spinnaker -o=jsonpath="{.status.succeeded}") while [ $SUCCESS -ne "1" ]; do SUCCESS=$(kubectl get job data-cassandra-keys --namespace=spinnaker -o=jsonpath="{.status.succeeded}") done I can't figure out what setting I have to change to make this work (how cassandra knows what host to connect). I also don't really understand why the "data-cassandra-keys" job is recreated over and over again. The events are full of: 6m 6m 1 data-cassandra-keys-sxp3o Pod Normal Scheduled {default-scheduler } Successfully assigned data-cassandra-keys-sxp3o to ld9c0193.corp.test 6m 6m 1 data-cassandra-keys-sxp3o Pod spec.containers{cassandra-keys} Normal Pulled {kubelet ld9c0193.corp.test} Container image "docker-registry.corp.ch/kubernetes-spinnaker/cassandra-keys:v2" already present on machine 6m 6m 1 data-cassandra-keys-sxp3o Pod spec.containers{cassandra-keys} Normal Created {kubelet ld9c0193.corp.test} Created container with docker id 46de7bd5f425 6m 6m 1 data-cassandra-keys-sxp3o Pod spec.containers{cassandra-keys} Normal Started {kubelet ld9c0193.corp.test} Started container with docker id 46de7bd5f425 Any hint on whats going on or where to look at is appreciated :) Thanks!
NoDiskConflict is returned by the scheduler if you try to schedule a pod that is referencing a volume that is already referenced by another (already scheduled) pod and the volume does not support multiple mounts. GCE PD allow multiple mounts only if they're all read-only. So, make sure you have no more than one pod referencing a GCE PD in read-write mode. See https://github.com/kubernetes/kubernetes/blob/master/plugin/pkg/scheduler/algorithm/predicates/predicates.go#L105
###Instruction: We had a pod working great for about a month, and suddenly it cannot be scheduled anymore. Describing the pod seems to indicate that a disk is full or otherwise unavailable, but it's not very specific (see full output of describing the pod below). I have confirmed that the disk on this node has plenty of space (95G) and the GCEPersistentDisk it references also has plenty of space (450G). What else can I look for to get this working again? So far I have tried restarting the node and even deleting the node to start from scratch. This is a one-node cluster on GKE. Thanks for any tips! > kubectl --namespace=bakery-production describe pods bakery-deployment-3841321805-l84nc Name: bakery-deployment-3841321805-l84nc Namespace: bakery-production Node: / Labels: pod-template-hash=3841321805,service=bakery Status: Pending IP: Controllers: ReplicaSet/bakery-deployment-3841321805 Containers: bakery: Image: gcr.io/pear-deck-production/bakery:38fda09f727493e4e88def14d49fe36883414e08 Port: 80/TCP QoS Tier: cpu: BestEffort memory: BestEffort Environment Variables: PEARDECK_CONTAINER_REGISTRY: gcr.io/pear-deck-production Volumes: docker-images: Type: GCEPersistentDisk (a Persistent Disk resource in Google Compute Engine) PDName: bakery-docker-images FSType: ext4 Partition: 0 ReadOnly: false bakery-secret-volume: Type: Secret (a volume populated by a Secret) SecretName: bakery-secret default-token-z3ew1: Type: Secret (a volume populated by a Secret) SecretName: default-token-z3ew1 Events: FirstSeen LastSeen Count From SubobjectPath Type Reason Message --------- -------- ----- ---- ------------- -------- ------ ------- 20s 13s 4 {default-scheduler } Warning FailedScheduling pod (bakery-deployment-3841321805-l84nc) failed to fit in any node fit failure on node (gke-peardeck-infrastructure-0f42f748-node-qa5a): NoDiskConflict ### Response: NoDiskConflict is returned by the scheduler if you try to schedule a pod that is referencing a volume that is already referenced by another (already scheduled) pod and the volume does not support multiple mounts. GCE PD allow multiple mounts only if they're all read-only. So, make sure you have no more than one pod referencing a GCE PD in read-write mode. See https://github.com/kubernetes/kubernetes/blob/master/plugin/pkg/scheduler/algorithm/predicates/predicates.go#L105
We had a pod working great for about a month, and suddenly it cannot be scheduled anymore. Describing the pod seems to indicate that a disk is full or otherwise unavailable, but it's not very specific (see full output of describing the pod below). I have confirmed that the disk on this node has plenty of space (95G) and the GCEPersistentDisk it references also has plenty of space (450G). What else can I look for to get this working again? So far I have tried restarting the node and even deleting the node to start from scratch. This is a one-node cluster on GKE. Thanks for any tips! > kubectl --namespace=bakery-production describe pods bakery-deployment-3841321805-l84nc Name: bakery-deployment-3841321805-l84nc Namespace: bakery-production Node: / Labels: pod-template-hash=3841321805,service=bakery Status: Pending IP: Controllers: ReplicaSet/bakery-deployment-3841321805 Containers: bakery: Image: gcr.io/pear-deck-production/bakery:38fda09f727493e4e88def14d49fe36883414e08 Port: 80/TCP QoS Tier: cpu: BestEffort memory: BestEffort Environment Variables: PEARDECK_CONTAINER_REGISTRY: gcr.io/pear-deck-production Volumes: docker-images: Type: GCEPersistentDisk (a Persistent Disk resource in Google Compute Engine) PDName: bakery-docker-images FSType: ext4 Partition: 0 ReadOnly: false bakery-secret-volume: Type: Secret (a volume populated by a Secret) SecretName: bakery-secret default-token-z3ew1: Type: Secret (a volume populated by a Secret) SecretName: default-token-z3ew1 Events: FirstSeen LastSeen Count From SubobjectPath Type Reason Message --------- -------- ----- ---- ------------- -------- ------ ------- 20s 13s 4 {default-scheduler } Warning FailedScheduling pod (bakery-deployment-3841321805-l84nc) failed to fit in any node fit failure on node (gke-peardeck-infrastructure-0f42f748-node-qa5a): NoDiskConflict
I edited cluster/addons/cluster-monitoring/influxdb/influxdb-grafana-controller.yaml - image: privaterepo.net/grafana304 name: grafana env: resources: # keep request = limit to keep this container in guaranteed class limits: And successfully ran grafana 3.0.4 I was also able to post this file to a running cluster by putting the updated file on the master node at this location (master node periodically creates the RC): /etc/kubernetes/addons/cluster-monitoring/influxdb/
###Instruction: I am using Kubernetes v1.2.4 @ https://github.com/kubernetes/kubernetes/releases/download/v1.2.4/kubernetes.tar.gz It comes with Grafana v2.6.0. I tried to change /cluster/addons/cluster-monitoring/influxdb/influxdb-grafana-controller.yaml with monitoringartist/grafana-xxl:latest but this runs Grafana v2.6.0. It seems kube-up is using some other yaml file to create Grafana service. Which yaml/sh file should I modify to do upgrade Grafana? ### Response: I edited cluster/addons/cluster-monitoring/influxdb/influxdb-grafana-controller.yaml - image: privaterepo.net/grafana304 name: grafana env: resources: # keep request = limit to keep this container in guaranteed class limits: And successfully ran grafana 3.0.4 I was also able to post this file to a running cluster by putting the updated file on the master node at this location (master node periodically creates the RC): /etc/kubernetes/addons/cluster-monitoring/influxdb/
I am using Kubernetes v1.2.4 @ https://github.com/kubernetes/kubernetes/releases/download/v1.2.4/kubernetes.tar.gz It comes with Grafana v2.6.0. I tried to change /cluster/addons/cluster-monitoring/influxdb/influxdb-grafana-controller.yaml with monitoringartist/grafana-xxl:latest but this runs Grafana v2.6.0. It seems kube-up is using some other yaml file to create Grafana service. Which yaml/sh file should I modify to do upgrade Grafana?
Your JSON override is specified incorrectly. Unfortunately kubectl run just ignores fields it doesn't understand. kubectl run -i --rm --tty ubuntu --overrides=' { "apiVersion": "batch/v1", "spec": { "template": { "spec": { "containers": [ { "name": "ubuntu", "image": "ubuntu:14.04", "args": [ "bash" ], "stdin": true, "stdinOnce": true, "tty": true, "volumeMounts": [{ "mountPath": "/home/store", "name": "store" }] } ], "volumes": [{ "name":"store", "emptyDir":{} }] } } } } ' --image=ubuntu:14.04 --restart=Never -- bash To debug this issue I ran the command you specified, and then in another terminal ran: kubectl get job ubuntu -o json From there you can see that the actual job structure differs from your json override (you were missing the nested template/spec, and volumes, volumeMounts, and containers need to be arrays).
###Instruction: I understand that you can create a pod with Deployment/Job using kubectl run. But is it possible to create one with a volume attached to it? I tried running this command: kubectl run -i --rm --tty ubuntu --overrides='{ "apiVersion":"batch/v1", "spec": {"containers": {"image": "ubuntu:14.04", "volumeMounts": {"mountPath": "/home/store", "name":"store"}}, "volumes":{"name":"store", "emptyDir":{}}}}' --image=ubuntu:14.04 --restart=Never -- bash But the volume does not appear in the interactive bash. Is there a better way to create a pod with volume that you can attach to? ### Response: Your JSON override is specified incorrectly. Unfortunately kubectl run just ignores fields it doesn't understand. kubectl run -i --rm --tty ubuntu --overrides=' { "apiVersion": "batch/v1", "spec": { "template": { "spec": { "containers": [ { "name": "ubuntu", "image": "ubuntu:14.04", "args": [ "bash" ], "stdin": true, "stdinOnce": true, "tty": true, "volumeMounts": [{ "mountPath": "/home/store", "name": "store" }] } ], "volumes": [{ "name":"store", "emptyDir":{} }] } } } } ' --image=ubuntu:14.04 --restart=Never -- bash To debug this issue I ran the command you specified, and then in another terminal ran: kubectl get job ubuntu -o json From there you can see that the actual job structure differs from your json override (you were missing the nested template/spec, and volumes, volumeMounts, and containers need to be arrays).
I understand that you can create a pod with Deployment/Job using kubectl run. But is it possible to create one with a volume attached to it? I tried running this command: kubectl run -i --rm --tty ubuntu --overrides='{ "apiVersion":"batch/v1", "spec": {"containers": {"image": "ubuntu:14.04", "volumeMounts": {"mountPath": "/home/store", "name":"store"}}, "volumes":{"name":"store", "emptyDir":{}}}}' --image=ubuntu:14.04 --restart=Never -- bash But the volume does not appear in the interactive bash. Is there a better way to create a pod with volume that you can attach to?
Looks to me like you are getting region and zone confused. Use the ec2-describe-regions command as follows to describe your regions. PROMPT> ec2-describe-regions REGION us-east-1 ec2.us-east-1.amazonaws.com REGION ap-northeast-1 ec2.ap-northeast-1.amazonaws.com REGION ap-southeast-1 ec2.ap-southeast-1.amazonaws.com .. Use the ec2-describe-availability-zones command as follows to describe your Availability Zones within the us-east-1 region. PROMPT> ec2-describe-availability-zones --region us-east-1 AVAILABILITYZONE us-east-1a available us-east-1 AVAILABILITYZONE us-east-1b available us-east-1 AVAILABILITYZONE us-east-1c available us-east-1 AVAILABILITYZONE us-east-1d available us-east-1 be sure to use a region in export AWS_S3_REGION=
###Instruction: I'm following this guide to set up Kubernetes on an Ubuntu 14.04 image on AWS. sudo apt-get update sudo apt-get install curl sudo apt-get install awscli aws configure # enter credentials, etc. # fix `locale` errors export LC_ALL=en_US.UTF-8 export LANG=en_US.UTF-8 export KUBE_AWS_ZONE=us-east-1b export NUM_NODES=2 export MASTER_SIZE=t2.micro export NODE_SIZE=t2.micro export AWS_S3_BUCKET=my.s3.bucket.kube export AWS_S3_REGION=us-east-1b export INSTANCE_PREFIX=k8s export KUBERNETES_PROVIDER=aws curl -sS https://get.k8s.io | bash This fails, however... ubuntu@ip-172-31-24-216:~$ curl -sS https://get.k8s.io | bash Downloading kubernetes release v1.2.4 to /home/ubuntu/kubernetes.tar.gz --2016-05-21 17:01:20-- https://storage.googleapis.com/kubernetes-release/release/v1.2.4/kubernetes.tar.gz Resolving storage.googleapis.com (storage.googleapis.com)... 74.125.29.128, 2607:f8b0:400d:c03::80 Connecting to storage.googleapis.com (storage.googleapis.com)|74.125.29.128|:443... connected. HTTP request sent, awaiting response... 200 OK Length: 496696744 (474M) [application/x-tar] Saving to: ‘kubernetes.tar.gz’ 100%[======================================>] 496,696,744 57.4MB/s in 8.2s 2016-05-21 17:01:29 (58.1 MB/s) - ‘kubernetes.tar.gz’ saved [496696744/496696744] Unpacking kubernetes release v1.2.4 Creating a kubernetes on aws... ... Starting cluster in us-east-1b using provider aws ... calling verify-prereqs ... calling kube-up Starting cluster using os distro: jessie Uploading to Amazon S3 +++ Staging server tars to S3 Storage: my.s3.bucket.kube/devel usage: aws [options] <command> <subcommand> [parameters] aws: error: argument --region: expected one argument I tried editing cluster/aws/util.sh to print out s3_bucket_location (following advice from this question, and I get an empty string. I'm guessing that's why it fails? The docs say an empty string for US East is normal, but I tried changing region (with everything else remaining the same) and I still get an empty string. The s3 bucket does get created. Any help would be appreciated. ### Response: Looks to me like you are getting region and zone confused. Use the ec2-describe-regions command as follows to describe your regions. PROMPT> ec2-describe-regions REGION us-east-1 ec2.us-east-1.amazonaws.com REGION ap-northeast-1 ec2.ap-northeast-1.amazonaws.com REGION ap-southeast-1 ec2.ap-southeast-1.amazonaws.com .. Use the ec2-describe-availability-zones command as follows to describe your Availability Zones within the us-east-1 region. PROMPT> ec2-describe-availability-zones --region us-east-1 AVAILABILITYZONE us-east-1a available us-east-1 AVAILABILITYZONE us-east-1b available us-east-1 AVAILABILITYZONE us-east-1c available us-east-1 AVAILABILITYZONE us-east-1d available us-east-1 be sure to use a region in export AWS_S3_REGION=
I'm following this guide to set up Kubernetes on an Ubuntu 14.04 image on AWS. sudo apt-get update sudo apt-get install curl sudo apt-get install awscli aws configure # enter credentials, etc. # fix `locale` errors export LC_ALL=en_US.UTF-8 export LANG=en_US.UTF-8 export KUBE_AWS_ZONE=us-east-1b export NUM_NODES=2 export MASTER_SIZE=t2.micro export NODE_SIZE=t2.micro export AWS_S3_BUCKET=my.s3.bucket.kube export AWS_S3_REGION=us-east-1b export INSTANCE_PREFIX=k8s export KUBERNETES_PROVIDER=aws curl -sS https://get.k8s.io | bash This fails, however... ubuntu@ip-172-31-24-216:~$ curl -sS https://get.k8s.io | bash Downloading kubernetes release v1.2.4 to /home/ubuntu/kubernetes.tar.gz --2016-05-21 17:01:20-- https://storage.googleapis.com/kubernetes-release/release/v1.2.4/kubernetes.tar.gz Resolving storage.googleapis.com (storage.googleapis.com)... 74.125.29.128, 2607:f8b0:400d:c03::80 Connecting to storage.googleapis.com (storage.googleapis.com)|74.125.29.128|:443... connected. HTTP request sent, awaiting response... 200 OK Length: 496696744 (474M) [application/x-tar] Saving to: ‘kubernetes.tar.gz’ 100%[======================================>] 496,696,744 57.4MB/s in 8.2s 2016-05-21 17:01:29 (58.1 MB/s) - ‘kubernetes.tar.gz’ saved [496696744/496696744] Unpacking kubernetes release v1.2.4 Creating a kubernetes on aws... ... Starting cluster in us-east-1b using provider aws ... calling verify-prereqs ... calling kube-up Starting cluster using os distro: jessie Uploading to Amazon S3 +++ Staging server tars to S3 Storage: my.s3.bucket.kube/devel usage: aws [options] <command> <subcommand> [parameters] aws: error: argument --region: expected one argument I tried editing cluster/aws/util.sh to print out s3_bucket_location (following advice from this question, and I get an empty string. I'm guessing that's why it fails? The docs say an empty string for US East is normal, but I tried changing region (with everything else remaining the same) and I still get an empty string. The s3 bucket does get created. Any help would be appreciated.
You can't. You should think your disc as a physical disk. If your physical disk is unmounted then you can't access it. If you want to access to Neo4j data then the best way is through your Ne4j instance. Also you can mount this persistent disk in another instance and through it access to your data. Check this to do that. Update: If you have access via ssh to the instance where your disc is mounted (Neo4j instance), then you can transfer your data via scp copy to/from your local computer. Take a look here.
###Instruction: I have linked a Persistent Volume to my Kubernetes Neo4j Replication Controller to store the DB data. Now I would like to access this Drive to copy its content. The gcould api offers: gcloud compute ssh instance-name but its not an instance its a drive, so how can you connect to it ? ### Response: You can't. You should think your disc as a physical disk. If your physical disk is unmounted then you can't access it. If you want to access to Neo4j data then the best way is through your Ne4j instance. Also you can mount this persistent disk in another instance and through it access to your data. Check this to do that. Update: If you have access via ssh to the instance where your disc is mounted (Neo4j instance), then you can transfer your data via scp copy to/from your local computer. Take a look here.
I have linked a Persistent Volume to my Kubernetes Neo4j Replication Controller to store the DB data. Now I would like to access this Drive to copy its content. The gcould api offers: gcloud compute ssh instance-name but its not an instance its a drive, so how can you connect to it ?
If you go to the AWS ASG in the web console and select the minion ASG example: https://us-west-2.console.aws.amazon.com/ec2/autoscaling/home?region=us-west-2#AutoScalingGroups:id=kubernetes-dev-minion-group-us-west-2a;view=details Then edit the ASG's min,max you should get more/less nodes: adjusting the num nodes in ASG
###Instruction: as We know we can autoscale on pods so here actually I have 2 question: 1. How to autoscaling nodes on kubernetes ? 2. How to trigger autoscaling group with AWS ? ### Response: If you go to the AWS ASG in the web console and select the minion ASG example: https://us-west-2.console.aws.amazon.com/ec2/autoscaling/home?region=us-west-2#AutoScalingGroups:id=kubernetes-dev-minion-group-us-west-2a;view=details Then edit the ASG's min,max you should get more/less nodes: adjusting the num nodes in ASG
as We know we can autoscale on pods so here actually I have 2 question: 1. How to autoscaling nodes on kubernetes ? 2. How to trigger autoscaling group with AWS ?
This happens only when kubelet is run without the --cloud-provider=gce flag. The problem, unless is something different, is dependant on how GCP is launching Container-VMs. Please contact with google cloud platform guys. Note if this happens to you when using GCE: Add --cloud-provider=gce flag to kubelet in all your workers. This only applies to 1.2 cluster versions because, if i'm not wrong, there is an ongoing attach/detach design targeted for 1.3 clusters which will move this business logic out of kubelet. In case someone is interested in the attach/detach redesign here it is its corresponding github issue: https://github.com/kubernetes/kubernetes/issues/20262
###Instruction: I currently try to switch from the "Container-Optimized Google Compute Engine Images" (https://cloud.google.com/compute/docs/containers/container_vms) to the "Container-VM" Image (https://cloud.google.com/compute/docs/containers/vm-image/#overview). In my containers.yaml, I define a volume and a container using the volume. apiVersion: v1 kind: Pod metadata: name: workhorse spec: containers: - name: postgres image: postgres:9.5 imagePullPolicy: Always volumeMounts: - name: postgres-storage mountPath: /var/lib/postgresql/data volumes: - name: postgres-storage gcePersistentDisk: pdName: disk-name fsType: ext4 This setup worked fine with the "Container-Optimized Google Compute Engine Images", however fails with the "Container-VM". In the logs, I can see the following error: May 24 18:33:43 battleship kubelet[629]: E0524 18:33:43.405470 629 gce_util.go:176] Error getting GCECloudProvider while detaching PD "disk-name": Failed to get GCE Cloud Provider. plugin.host.GetCloudProvider returned <nil> instead Thanks in advance for any hint! ### Response: This happens only when kubelet is run without the --cloud-provider=gce flag. The problem, unless is something different, is dependant on how GCP is launching Container-VMs. Please contact with google cloud platform guys. Note if this happens to you when using GCE: Add --cloud-provider=gce flag to kubelet in all your workers. This only applies to 1.2 cluster versions because, if i'm not wrong, there is an ongoing attach/detach design targeted for 1.3 clusters which will move this business logic out of kubelet. In case someone is interested in the attach/detach redesign here it is its corresponding github issue: https://github.com/kubernetes/kubernetes/issues/20262
I currently try to switch from the "Container-Optimized Google Compute Engine Images" (https://cloud.google.com/compute/docs/containers/container_vms) to the "Container-VM" Image (https://cloud.google.com/compute/docs/containers/vm-image/#overview). In my containers.yaml, I define a volume and a container using the volume. apiVersion: v1 kind: Pod metadata: name: workhorse spec: containers: - name: postgres image: postgres:9.5 imagePullPolicy: Always volumeMounts: - name: postgres-storage mountPath: /var/lib/postgresql/data volumes: - name: postgres-storage gcePersistentDisk: pdName: disk-name fsType: ext4 This setup worked fine with the "Container-Optimized Google Compute Engine Images", however fails with the "Container-VM". In the logs, I can see the following error: May 24 18:33:43 battleship kubelet[629]: E0524 18:33:43.405470 629 gce_util.go:176] Error getting GCECloudProvider while detaching PD "disk-name": Failed to get GCE Cloud Provider. plugin.host.GetCloudProvider returned <nil> instead Thanks in advance for any hint!
The kube-proxy is run as an addon pod, meaning the Kubelet will automatically restart it if it goes away. This means you can restart the kube-proxy pod by simply deleting it: $ kubectl delete pod --namespace=kube-system kube-proxy-${NODE_NAME} Where $NODE_NAME is the node you want to restart the proxy on (this is assuming a default configuration, otherwise kubectl get pods --kube-system should include the list of kube-proxy pods). If the restarted kube-proxy is missing your annotation change, you may need to update the manifest file, usually found in /etc/kubernetes/manifests on the node.
###Instruction: As of Kubernetes 1.2, kube-proxy is now a pod running in the kube-system namespace. The old init script /etc/init.d/kube-proxy has been removed. Aside from simply resetting the GCE instance, is there a good way to restart kube-proxy? I just added an annotation to change the proxy mode, and I need to restart kube-proxy for my change to take effect. ### Response: The kube-proxy is run as an addon pod, meaning the Kubelet will automatically restart it if it goes away. This means you can restart the kube-proxy pod by simply deleting it: $ kubectl delete pod --namespace=kube-system kube-proxy-${NODE_NAME} Where $NODE_NAME is the node you want to restart the proxy on (this is assuming a default configuration, otherwise kubectl get pods --kube-system should include the list of kube-proxy pods). If the restarted kube-proxy is missing your annotation change, you may need to update the manifest file, usually found in /etc/kubernetes/manifests on the node.
As of Kubernetes 1.2, kube-proxy is now a pod running in the kube-system namespace. The old init script /etc/init.d/kube-proxy has been removed. Aside from simply resetting the GCE instance, is there a good way to restart kube-proxy? I just added an annotation to change the proxy mode, and I need to restart kube-proxy for my change to take effect.
This is expected to be supported in 1.3: https://github.com/kubernetes/kubernetes/pull/11980 UPDATE: didn't meet the 1.3 deadline so it'll sleep into 1.4 https://github.com/kubernetes/kubernetes/issues/2156#issuecomment-223385808 UPDATE (thanks @Kevinoid): Looks like it has reached alpha in 1.4 and progress is now being tracked in https://github.com/kubernetes/features/issues/19 with usage documentation at http://kubernetes.io/docs/user-guide/cron-jobs/
###Instruction: What is the recommended way to execute a container or pod based on a time-based schedule? For example, a task to run at 2am for 10 minutes every day. On a traditional linux server, crontab would easily work, and that obviously still is possible inside the container. However, since this task only executes for 10 minutes I was looking for a mechanism to execute a basic container on a given time interval, then dispose of of the container. Chronos (part of Mesos) appears to have a similar behavior, is this possible in Container Engine? ### Response: This is expected to be supported in 1.3: https://github.com/kubernetes/kubernetes/pull/11980 UPDATE: didn't meet the 1.3 deadline so it'll sleep into 1.4 https://github.com/kubernetes/kubernetes/issues/2156#issuecomment-223385808 UPDATE (thanks @Kevinoid): Looks like it has reached alpha in 1.4 and progress is now being tracked in https://github.com/kubernetes/features/issues/19 with usage documentation at http://kubernetes.io/docs/user-guide/cron-jobs/
What is the recommended way to execute a container or pod based on a time-based schedule? For example, a task to run at 2am for 10 minutes every day. On a traditional linux server, crontab would easily work, and that obviously still is possible inside the container. However, since this task only executes for 10 minutes I was looking for a mechanism to execute a basic container on a given time interval, then dispose of of the container. Chronos (part of Mesos) appears to have a similar behavior, is this possible in Container Engine?
This is exactly the type of use case that Kubernetes is well suited for. You should use a Replica Set. When creating your Replica Set, you specify a template that tells the system how to create each container instance along with a desired number of replicas. It will then create that number of replicas in the available number of nodes in your cluster. One caveat is that by default, Kubernetes will only allow you to have ~100 pods / node, but you can change this number with a command line flag if you need more.
###Instruction: I have to create a huge number of Docker container on different hosts (e.g. 50 container each on 3 hosts). These container all have the same image, configuration etc. and only the network address and ID of each container should be different (so basically I want to create a huge virtual container network). Is there a way to achieve this? I have looked at technologies like Helios and Kubernetes but they seem to only deploy one container on each agent. I thought about just creating a lot of different jobs in Helios and then deploy each one of them to its agent, but that seems a little dirty to me. ### Response: This is exactly the type of use case that Kubernetes is well suited for. You should use a Replica Set. When creating your Replica Set, you specify a template that tells the system how to create each container instance along with a desired number of replicas. It will then create that number of replicas in the available number of nodes in your cluster. One caveat is that by default, Kubernetes will only allow you to have ~100 pods / node, but you can change this number with a command line flag if you need more.
I have to create a huge number of Docker container on different hosts (e.g. 50 container each on 3 hosts). These container all have the same image, configuration etc. and only the network address and ID of each container should be different (so basically I want to create a huge virtual container network). Is there a way to achieve this? I have looked at technologies like Helios and Kubernetes but they seem to only deploy one container on each agent. I thought about just creating a lot of different jobs in Helios and then deploy each one of them to its agent, but that seems a little dirty to me.
The sync period is how often we force-refresh the whole state, rather than just doing incremental deltas. This is a safegauard against potential bugs that might cause syncronized state to drift.
###Instruction: The kube-proxy gets the Services and Endpoints information from the master api, but how? According to these links: http://kubernetes.io/docs/user-guide/services/#proxy-mode-iptables https://github.com/kubernetes/kubernetes/blob/ee2a0694b649941fc0c3be606746db041b75b91d/cmd/kube-proxy/app/server.go The proxy seems to be a watcher of the master api, so the update of the proxy information is immediate. But then, what is the parameter config-sync-period ( How often configuration from the apiserver is refreshed. Must be greater than 0. ) in the proxy that defaults to 15 min? What configuration is refreshed? ### Response: The sync period is how often we force-refresh the whole state, rather than just doing incremental deltas. This is a safegauard against potential bugs that might cause syncronized state to drift.
The kube-proxy gets the Services and Endpoints information from the master api, but how? According to these links: http://kubernetes.io/docs/user-guide/services/#proxy-mode-iptables https://github.com/kubernetes/kubernetes/blob/ee2a0694b649941fc0c3be606746db041b75b91d/cmd/kube-proxy/app/server.go The proxy seems to be a watcher of the master api, so the update of the proxy information is immediate. But then, what is the parameter config-sync-period ( How often configuration from the apiserver is refreshed. Must be greater than 0. ) in the proxy that defaults to 15 min? What configuration is refreshed?
Each ingress resource will have a separate IP. If you need to share a single IP between domains, then you will need to configure both domains in the same ingress resource. Try kubectl edit if you don't want to patch directly on the command line.
###Instruction: I'm trying to figure out how to create multiple ingress resources that share an IP. Or, if that isn't possible, I'd like to know if there's some sort of forwarding rule I can use in conjunction with a Cloud DNS entry that ensures all traffic to an IP (which I can make static) goes to one kubernetes cluster. Essentially I'd like to set up an ingress with each service that contains one or more subdomains and all those ingresses to point to the same cluster. Right now I get a different ephemeral IP with each ingress. Can I create some forwarding rule that points all traffic to a static IP go to a cluster and then perhaps create a wildcard DNS entry that points all subdomains to the static IP? Here's an example config similar to what I'm using: apiVersion: v1 kind: Service metadata: name: api-service labels: name: api-service spec: type: NodePort ports: - port: 80 targetPort: 3000 protocol: TCP selector: name: api-deployment --- apiVersion: extensions/v1beta1 kind: Deployment metadata: name: api-deployment labels: name: api-deployment spec: template: metadata: labels: name: api spec: containers: - image: us.gcr.io/[project]/hello-world:1.0.0 name: api ports: - containerPort: 3000 env: - name: NAME value: api --- apiVersion: extensions/v1beta1 kind: Ingress metadata: name: api-ingress spec: backend: serviceName: api-service servicePort: 80 rules: - host: api.example.com http: paths: - backend: serviceName: api-service servicePort: 80 I create these resources on a kube cluster like so: $ kubectl create -f api.yml And then see the ingress that's created like so: $ kubectl get ing NAME RULE BACKEND ADDRESS AGE api-ingress - api-service:80 130.211.32.223 1h api.example.com api-service:80 Now, imagine you copy that yaml above and change the service, deployment and ingress name to api-2 and create those. You'd end up with something like this: $ kubectl get ing NAME RULE BACKEND ADDRESS AGE api-ingress - api-service:80 130.211.32.223 1h api.example.com api-service:80 api-2-ingress - api-2-service:80 130.211.22.214 1h api-2.example.com api-2-service:80 Which is fine... But I need to ensure all traffic to *.example.com goes to the cluster so the ingresses can do their magic and route the requests to the right services. I know I could have a single ingress resource created and patch that one instead of creating a new one but I'm trying to avoid that and would prefer if I can create one per service. Is this possible somehow? Related: https://github.com/kubernetes/kubernetes/issues/26935 ### Response: Each ingress resource will have a separate IP. If you need to share a single IP between domains, then you will need to configure both domains in the same ingress resource. Try kubectl edit if you don't want to patch directly on the command line.
I'm trying to figure out how to create multiple ingress resources that share an IP. Or, if that isn't possible, I'd like to know if there's some sort of forwarding rule I can use in conjunction with a Cloud DNS entry that ensures all traffic to an IP (which I can make static) goes to one kubernetes cluster. Essentially I'd like to set up an ingress with each service that contains one or more subdomains and all those ingresses to point to the same cluster. Right now I get a different ephemeral IP with each ingress. Can I create some forwarding rule that points all traffic to a static IP go to a cluster and then perhaps create a wildcard DNS entry that points all subdomains to the static IP? Here's an example config similar to what I'm using: apiVersion: v1 kind: Service metadata: name: api-service labels: name: api-service spec: type: NodePort ports: - port: 80 targetPort: 3000 protocol: TCP selector: name: api-deployment --- apiVersion: extensions/v1beta1 kind: Deployment metadata: name: api-deployment labels: name: api-deployment spec: template: metadata: labels: name: api spec: containers: - image: us.gcr.io/[project]/hello-world:1.0.0 name: api ports: - containerPort: 3000 env: - name: NAME value: api --- apiVersion: extensions/v1beta1 kind: Ingress metadata: name: api-ingress spec: backend: serviceName: api-service servicePort: 80 rules: - host: api.example.com http: paths: - backend: serviceName: api-service servicePort: 80 I create these resources on a kube cluster like so: $ kubectl create -f api.yml And then see the ingress that's created like so: $ kubectl get ing NAME RULE BACKEND ADDRESS AGE api-ingress - api-service:80 130.211.32.223 1h api.example.com api-service:80 Now, imagine you copy that yaml above and change the service, deployment and ingress name to api-2 and create those. You'd end up with something like this: $ kubectl get ing NAME RULE BACKEND ADDRESS AGE api-ingress - api-service:80 130.211.32.223 1h api.example.com api-service:80 api-2-ingress - api-2-service:80 130.211.22.214 1h api-2.example.com api-2-service:80 Which is fine... But I need to ensure all traffic to *.example.com goes to the cluster so the ingresses can do their magic and route the requests to the right services. I know I could have a single ingress resource created and patch that one instead of creating a new one but I'm trying to avoid that and would prefer if I can create one per service. Is this possible somehow? Related: https://github.com/kubernetes/kubernetes/issues/26935
A couple of issues #9043 and #13488 describe the problem reasonably well, and I suspect a rolling update approach will eventuate shortly (like most things in Kubernetes), though unlikely for 1.3.0. The same issue applies with updating ConfigMaps. Kubernetes will do a rolling update whenever anything in the deployment pod spec is changed (eg. typically image to a new version), so one suggested workaround is to set an env variable in your deployment pod spec (eg. RESTART_) Then when you've updated your secret/configmap, bump the env value in your deployment (via kubectl apply, or patch, or edit), and Kubernetes will start a rolling update of your deployment. Example Deployment spec: apiVersion: extensions/v1beta1 kind: Deployment metadata: name: test-nginx spec: replicas: 2 template: metadata: spec: containers: - name: nginx image: "nginx:stable" ports: - containerPort: 80 - mountPath: /etc/nginx/conf.d name: config readOnly: true - mountPath: /etc/nginx/auth name: tokens readOnly: true env: - name: RESTART_ value: "13" volumes: - name: config configMap: name: test-nginx-config - name: tokens secret: secretName: test-nginx-tokens Two tips: your environment variable name can't start with an _ or it magically disappears somehow. if you use a number for your restart variable you need to wrap it in quotes
###Instruction: I have a Replication Controller with one replica using a secret. How can I update or recreate its (lone) pod—without downtime—with latest secret value when the secret value is changed? My current workaround is increasing number of replicas in the Replication Controller, deleting the old pods, and changing the replica count back to its original value. Is there a command or flag to induce a rolling update retaining the same container image and tag? When I try to do so, it rejects my attempt with the following message: error: Specified --image must be distinct from existing container image ### Response: A couple of issues #9043 and #13488 describe the problem reasonably well, and I suspect a rolling update approach will eventuate shortly (like most things in Kubernetes), though unlikely for 1.3.0. The same issue applies with updating ConfigMaps. Kubernetes will do a rolling update whenever anything in the deployment pod spec is changed (eg. typically image to a new version), so one suggested workaround is to set an env variable in your deployment pod spec (eg. RESTART_) Then when you've updated your secret/configmap, bump the env value in your deployment (via kubectl apply, or patch, or edit), and Kubernetes will start a rolling update of your deployment. Example Deployment spec: apiVersion: extensions/v1beta1 kind: Deployment metadata: name: test-nginx spec: replicas: 2 template: metadata: spec: containers: - name: nginx image: "nginx:stable" ports: - containerPort: 80 - mountPath: /etc/nginx/conf.d name: config readOnly: true - mountPath: /etc/nginx/auth name: tokens readOnly: true env: - name: RESTART_ value: "13" volumes: - name: config configMap: name: test-nginx-config - name: tokens secret: secretName: test-nginx-tokens Two tips: your environment variable name can't start with an _ or it magically disappears somehow. if you use a number for your restart variable you need to wrap it in quotes
I have a Replication Controller with one replica using a secret. How can I update or recreate its (lone) pod—without downtime—with latest secret value when the secret value is changed? My current workaround is increasing number of replicas in the Replication Controller, deleting the old pods, and changing the replica count back to its original value. Is there a command or flag to induce a rolling update retaining the same container image and tag? When I try to do so, it rejects my attempt with the following message: error: Specified --image must be distinct from existing container image
I understand that the Ingress controller will automatically allocate an external/public IP for me, but this is not exactly what I need. Am I able to decide what IP I want? You can ask Google for a static global IP address, which can then be used for your L7 load balancing (you would point your DNS name to this IP). There isn't a way to bring your own IP address into a google L7 load balancer (either directly or using the Ingress object).
###Instruction: I have followed the instructions (https://cloud.google.com/container-engine/docs/tutorials/http-balancer, and http://kubernetes.io/docs/user-guide/ingress/) to create an Ingress resource for my Kubernetes Service - my cluster is deployed within Google Container Engine (GKE). I understand that the Ingress controller will automatically allocate an external/public IP for me, but this is not exactly what I need. Am I able to decide what IP I want? I have a domain name and a static IP which I would like to use instead of the one assigned by the Ingress controller. Hopefully this can be defined inside the json/yaml configuration file for the Ingress resource. This is my preferred way to create resources as I can keep track of the state of the created resources (rather than using kubectl edit from command line to edit my way to the preferred state). ### Response: I understand that the Ingress controller will automatically allocate an external/public IP for me, but this is not exactly what I need. Am I able to decide what IP I want? You can ask Google for a static global IP address, which can then be used for your L7 load balancing (you would point your DNS name to this IP). There isn't a way to bring your own IP address into a google L7 load balancer (either directly or using the Ingress object).
I have followed the instructions (https://cloud.google.com/container-engine/docs/tutorials/http-balancer, and http://kubernetes.io/docs/user-guide/ingress/) to create an Ingress resource for my Kubernetes Service - my cluster is deployed within Google Container Engine (GKE). I understand that the Ingress controller will automatically allocate an external/public IP for me, but this is not exactly what I need. Am I able to decide what IP I want? I have a domain name and a static IP which I would like to use instead of the one assigned by the Ingress controller. Hopefully this can be defined inside the json/yaml configuration file for the Ingress resource. This is my preferred way to create resources as I can keep track of the state of the created resources (rather than using kubectl edit from command line to edit my way to the preferred state).
Most likely the problem is that you're not running DNS in your cluster. HPA currently uses heapster service name to read metrics. You have properly created it, but HPA controller cannot resolve service name to IP address as there's not DNS in your cluster. I have create issue https://github.com/kubernetes/kubernetes/issues/27044 to have more informative events that would help the user/admin understand the problem better.
###Instruction: I am trying to configure kubernetes horizontal pod autoscaling. The definition of my deployment is here. I start heapster deployment and heapster service like below: # kubectl run heapster --namespace=kube-system --image=gcr.io/google_containers/heapster:v1.0.2 --command -- /heapster --source=kubernetes:http://192.168.122.159:8080?inClusterConfig=false --sink=log # kubectl expose deployment heapster --port=80 --target-port=8082 --name=heapster --namespace=kube-system The hpa is create like this: # kubectl autoscale deployment nginx-rc --max=5 --cpu-percent=25 The heapster seems to run fine. Here are the logs. After all this, the hpa is not receiving any data on CPU utilization. # kubectl describe hpa Name: nginx-rc Namespace: default Labels: <none> Annotations: <none> CreationTimestamp: Sat, 04 Jun 2016 07:23:03 -0400 Reference: Deployment/nginx-rc/scale Target CPU utilization: 25% Current CPU utilization: <unset> Min replicas: 1 Max replicas: 5 Events: FirstSeen LastSeen Count From SubobjectPath Type Reason Message --------- -------- ----- ---- ------------- -------- ------ ------- 9m 7s 22 {horizontal-pod-autoscaler } Warning FailedGetMetrics failed to get CPU consumption and request: metrics obtained for 0/1 of pods 9m 7s 22 {horizontal-pod-autoscaler } Warning FailedComputeReplicas failed to get CPU utilization: failed to get CPU consumption and request: metrics obtained for 0/1 of pods Controller manager logs have a recurring line: Jun 04 07:21:33 master kube-controller-manager[8202]: W0604 07:21:33.079677 8202 horizontal.go:108] Failed to reconcile nginx-rc: failed to compute desired number of replicas based on CPU utilization for Deployment/default/nginx-rc: failed to get CPU utilization: failed to get CPU consumption and request: metrics obtained for 0/1 of pods Can someone point out the nature of the problem here? ### Response: Most likely the problem is that you're not running DNS in your cluster. HPA currently uses heapster service name to read metrics. You have properly created it, but HPA controller cannot resolve service name to IP address as there's not DNS in your cluster. I have create issue https://github.com/kubernetes/kubernetes/issues/27044 to have more informative events that would help the user/admin understand the problem better.
I am trying to configure kubernetes horizontal pod autoscaling. The definition of my deployment is here. I start heapster deployment and heapster service like below: # kubectl run heapster --namespace=kube-system --image=gcr.io/google_containers/heapster:v1.0.2 --command -- /heapster --source=kubernetes:http://192.168.122.159:8080?inClusterConfig=false --sink=log # kubectl expose deployment heapster --port=80 --target-port=8082 --name=heapster --namespace=kube-system The hpa is create like this: # kubectl autoscale deployment nginx-rc --max=5 --cpu-percent=25 The heapster seems to run fine. Here are the logs. After all this, the hpa is not receiving any data on CPU utilization. # kubectl describe hpa Name: nginx-rc Namespace: default Labels: <none> Annotations: <none> CreationTimestamp: Sat, 04 Jun 2016 07:23:03 -0400 Reference: Deployment/nginx-rc/scale Target CPU utilization: 25% Current CPU utilization: <unset> Min replicas: 1 Max replicas: 5 Events: FirstSeen LastSeen Count From SubobjectPath Type Reason Message --------- -------- ----- ---- ------------- -------- ------ ------- 9m 7s 22 {horizontal-pod-autoscaler } Warning FailedGetMetrics failed to get CPU consumption and request: metrics obtained for 0/1 of pods 9m 7s 22 {horizontal-pod-autoscaler } Warning FailedComputeReplicas failed to get CPU utilization: failed to get CPU consumption and request: metrics obtained for 0/1 of pods Controller manager logs have a recurring line: Jun 04 07:21:33 master kube-controller-manager[8202]: W0604 07:21:33.079677 8202 horizontal.go:108] Failed to reconcile nginx-rc: failed to compute desired number of replicas based on CPU utilization for Deployment/default/nginx-rc: failed to get CPU utilization: failed to get CPU consumption and request: metrics obtained for 0/1 of pods Can someone point out the nature of the problem here?
While you can create "unmanaged" HTTP Load Balancer by yourself, what happens when you add new deployments (pods with services) and want traffic to be routed to them as well (perhaps using URL Maps)? What happens when one of your services goes down for some reason and the new service allocates another node port? The great thing about Ingress is that it manages the HTTP Load Balancer for you while keeping track on Kubernetes' resources and updates the HTTP Load Balancer accordingly.
###Instruction: I have followed the GKE tutorial for creating an HTTP Load Balancer using the beta Ingress type and it works fine when using the nginx image. My question is about why Ingress is even necessary. I can create a container engine cluster and then create a HTTP Load Balancer that uses the Kubernetes-created instance group as the service backend and everything seems to work fine. Why would I go through all of the hassel of using Ingress when using Kubernetes for only part of the process seems to work just fine? ### Response: While you can create "unmanaged" HTTP Load Balancer by yourself, what happens when you add new deployments (pods with services) and want traffic to be routed to them as well (perhaps using URL Maps)? What happens when one of your services goes down for some reason and the new service allocates another node port? The great thing about Ingress is that it manages the HTTP Load Balancer for you while keeping track on Kubernetes' resources and updates the HTTP Load Balancer accordingly.
I have followed the GKE tutorial for creating an HTTP Load Balancer using the beta Ingress type and it works fine when using the nginx image. My question is about why Ingress is even necessary. I can create a container engine cluster and then create a HTTP Load Balancer that uses the Kubernetes-created instance group as the service backend and everything seems to work fine. Why would I go through all of the hassel of using Ingress when using Kubernetes for only part of the process seems to work just fine?
if I delete and recreate the pv, kubectl get pvc,pv will show [bound]. Why is the pvc still Bound? That's bug in Kubernetes 1.2, it will be fixed in 1.3. Both PV and PVC should get Bound eventually. However, deleting a bound PV is very bad idea, as the PVC may be used in a running pod and the pod suddenly looses storage underneath. You should never touch bound PVs! I also observed that creating the pv after the pvc makes the pvc wait forever with Pending status It won't wait forever, it should get bound after 10 minutes. Use kube-controller-manager --pvclaimbinder-sync-period=15s to shorten it to 15 seconds. Again, this will be better in Kubernetes 1.3, 15 seconds will be default there.
###Instruction: I have the following pvc (Persistent Volume Claim): piVersion: v1 kind: PersistentVolumeClaim metadata: name: test-claim-web spec: accessModes: - ReadWriteOnce resources: requests: storage: 10Gi and the Google Cloud-backed pv (Persistent Volume): apiVersion: v1 kind: PersistentVolume metadata: name: test-pv-1 spec: capacity: storage: 10Gi accessModes: - ReadWriteOnce gcePersistentDisk: pdName: test-1 fsType: ext4 and the Disk in Google cloud that exists. If I create first the pv and after the pvc, kubectl get pvc,pv will show: NAME STATUS VOLUME CAPACITY ACCESSMODES AGE test-claim-web Bound test-pv-1 10Gi RWO 15s NAME CAPACITY ACCESSMODES STATUS CLAIM REASON AGE test-pv-1 10Gi RWO Bound default/test-claim-web 25s But if I delete and recreate the pv, kubectl get pvc,pv will show: NAME STATUS VOLUME CAPACITY ACCESSMODES AGE test-claim-web Bound test-pv-1 10Gi RWO 3m NAME CAPACITY ACCESSMODES STATUS CLAIM REASON AGE test-pv-1 10Gi RWO Available 18s Why is the pvc still Bound? Doesn't the pvc (re-)bind automatically? (I also observed that creating the pv after the pvc makes the pvc wait forever with Pending status.) I use the following Kubernetes version: Client Version: version.Info{Major:"1", Minor:"2", GitVersion:"v1.2.4", GitCommit:"3eed1e3be6848b877ff80a93da3785d9034d0a4f", GitTreeState:"clean"} Server Version: version.Info{Major:"1", Minor:"2", GitVersion:"v1.2.4", GitCommit:"3eed1e3be6848b877ff80a93da3785d9034d0a4f", GitTreeState:"clean"} ### Response: if I delete and recreate the pv, kubectl get pvc,pv will show [bound]. Why is the pvc still Bound? That's bug in Kubernetes 1.2, it will be fixed in 1.3. Both PV and PVC should get Bound eventually. However, deleting a bound PV is very bad idea, as the PVC may be used in a running pod and the pod suddenly looses storage underneath. You should never touch bound PVs! I also observed that creating the pv after the pvc makes the pvc wait forever with Pending status It won't wait forever, it should get bound after 10 minutes. Use kube-controller-manager --pvclaimbinder-sync-period=15s to shorten it to 15 seconds. Again, this will be better in Kubernetes 1.3, 15 seconds will be default there.
I have the following pvc (Persistent Volume Claim): piVersion: v1 kind: PersistentVolumeClaim metadata: name: test-claim-web spec: accessModes: - ReadWriteOnce resources: requests: storage: 10Gi and the Google Cloud-backed pv (Persistent Volume): apiVersion: v1 kind: PersistentVolume metadata: name: test-pv-1 spec: capacity: storage: 10Gi accessModes: - ReadWriteOnce gcePersistentDisk: pdName: test-1 fsType: ext4 and the Disk in Google cloud that exists. If I create first the pv and after the pvc, kubectl get pvc,pv will show: NAME STATUS VOLUME CAPACITY ACCESSMODES AGE test-claim-web Bound test-pv-1 10Gi RWO 15s NAME CAPACITY ACCESSMODES STATUS CLAIM REASON AGE test-pv-1 10Gi RWO Bound default/test-claim-web 25s But if I delete and recreate the pv, kubectl get pvc,pv will show: NAME STATUS VOLUME CAPACITY ACCESSMODES AGE test-claim-web Bound test-pv-1 10Gi RWO 3m NAME CAPACITY ACCESSMODES STATUS CLAIM REASON AGE test-pv-1 10Gi RWO Available 18s Why is the pvc still Bound? Doesn't the pvc (re-)bind automatically? (I also observed that creating the pv after the pvc makes the pvc wait forever with Pending status.) I use the following Kubernetes version: Client Version: version.Info{Major:"1", Minor:"2", GitVersion:"v1.2.4", GitCommit:"3eed1e3be6848b877ff80a93da3785d9034d0a4f", GitTreeState:"clean"} Server Version: version.Info{Major:"1", Minor:"2", GitVersion:"v1.2.4", GitCommit:"3eed1e3be6848b877ff80a93da3785d9034d0a4f", GitTreeState:"clean"}
You should use volumes to map a directory in the container to persistent disks on the host or other storage
###Instruction: I'm newbie at kubernetes and I'm having problem to understand how I can run persistent pods (Cassandras ones or mysql ones) in ubuntu servers. Correct me if I'm wrong, kubernetes can scale up or down the pods when it sees that we need more CPU but we are not talking about static code but data that are present in other nodes. So what will do the pod when it receive the request from the balancer? Also, kubernetes has the power to destroy nodes when it sees that the traffic has reduced, so how we can not lose data and not disturb the environment? ### Response: You should use volumes to map a directory in the container to persistent disks on the host or other storage
I'm newbie at kubernetes and I'm having problem to understand how I can run persistent pods (Cassandras ones or mysql ones) in ubuntu servers. Correct me if I'm wrong, kubernetes can scale up or down the pods when it sees that we need more CPU but we are not talking about static code but data that are present in other nodes. So what will do the pod when it receive the request from the balancer? Also, kubernetes has the power to destroy nodes when it sees that the traffic has reduced, so how we can not lose data and not disturb the environment?
Mesos is another abstraction layer. It simply abstracts underlying hardware so the software that want to run on the top of it could only define required resources without having to know any other information. Kubernetes could do similar thing but without abstraction provided by Mesos you can't run other frameworks (e.g., Spark or Cassandra) on same machine without manually dividing it between those frameworks.
###Instruction: What's the difference between Apache's Mesos and Google's Kubernetes I read the accepted answers but I'm still confused what the differences are. If Kubernetes is a cluster management then what does Mesos do (I understand what it does from watching bunch of videos but I suppose I'm more confused how those two work together)? From reading both Kubernetes and Marathon are "framework" sitting on top of Mesos? What is Mesos responsible for and what are Kubernetes/Marathon responsible for and how do they work with each other? EDIT: I think the better question is When would I want to use Kubernetes on top of Mesos vs just running Mesos alone? ### Response: Mesos is another abstraction layer. It simply abstracts underlying hardware so the software that want to run on the top of it could only define required resources without having to know any other information. Kubernetes could do similar thing but without abstraction provided by Mesos you can't run other frameworks (e.g., Spark or Cassandra) on same machine without manually dividing it between those frameworks.
What's the difference between Apache's Mesos and Google's Kubernetes I read the accepted answers but I'm still confused what the differences are. If Kubernetes is a cluster management then what does Mesos do (I understand what it does from watching bunch of videos but I suppose I'm more confused how those two work together)? From reading both Kubernetes and Marathon are "framework" sitting on top of Mesos? What is Mesos responsible for and what are Kubernetes/Marathon responsible for and how do they work with each other? EDIT: I think the better question is When would I want to use Kubernetes on top of Mesos vs just running Mesos alone?
The problem is that some ubuntu (and others) distro come with the google cloud SDK installed through the local package manager, but it doesn't contain everything. kubectl for example is missing as seen with this command: gcloud components list when you try to add the needed component for Kubernetes with: gcloud components install kubectl you end up with this error: ERROR: (gcloud.components.update) The component manager is disabled for this installation It is a known issue on the Google Cloud SDK issue tracker : Issue 336: kubectl not installed by google-cloud-sdk debian package, and not installable Unfortunately, it provides a poor experience for first timer testing kubernetes as it's hard to find a quick AND CLEAN step by step solution. Here is one: sudo apt-get update sudo apt-get remove google-cloud-sdk curl https://sdk.cloud.google.com | bash exec -l $SHELL gcloud init gcloud components list gcloud components install kubectl gcloud components list this last command should show kubectl installed and everything up to date.
###Instruction: Can any one help me understanding this error I am getting while trying to set-up kubernetes. I am trying to follow this url and run the command $ curl -sS https://get.k8s.io | bash ERROR: (gcloud.components.update) The component manager is disabled for this installation I am running the command on google compute Ubuntu machine. Appreciate any help Adding the complete error ( Ubunut 15.4), after full blown google sdk installation ............. Unpacking kubernetes release v1.0.3 Creating a kubernetes on gce... Starting cluster using provider: gce ... calling verify-prereqs You cannot perform this action because the component manager has been disabled for this installation. If you would like get the latest version of the Google Cloud SDK, please see our main download page at: https://developers.google.com/cloud/sdk/ ERROR: (gcloud.components.update) The component manager is disabled for this installation You cannot perform this action because the component manager has been disabled for this installation. If you would like get the latest version of the Google Cloud SDK, please see our main download page at: https://developers.google.com/cloud/sdk/ ERROR: (gcloud.components.update) The component manager is disabled for this installation You cannot perform this action because the component manager has been disabled for this installation. If you would like get the latest version of the Google Cloud SDK, please see our main download page at: https://developers.google.com/cloud/sdk/ ERROR: (gcloud.components.update) The component manager is disabled for this installation ... calling kube-up ### Response: The problem is that some ubuntu (and others) distro come with the google cloud SDK installed through the local package manager, but it doesn't contain everything. kubectl for example is missing as seen with this command: gcloud components list when you try to add the needed component for Kubernetes with: gcloud components install kubectl you end up with this error: ERROR: (gcloud.components.update) The component manager is disabled for this installation It is a known issue on the Google Cloud SDK issue tracker : Issue 336: kubectl not installed by google-cloud-sdk debian package, and not installable Unfortunately, it provides a poor experience for first timer testing kubernetes as it's hard to find a quick AND CLEAN step by step solution. Here is one: sudo apt-get update sudo apt-get remove google-cloud-sdk curl https://sdk.cloud.google.com | bash exec -l $SHELL gcloud init gcloud components list gcloud components install kubectl gcloud components list this last command should show kubectl installed and everything up to date.
Can any one help me understanding this error I am getting while trying to set-up kubernetes. I am trying to follow this url and run the command $ curl -sS https://get.k8s.io | bash ERROR: (gcloud.components.update) The component manager is disabled for this installation I am running the command on google compute Ubuntu machine. Appreciate any help Adding the complete error ( Ubunut 15.4), after full blown google sdk installation ............. Unpacking kubernetes release v1.0.3 Creating a kubernetes on gce... Starting cluster using provider: gce ... calling verify-prereqs You cannot perform this action because the component manager has been disabled for this installation. If you would like get the latest version of the Google Cloud SDK, please see our main download page at: https://developers.google.com/cloud/sdk/ ERROR: (gcloud.components.update) The component manager is disabled for this installation You cannot perform this action because the component manager has been disabled for this installation. If you would like get the latest version of the Google Cloud SDK, please see our main download page at: https://developers.google.com/cloud/sdk/ ERROR: (gcloud.components.update) The component manager is disabled for this installation You cannot perform this action because the component manager has been disabled for this installation. If you would like get the latest version of the Google Cloud SDK, please see our main download page at: https://developers.google.com/cloud/sdk/ ERROR: (gcloud.components.update) The component manager is disabled for this installation ... calling kube-up
Figured out the answer, documenting here for anyone else having the same issue with ABAC. The kubelet user is define in the worker configuration, which in my case is a yaml file which i store here - /etc/kubernetes/worker-kubeconfig.yaml, the content of which is shown below: apiVersion: v1 kind: Config clusters: - name: default cluster: server: https://10.96.17.34:8443 certificate-authority: /etc/kubernetes/ssl/ca.pem users: - name: kubelet user: client-certificate: /etc/kubernetes/ssl/worker.pem client-key: /etc/kubernetes/ssl/worker-key.pem contexts: - context: cluster: default user: kubelet name: kubelet-context current-context: kubelet-context So the user it's connecting with is kubelet. In my case I had create my certificates with the CN=${MINION_FQDN}, and since this did not match "kubelet" then the ABAC policies weren't met. I regenerated my certifcates with the following arguments and now the nodes authenticate succesfully :) # Create worker key openssl genrsa -out $OUT/${WORKER_HOSTNAME}/worker-key.pem 2048 #Creating Worker CSR... WORKER_FQDN=${WORKER_FQDN} WORKER_IP=${WORKER_IP} openssl req -new -key $OUT/${WORKER_HOSTNAME}/worker-key.pem -out $OUT/${WORKER_HOSTNAME}/worker.csr -subj "/CN=kubelet" -config $SSL_CONFIG # Creating Worker Cert WORKER_FQDN=${WORKER_FQDN} WORKER_IP=${WORKER_IP} openssl x509 -req -in $OUT/${WORKER_HOSTNAME}/worker.csr -CA $CA/ca.pem -CAkey $CA/ca-key.pem -CAcreateserial -out $OUT/${WORKER_HOSTNAME}/worker.pem -days 365 -extensions v3_req -extfile $SSL_CONFIG The important part of which is this: -subj "/CN=kubelet" Hope this helps someone else.
###Instruction: So I've been trying to implement ABAC authorization in the kubernetes API, with the following arguments in my kube-api manifest file. - --authorization-mode=ABAC - --authorization-policy-file=/etc/kubernetes/auth/abac-rules.json And the following content in the abac-rulse.json file. {"apiVersion": "abac.authorization.kubernetes.io/v1beta1", "kind": "Policy", "spec": {"user":"*", "nonResourcePath": "*", "readonly": true}} {"apiVersion": "abac.authorization.kubernetes.io/v1beta1", "kind": "Policy", "spec": {"user":"admin", "namespace": "*", "resource": "*", "apiGroup": "*" }} {"apiVersion": "abac.authorization.kubernetes.io/v1beta1", "kind": "Policy", "spec": {"user":"scheduler", "apiGroup": "*", "namespace": "*", "resource": "*", "readonly": false}} {"apiVersion": "abac.authorization.kubernetes.io/v1beta1", "kind": "Policy", "spec": {"user":"kubelet", "apiGroup": "*", "namespace": "*", "resource": "*", "readonly": false }} However, the kubelets can't seem to connect to the api servers. I read that the username is taken from the CN field of the -subject in the certificate used to authenticate the connection, see here. In this case that's the fqdn of the hose, i've tried that too with no luck. Any ideas what i'm doing wrong? Cheers in advance Edit: I'm using Kubernetes version 1.2.2, both kubectl and hyperkube docker image. ### Response: Figured out the answer, documenting here for anyone else having the same issue with ABAC. The kubelet user is define in the worker configuration, which in my case is a yaml file which i store here - /etc/kubernetes/worker-kubeconfig.yaml, the content of which is shown below: apiVersion: v1 kind: Config clusters: - name: default cluster: server: https://10.96.17.34:8443 certificate-authority: /etc/kubernetes/ssl/ca.pem users: - name: kubelet user: client-certificate: /etc/kubernetes/ssl/worker.pem client-key: /etc/kubernetes/ssl/worker-key.pem contexts: - context: cluster: default user: kubelet name: kubelet-context current-context: kubelet-context So the user it's connecting with is kubelet. In my case I had create my certificates with the CN=${MINION_FQDN}, and since this did not match "kubelet" then the ABAC policies weren't met. I regenerated my certifcates with the following arguments and now the nodes authenticate succesfully :) # Create worker key openssl genrsa -out $OUT/${WORKER_HOSTNAME}/worker-key.pem 2048 #Creating Worker CSR... WORKER_FQDN=${WORKER_FQDN} WORKER_IP=${WORKER_IP} openssl req -new -key $OUT/${WORKER_HOSTNAME}/worker-key.pem -out $OUT/${WORKER_HOSTNAME}/worker.csr -subj "/CN=kubelet" -config $SSL_CONFIG # Creating Worker Cert WORKER_FQDN=${WORKER_FQDN} WORKER_IP=${WORKER_IP} openssl x509 -req -in $OUT/${WORKER_HOSTNAME}/worker.csr -CA $CA/ca.pem -CAkey $CA/ca-key.pem -CAcreateserial -out $OUT/${WORKER_HOSTNAME}/worker.pem -days 365 -extensions v3_req -extfile $SSL_CONFIG The important part of which is this: -subj "/CN=kubelet" Hope this helps someone else.
So I've been trying to implement ABAC authorization in the kubernetes API, with the following arguments in my kube-api manifest file. - --authorization-mode=ABAC - --authorization-policy-file=/etc/kubernetes/auth/abac-rules.json And the following content in the abac-rulse.json file. {"apiVersion": "abac.authorization.kubernetes.io/v1beta1", "kind": "Policy", "spec": {"user":"*", "nonResourcePath": "*", "readonly": true}} {"apiVersion": "abac.authorization.kubernetes.io/v1beta1", "kind": "Policy", "spec": {"user":"admin", "namespace": "*", "resource": "*", "apiGroup": "*" }} {"apiVersion": "abac.authorization.kubernetes.io/v1beta1", "kind": "Policy", "spec": {"user":"scheduler", "apiGroup": "*", "namespace": "*", "resource": "*", "readonly": false}} {"apiVersion": "abac.authorization.kubernetes.io/v1beta1", "kind": "Policy", "spec": {"user":"kubelet", "apiGroup": "*", "namespace": "*", "resource": "*", "readonly": false }} However, the kubelets can't seem to connect to the api servers. I read that the username is taken from the CN field of the -subject in the certificate used to authenticate the connection, see here. In this case that's the fqdn of the hose, i've tried that too with no luck. Any ideas what i'm doing wrong? Cheers in advance Edit: I'm using Kubernetes version 1.2.2, both kubectl and hyperkube docker image.
If you don't want to use a LoadBalancer service, other options for exposing your service publicly are: Type NodePort Create your service with type set to NodePort, and Kubernetes will allocate a port on all of your node VMs on which your service will be exposed (docs). E.g. if you have 2 nodes, w/ public IPs 12.34.56.78 and 23.45.67.89, and Kubernetes assigns your service port 31234, then the service will be available publicly on both 12.34.56.78:31234 & 23.45.67.89:31234 Specify externalIPs If you have the ability to route public IPs to your nodes, you can specify externalIPs in your service to tell Kubernetes "If you see something come in destined for that IP w/ my service port, route it to me." (docs) The cluster endpoint won't work for this because that is only the IP of your Kubernetes master. The public IP of another LoadBalancer service won't work because the LoadBalancer is only configured to route the port of that original service. I'd expect the node IP to work, but it may conflict if your service port is a privileged port. Use the /proxy/ endpoint The Kubernetes API includes a /proxy/ endpoint that allows you to access services on the cluster endpoint IP. E.g. if your cluster endpoint is 1.2.3.4, you could reach my-service in namespace my-ns by accessing https://1.2.3.4/api/v1/proxy/namespaces/my-ns/services/my-service with your cluster credentials. This should really only be used for testing/debugging, as it takes all traffic through your Kubernetes master on the way to the service (extra hops, SPOF, etc.).
###Instruction: I would like to avoid using type: "LoadBalancer" for a certain Kubernetes Service, but still to be able to publish it on the Internet. I am using Google Cloud Platform (GCP) to run a Kubernetes cluster currently running on a single node. I tried to us the externalIPs Service configuration and to give at turns, the IPs of: the instance hosting the Kubernetes cluster (External IP; which also conincides with the IP address of the Kubernetes node as reported by kubernetes describe node) the Kubernetes cluster endpoint (as reported by the Google Cloud Console in the details of the cluster) the public/external IP of another Kubernetes Service of type LoadBalancer running on the same node. None of the above helped me reach my application using the Kubernetes Service with an externalIPs configuration. So, how can I publish a service on the Internet without using a LoadBalancer-type Kubernetes Service. ### Response: If you don't want to use a LoadBalancer service, other options for exposing your service publicly are: Type NodePort Create your service with type set to NodePort, and Kubernetes will allocate a port on all of your node VMs on which your service will be exposed (docs). E.g. if you have 2 nodes, w/ public IPs 12.34.56.78 and 23.45.67.89, and Kubernetes assigns your service port 31234, then the service will be available publicly on both 12.34.56.78:31234 & 23.45.67.89:31234 Specify externalIPs If you have the ability to route public IPs to your nodes, you can specify externalIPs in your service to tell Kubernetes "If you see something come in destined for that IP w/ my service port, route it to me." (docs) The cluster endpoint won't work for this because that is only the IP of your Kubernetes master. The public IP of another LoadBalancer service won't work because the LoadBalancer is only configured to route the port of that original service. I'd expect the node IP to work, but it may conflict if your service port is a privileged port. Use the /proxy/ endpoint The Kubernetes API includes a /proxy/ endpoint that allows you to access services on the cluster endpoint IP. E.g. if your cluster endpoint is 1.2.3.4, you could reach my-service in namespace my-ns by accessing https://1.2.3.4/api/v1/proxy/namespaces/my-ns/services/my-service with your cluster credentials. This should really only be used for testing/debugging, as it takes all traffic through your Kubernetes master on the way to the service (extra hops, SPOF, etc.).
I would like to avoid using type: "LoadBalancer" for a certain Kubernetes Service, but still to be able to publish it on the Internet. I am using Google Cloud Platform (GCP) to run a Kubernetes cluster currently running on a single node. I tried to us the externalIPs Service configuration and to give at turns, the IPs of: the instance hosting the Kubernetes cluster (External IP; which also conincides with the IP address of the Kubernetes node as reported by kubernetes describe node) the Kubernetes cluster endpoint (as reported by the Google Cloud Console in the details of the cluster) the public/external IP of another Kubernetes Service of type LoadBalancer running on the same node. None of the above helped me reach my application using the Kubernetes Service with an externalIPs configuration. So, how can I publish a service on the Internet without using a LoadBalancer-type Kubernetes Service.
In CoreOS the /usr partition is read-only by design, so /usr/local/bin/ will be read-only too (unless you mount another disk there). This allows for the auto-updating CoreOS uses to keep the OS current. You can see the partition layout here. You can install your binaries, etc. in another partition. I usually use /opt/ for this purpose. You can either mount another disk on /opt/ or rely on the fact that / is read-write, depending on your use case, size of files installed, etc.
###Instruction: When moving file to /usr/local/bin it says: mv: inter-device move failed: 'kubectl' to '/usr/local/bin/kubectl'; unable to remove target: Read-only file system I already try chmod How can the CoreOS directory be made writable? ### Response: In CoreOS the /usr partition is read-only by design, so /usr/local/bin/ will be read-only too (unless you mount another disk there). This allows for the auto-updating CoreOS uses to keep the OS current. You can see the partition layout here. You can install your binaries, etc. in another partition. I usually use /opt/ for this purpose. You can either mount another disk on /opt/ or rely on the fact that / is read-write, depending on your use case, size of files installed, etc.
When moving file to /usr/local/bin it says: mv: inter-device move failed: 'kubectl' to '/usr/local/bin/kubectl'; unable to remove target: Read-only file system I already try chmod How can the CoreOS directory be made writable?
it turns out that Stackdriver had a problem of not properly displaying new-ish clusters in its UI. Metrics were being properly collected and were available via their API the entire time. The problem should now be resolved, but the team is very sorry for any trouble this caused and will work to catch problems like this more quickly.
###Instruction: My GKE clusters are not monitored by Stackdriver, despite having Cloud Monitoring enabled. In particular https://app.google.stackdriver.com/gke simply reports "You do not have any resources of this type being monitored by Stackdriver". Clusters running Kubernetes 1.2.4, created in mid-May 2016. Some had Cloud Monitoring enabled on creation, some had it enabled via gcloud container clusters update serve --monitoring-service=monitoring.googleapis.com. All clusters are running the heapster pod with 2/2 ready, status of Running, no restarts e.g. as heapster-v1.0.2-594732231-76sdj. All clusters are running the heapster service with a cluster IP, no external IP and port 80/TCP. Logs of heapster pod, heapster container look like: I0609 09:15:05.000189 1 manager.go:79] Scraping metrics start: 2016-06-09 09:14:00 +0000 UTC, end: 2016-06-09 09:15:00 +0000 UTC I0609 09:15:05.023729 1 manager.go:152] ScrapeMetrics: time: 23.435264ms size: 25 Logs of heapster pod, heapster-nanny container look like: I0609 09:18:03.968201 1 nanny_lib.go:90] The number of nodes is 1 I0609 09:18:03.971459 1 nanny_lib.go:98] The container resources are &{map[memory:{213909504.000000000 BinarySI} cpu:{0.100000000 DecimalSI}] map[cpu:{0.100000000 DecimalSI} memory:{213909504.000000000 BinarySI}]} I0609 09:18:03.971522 1 nanny_lib.go:102] The expected resources are &{map[cpu:{0.100000000 DecimalSI} memory:{218103808.000000000 BinarySI}] map[cpu:{0.100000000 DecimalSI} memory:{218103808.000000000 BinarySI}]} I0609 09:18:03.971634 1 nanny_lib.go:106] Resources are within the expected limits. https://status.cloud.google.com shows all services green. ### Response: it turns out that Stackdriver had a problem of not properly displaying new-ish clusters in its UI. Metrics were being properly collected and were available via their API the entire time. The problem should now be resolved, but the team is very sorry for any trouble this caused and will work to catch problems like this more quickly.
My GKE clusters are not monitored by Stackdriver, despite having Cloud Monitoring enabled. In particular https://app.google.stackdriver.com/gke simply reports "You do not have any resources of this type being monitored by Stackdriver". Clusters running Kubernetes 1.2.4, created in mid-May 2016. Some had Cloud Monitoring enabled on creation, some had it enabled via gcloud container clusters update serve --monitoring-service=monitoring.googleapis.com. All clusters are running the heapster pod with 2/2 ready, status of Running, no restarts e.g. as heapster-v1.0.2-594732231-76sdj. All clusters are running the heapster service with a cluster IP, no external IP and port 80/TCP. Logs of heapster pod, heapster container look like: I0609 09:15:05.000189 1 manager.go:79] Scraping metrics start: 2016-06-09 09:14:00 +0000 UTC, end: 2016-06-09 09:15:00 +0000 UTC I0609 09:15:05.023729 1 manager.go:152] ScrapeMetrics: time: 23.435264ms size: 25 Logs of heapster pod, heapster-nanny container look like: I0609 09:18:03.968201 1 nanny_lib.go:90] The number of nodes is 1 I0609 09:18:03.971459 1 nanny_lib.go:98] The container resources are &{map[memory:{213909504.000000000 BinarySI} cpu:{0.100000000 DecimalSI}] map[cpu:{0.100000000 DecimalSI} memory:{213909504.000000000 BinarySI}]} I0609 09:18:03.971522 1 nanny_lib.go:102] The expected resources are &{map[cpu:{0.100000000 DecimalSI} memory:{218103808.000000000 BinarySI}] map[cpu:{0.100000000 DecimalSI} memory:{218103808.000000000 BinarySI}]} I0609 09:18:03.971634 1 nanny_lib.go:106] Resources are within the expected limits. https://status.cloud.google.com shows all services green.
Kafka register to zookeeper with its service's name. And consuming/producing messages need access to the service names(here is dns records on zookeeper-1, zookeeper-2, zookeeper-3), which are only accessible through kubernetes' dns. So only application running on kubernetes can access my kafka. Therefore I cannot use the external IP of kafka-service or port-forwarding the kafka pod to localhost and then access it. But why can I create, list and describe topics outside kubernetes cluster? I guess it is because zookeepers can do those operation by themselves. But consuming/producing message will need access to the ADVERTISED_HOST_NAME provided by kafka.
###Instruction: I run 1 kafka and 3 zookeeper-server in docker on kubernetes following this instruction. I cannot produce/consume topics outside pod(docker container). bin/kafka-console-producer.sh --broker-list 1.2.3.4:9092 --topic [2016-06-11 15:14:46,889] ERROR Error when sending message to topic test with key: null, value: 3 bytes with error: (org.apache.kafka.clients.producer.internals.ErrorLoggingCallback) org.apache.kafka.common.errors.TimeoutException: Batch containing 3 record(s) expired due to timeout while requesting metadata from brokers for test-0 bin/kafka-console-consumer.sh --zookeeper 5.6.7.8:2181 --topic test --from-beginning [2016-06-11 15:15:58,985] WARN Fetching topic metadata with correlation id 0 for topics [Set(test)] from broker [BrokerEndPoint(1001,kafka-service,9092)] failed (kafka.client.ClientUtils$) java.nio.channels.ClosedChannelException at kafka.network.BlockingChannel.send(BlockingChannel.scala:110) at kafka.producer.SyncProducer.liftedTree1$1(SyncProducer.scala:80) at kafka.producer.SyncProducer.kafka$producer$SyncProducer$$doSend(SyncProducer.scala:79) at kafka.producer.SyncProducer.send(SyncProducer.scala:124) at kafka.client.ClientUtils$.fetchTopicMetadata(ClientUtils.scala:59) at kafka.client.ClientUtils$.fetchTopicMetadata(ClientUtils.scala:94) at kafka.consumer.ConsumerFetcherManager$LeaderFinderThread.doWork(ConsumerFetcherManager.scala:66) at kafka.utils.ShutdownableThread.run(ShutdownableThread.scala:63) [2016-06-11 15:15:58,992] WARN [console-consumer-66869_tattoo-NV49C-1465629357799-ce1529da-leader-finder-thread], Failed to find leader for Set([test,0]) (kafka.consumer.ConsumerFetcherManager$LeaderFinderThread) kafka.common.KafkaException: fetching topic metadata for topics [Set(test)] from broker [ArrayBuffer(BrokerEndPoint(1001,kafka-service,9092))] failed at kafka.client.ClientUtils$.fetchTopicMetadata(ClientUtils.scala:73) at kafka.client.ClientUtils$.fetchTopicMetadata(ClientUtils.scala:94) at kafka.consumer.ConsumerFetcherManager$LeaderFinderThread.doWork(ConsumerFetcherManager.scala:66) at kafka.utils.ShutdownableThread.run(ShutdownableThread.scala:63) Caused by: java.nio.channels.ClosedChannelException at kafka.network.BlockingChannel.send(BlockingChannel.scala:110) at kafka.producer.SyncProducer.liftedTree1$1(SyncProducer.scala:80) at kafka.producer.SyncProducer.kafka$producer$SyncProducer$$doSend(SyncProducer.scala:79) at kafka.producer.SyncProducer.send(SyncProducer.scala:124) at kafka.client.ClientUtils$.fetchTopicMetadata(ClientUtils.scala:59) ... 3 more kafka log: [2016-06-11 07:47:58,269] INFO [Kafka Server 1001], started (kafka.server.KafkaServer) [2016-06-11 07:53:50,404] INFO [ReplicaFetcherManager on broker 1001] Removed fetcher for partitions [test,0] (kafka. server.ReplicaFetcherManager) [2016-06-11 07:53:50,443] INFO Completed load of log test-0 with log end offset 0 (kafka.log.Log) [2016-06-11 07:53:50,458] INFO Created log for partition [test,0] in /kafka/kafka-logs-kafka-controller-3rsv3 with properties {compression.type -> producer, message.format.version -> 0.10.0-IV1, file.delete.delay.ms -> 60000, max. message.bytes -> 1000012, message.timestamp.type -> CreateTime, min.insync.replicas -> 1, segment.jitter.ms -> 0, preallocate -> false, min.cleanable.dirty.ratio -> 0.5, index.interval.bytes -> 4096, unclean.leader.election.enable -> true, retention.bytes -> -1, delete.retention.ms -> 86400000, cleanup.policy -> delete, flush.ms -> 9223372036854775807, segment.ms -> 604800000, segment.bytes -> 1073741824, retention.ms -> 604800000, message. timestamp.difference.max.ms -> 9223372036854775807, segment.index.bytes -> 10485760, flush.messages -> 9223372036854775807}. (kafka.log.LogManager) [2016-06-11 07:53:50,459] INFO Partition [test,0] on broker 1001: No checkpointed highwatermark is found for partition [test,0] (kafka.cluster.Partition) [2016-06-11 07:57:57,955] INFO [Group Metadata Manager on Broker 1001]: Removed 0 expired offsets in 0 milliseconds. ( kafka.coordinator.GroupMetadataManager) And the config/server.properties broker.id=-1 log.dirs=/kafka/kafka-logs-kafka-controller-3rsv3 num.partitions=1 zookeeper.connect=zookeeper-1:2181,zookeeper-2:2181,zookeeper-3:2181 zookeeper.connection.timeout.ms=6000 service.port.9092.tcp.addr=10.254.68.65 service.port.9092.tcp.proto=tcp service.service.port.kafka.port=9092 service.service.port=9092 service.port=tcp://10.254.68.65:9092 service.port.9092.tcp.port=9092 version=0.10.0.0 service.service.host=10.254.68.65 port=9092 advertised.host.name=kafka-service service.port.9092.tcp=tcp://10.254.68.65:9092 advertised.port=9092 But I can do bin/kafka-console-producer.sh --broker-list localhost:9092 --topic and bin/kafka-console-consumer.sh --zookeeper 5.6.7.8:2181 --topic test --from-beginning if I am inside the pod (docker container). And I can create and list topics normally when connecting to zookeeper's service: bin/kafka-topics.sh --describe --zookeeper 5.6.7.8:2181 --topic test Topic:test PartitionCount:1 ReplicationFactor:1 Configs: Topic: test Partition: 0 Leader: 1001 Replicas: 1001 Isr: 1001 And my yaml file for creating kafka replicaiton-congtroller and service: --- apiVersion: v1 kind: Service metadata: name: kafka-service2 labels: app: kafka2 spec: clusterIP: None ports: - port: 9092 name: kafka-port targetPort: 9092 protocol: TCP selector: app: kafka2 --- apiVersion: v1 kind: ReplicationController metadata: name: kafka-controller2 spec: replicas: 1 selector: app: kafka2 template: metadata: labels: app: kafka2 spec: containers: - name: kafka2 image: wurstmeister/kafka ports: - containerPort: 9092 env: - name: KAFKA_ADVERTISED_PORT value: "9092" - name: KAFKA_ADVERTISED_HOST_NAME value: kafka-service2 - name: KAFKA_ZOOKEEPER_CONNECT value: zoo1:2181,zoo2:2181,zoo3:2181 ### Response: Kafka register to zookeeper with its service's name. And consuming/producing messages need access to the service names(here is dns records on zookeeper-1, zookeeper-2, zookeeper-3), which are only accessible through kubernetes' dns. So only application running on kubernetes can access my kafka. Therefore I cannot use the external IP of kafka-service or port-forwarding the kafka pod to localhost and then access it. But why can I create, list and describe topics outside kubernetes cluster? I guess it is because zookeepers can do those operation by themselves. But consuming/producing message will need access to the ADVERTISED_HOST_NAME provided by kafka.
I run 1 kafka and 3 zookeeper-server in docker on kubernetes following this instruction. I cannot produce/consume topics outside pod(docker container). bin/kafka-console-producer.sh --broker-list 1.2.3.4:9092 --topic [2016-06-11 15:14:46,889] ERROR Error when sending message to topic test with key: null, value: 3 bytes with error: (org.apache.kafka.clients.producer.internals.ErrorLoggingCallback) org.apache.kafka.common.errors.TimeoutException: Batch containing 3 record(s) expired due to timeout while requesting metadata from brokers for test-0 bin/kafka-console-consumer.sh --zookeeper 5.6.7.8:2181 --topic test --from-beginning [2016-06-11 15:15:58,985] WARN Fetching topic metadata with correlation id 0 for topics [Set(test)] from broker [BrokerEndPoint(1001,kafka-service,9092)] failed (kafka.client.ClientUtils$) java.nio.channels.ClosedChannelException at kafka.network.BlockingChannel.send(BlockingChannel.scala:110) at kafka.producer.SyncProducer.liftedTree1$1(SyncProducer.scala:80) at kafka.producer.SyncProducer.kafka$producer$SyncProducer$$doSend(SyncProducer.scala:79) at kafka.producer.SyncProducer.send(SyncProducer.scala:124) at kafka.client.ClientUtils$.fetchTopicMetadata(ClientUtils.scala:59) at kafka.client.ClientUtils$.fetchTopicMetadata(ClientUtils.scala:94) at kafka.consumer.ConsumerFetcherManager$LeaderFinderThread.doWork(ConsumerFetcherManager.scala:66) at kafka.utils.ShutdownableThread.run(ShutdownableThread.scala:63) [2016-06-11 15:15:58,992] WARN [console-consumer-66869_tattoo-NV49C-1465629357799-ce1529da-leader-finder-thread], Failed to find leader for Set([test,0]) (kafka.consumer.ConsumerFetcherManager$LeaderFinderThread) kafka.common.KafkaException: fetching topic metadata for topics [Set(test)] from broker [ArrayBuffer(BrokerEndPoint(1001,kafka-service,9092))] failed at kafka.client.ClientUtils$.fetchTopicMetadata(ClientUtils.scala:73) at kafka.client.ClientUtils$.fetchTopicMetadata(ClientUtils.scala:94) at kafka.consumer.ConsumerFetcherManager$LeaderFinderThread.doWork(ConsumerFetcherManager.scala:66) at kafka.utils.ShutdownableThread.run(ShutdownableThread.scala:63) Caused by: java.nio.channels.ClosedChannelException at kafka.network.BlockingChannel.send(BlockingChannel.scala:110) at kafka.producer.SyncProducer.liftedTree1$1(SyncProducer.scala:80) at kafka.producer.SyncProducer.kafka$producer$SyncProducer$$doSend(SyncProducer.scala:79) at kafka.producer.SyncProducer.send(SyncProducer.scala:124) at kafka.client.ClientUtils$.fetchTopicMetadata(ClientUtils.scala:59) ... 3 more kafka log: [2016-06-11 07:47:58,269] INFO [Kafka Server 1001], started (kafka.server.KafkaServer) [2016-06-11 07:53:50,404] INFO [ReplicaFetcherManager on broker 1001] Removed fetcher for partitions [test,0] (kafka. server.ReplicaFetcherManager) [2016-06-11 07:53:50,443] INFO Completed load of log test-0 with log end offset 0 (kafka.log.Log) [2016-06-11 07:53:50,458] INFO Created log for partition [test,0] in /kafka/kafka-logs-kafka-controller-3rsv3 with properties {compression.type -> producer, message.format.version -> 0.10.0-IV1, file.delete.delay.ms -> 60000, max. message.bytes -> 1000012, message.timestamp.type -> CreateTime, min.insync.replicas -> 1, segment.jitter.ms -> 0, preallocate -> false, min.cleanable.dirty.ratio -> 0.5, index.interval.bytes -> 4096, unclean.leader.election.enable -> true, retention.bytes -> -1, delete.retention.ms -> 86400000, cleanup.policy -> delete, flush.ms -> 9223372036854775807, segment.ms -> 604800000, segment.bytes -> 1073741824, retention.ms -> 604800000, message. timestamp.difference.max.ms -> 9223372036854775807, segment.index.bytes -> 10485760, flush.messages -> 9223372036854775807}. (kafka.log.LogManager) [2016-06-11 07:53:50,459] INFO Partition [test,0] on broker 1001: No checkpointed highwatermark is found for partition [test,0] (kafka.cluster.Partition) [2016-06-11 07:57:57,955] INFO [Group Metadata Manager on Broker 1001]: Removed 0 expired offsets in 0 milliseconds. ( kafka.coordinator.GroupMetadataManager) And the config/server.properties broker.id=-1 log.dirs=/kafka/kafka-logs-kafka-controller-3rsv3 num.partitions=1 zookeeper.connect=zookeeper-1:2181,zookeeper-2:2181,zookeeper-3:2181 zookeeper.connection.timeout.ms=6000 service.port.9092.tcp.addr=10.254.68.65 service.port.9092.tcp.proto=tcp service.service.port.kafka.port=9092 service.service.port=9092 service.port=tcp://10.254.68.65:9092 service.port.9092.tcp.port=9092 version=0.10.0.0 service.service.host=10.254.68.65 port=9092 advertised.host.name=kafka-service service.port.9092.tcp=tcp://10.254.68.65:9092 advertised.port=9092 But I can do bin/kafka-console-producer.sh --broker-list localhost:9092 --topic and bin/kafka-console-consumer.sh --zookeeper 5.6.7.8:2181 --topic test --from-beginning if I am inside the pod (docker container). And I can create and list topics normally when connecting to zookeeper's service: bin/kafka-topics.sh --describe --zookeeper 5.6.7.8:2181 --topic test Topic:test PartitionCount:1 ReplicationFactor:1 Configs: Topic: test Partition: 0 Leader: 1001 Replicas: 1001 Isr: 1001 And my yaml file for creating kafka replicaiton-congtroller and service: --- apiVersion: v1 kind: Service metadata: name: kafka-service2 labels: app: kafka2 spec: clusterIP: None ports: - port: 9092 name: kafka-port targetPort: 9092 protocol: TCP selector: app: kafka2 --- apiVersion: v1 kind: ReplicationController metadata: name: kafka-controller2 spec: replicas: 1 selector: app: kafka2 template: metadata: labels: app: kafka2 spec: containers: - name: kafka2 image: wurstmeister/kafka ports: - containerPort: 9092 env: - name: KAFKA_ADVERTISED_PORT value: "9092" - name: KAFKA_ADVERTISED_HOST_NAME value: kafka-service2 - name: KAFKA_ZOOKEEPER_CONNECT value: zoo1:2181,zoo2:2181,zoo3:2181
Glen, you're hitting https://github.com/kubernetes/kubernetes/issues/19953 There's no good workaround for this. It's fixed by https://github.com/kubernetes/kubernetes/pull/26351 which will be part of the next Kubernetes release (v1.3) scheduled to be released by the end of the June (https://github.com/kubernetes/kubernetes/wiki/Release-1.3).
###Instruction: I've tried running 2 Kubernetes pods on a single-node GKE cluster, sharing a read-only GCE persistent disk, but while one pod successfully runs, the other is stuck in the ContainerCreating state. The container is very simple: FROM debian:jessie CMD ["/bin/sh", "-c", "while true; do ls /mount; sleep 5; done"] The deployment looks like this: apiVersion: extensions/v1beta1 kind: Deployment metadata: name: dumpy spec: replicas: 2 template: metadata: labels: app: dump spec: containers: - name: dump image: gcr.io/myproject/dump volumeMounts: - mountPath: /mount name: dump readOnly: true volumes: - name: dump gcePersistentDisk: pdName: my-disk fsType: ext4 readOnly: true The failed pod reports: Warning FailedMount Unable to mount volumes for pod "xxx". Could not attach GCE PD "my-disk". Timeout waiting for mount paths to be created. FailedSync Error syncing pod, skipping: Could not attach GCE PD "my-disk". Timeout waiting for mount paths to be created. /var/log/kubelet.log reports: gce.go:422] GCE operation failed: googleapi: Error 400: The disk resource 'my-disk' is already being used by 'xxx-123' gce_util.go:187] Error attaching PD "my-disk": googleapi: Error 400: The disk resource 'my-disk' is already being used by 'xxx-123' I believe the Kubernetes documentation explicitly allows this scenario. A feature of PD is that they can be mounted as read-only by multiple consumers simultaneously. This means that you can pre-populate a PD with your dataset and then serve it in parallel from as many pods as you need. What's going on and what's the fix? ### Response: Glen, you're hitting https://github.com/kubernetes/kubernetes/issues/19953 There's no good workaround for this. It's fixed by https://github.com/kubernetes/kubernetes/pull/26351 which will be part of the next Kubernetes release (v1.3) scheduled to be released by the end of the June (https://github.com/kubernetes/kubernetes/wiki/Release-1.3).
I've tried running 2 Kubernetes pods on a single-node GKE cluster, sharing a read-only GCE persistent disk, but while one pod successfully runs, the other is stuck in the ContainerCreating state. The container is very simple: FROM debian:jessie CMD ["/bin/sh", "-c", "while true; do ls /mount; sleep 5; done"] The deployment looks like this: apiVersion: extensions/v1beta1 kind: Deployment metadata: name: dumpy spec: replicas: 2 template: metadata: labels: app: dump spec: containers: - name: dump image: gcr.io/myproject/dump volumeMounts: - mountPath: /mount name: dump readOnly: true volumes: - name: dump gcePersistentDisk: pdName: my-disk fsType: ext4 readOnly: true The failed pod reports: Warning FailedMount Unable to mount volumes for pod "xxx". Could not attach GCE PD "my-disk". Timeout waiting for mount paths to be created. FailedSync Error syncing pod, skipping: Could not attach GCE PD "my-disk". Timeout waiting for mount paths to be created. /var/log/kubelet.log reports: gce.go:422] GCE operation failed: googleapi: Error 400: The disk resource 'my-disk' is already being used by 'xxx-123' gce_util.go:187] Error attaching PD "my-disk": googleapi: Error 400: The disk resource 'my-disk' is already being used by 'xxx-123' I believe the Kubernetes documentation explicitly allows this scenario. A feature of PD is that they can be mounted as read-only by multiple consumers simultaneously. This means that you can pre-populate a PD with your dataset and then serve it in parallel from as many pods as you need. What's going on and what's the fix?
have a look at this example: https://github.com/kubernetes/contrib/tree/master/logging/fluentd-sidecar-es The basic idea is to deploy an additional fluentd container in your pod and share a volume between the containers. The application container writes the logs into the volume and the fluentd container mounts the same volume readonly and feeds the logs to elasticsearch. In the default configuration the log events get a tag like "file.application.log". We evaluate this setup at the moment but we have more application containers with the same logfile name. So there is still work todo.
###Instruction: We are using Kubernetes and we have multiple tomcat/jws containers running on multiple pods. What would be best approach for centralized logging using fluentd, Elasticsearch and Kibana. The main purpose is to get the tomcat logs which are running in pods (example: access.log and catalina.log), also the application log which is deployed on the tomcat. Also we need to differentiate the logs coming from different pods (tomcat container). I followed below link https://access.redhat.com/documentation/en/red-hat-enterprise-linux-atomic-host/7/getting-started-with-containers/chapter-11-using-the-atomic-rsyslog-container-image From this I am only able to get container logs but not able to get tomcat log. -Praveen ### Response: have a look at this example: https://github.com/kubernetes/contrib/tree/master/logging/fluentd-sidecar-es The basic idea is to deploy an additional fluentd container in your pod and share a volume between the containers. The application container writes the logs into the volume and the fluentd container mounts the same volume readonly and feeds the logs to elasticsearch. In the default configuration the log events get a tag like "file.application.log". We evaluate this setup at the moment but we have more application containers with the same logfile name. So there is still work todo.
We are using Kubernetes and we have multiple tomcat/jws containers running on multiple pods. What would be best approach for centralized logging using fluentd, Elasticsearch and Kibana. The main purpose is to get the tomcat logs which are running in pods (example: access.log and catalina.log), also the application log which is deployed on the tomcat. Also we need to differentiate the logs coming from different pods (tomcat container). I followed below link https://access.redhat.com/documentation/en/red-hat-enterprise-linux-atomic-host/7/getting-started-with-containers/chapter-11-using-the-atomic-rsyslog-container-image From this I am only able to get container logs but not able to get tomcat log. -Praveen
Check out Cloud Deployment Manager. It allows you to declaratively create a GKE cluster and then adding resources to the cluster. I'm not sure if it will label the nodes for you. To accomplish that, one option is to create multiple node pools. Each node pool will be automatically labeled with the name of the node pool, which should help you reduce the number of manual kubectl commands that you need to run.
###Instruction: In order to run a load test of an application I’m developing, I’m creating a Google Container Engine (GKE) cluster, create a couple of persistent disks, run a whole bunch of kubectl commands, run my benchmark, save the results, then delete the GKE cluster again. The kubectl commands are responsible for labeling a subset of nodes of the GKE cluster (to guarantee that they only run my application, whereas the benchmark infrastructure is on the remainder of nodes) and creating secrets, replication controllers and services. I’m looking for a way to automate all of this. I know that I could write a custom program which does all of this for me, but I’m wondering if there already is such a program. I’ve briefly looked into https://www.terraform.io/, but it looks like that would only cover the GKE setup, not the Kubernetes resources. Is the way to go to combine terraform and a script which runs kubectl commands? Or are there other tools for orchestrating Kubernetes? ### Response: Check out Cloud Deployment Manager. It allows you to declaratively create a GKE cluster and then adding resources to the cluster. I'm not sure if it will label the nodes for you. To accomplish that, one option is to create multiple node pools. Each node pool will be automatically labeled with the name of the node pool, which should help you reduce the number of manual kubectl commands that you need to run.
In order to run a load test of an application I’m developing, I’m creating a Google Container Engine (GKE) cluster, create a couple of persistent disks, run a whole bunch of kubectl commands, run my benchmark, save the results, then delete the GKE cluster again. The kubectl commands are responsible for labeling a subset of nodes of the GKE cluster (to guarantee that they only run my application, whereas the benchmark infrastructure is on the remainder of nodes) and creating secrets, replication controllers and services. I’m looking for a way to automate all of this. I know that I could write a custom program which does all of this for me, but I’m wondering if there already is such a program. I’ve briefly looked into https://www.terraform.io/, but it looks like that would only cover the GKE setup, not the Kubernetes resources. Is the way to go to combine terraform and a script which runs kubectl commands? Or are there other tools for orchestrating Kubernetes?
i am not sure if you need a dns. you can do something like this, even if the URL is hardcoded eg docker-compose.yml version: '2' services: service1: ... networks: back-tier: ipv4_address: "172.16.238.10" service2: ... networks: back-tier: ipv4_adress: "172.16.238.11" networks: back-tier: driver: bridge ipam: driver: default config: - subnet: 172.16.238.0/24 gateway: 172.16.238.1 you can even set hostnames for each container, etc, you could also make a link between them. if you need it to be circular you can do it with extra_hosts parameter. if should be able to find all the info you need over here: https://docs.docker.com/compose/compose-file/ if the containers are on the same network they should be able to talk to each other
###Instruction: I think this may be an XY problem, so I'll include the context of the question since I don't know the best way to solve this problem. I have a kubernetes environment set up on AWS such that I have two parts, an nginx container, and a backend service (which I'll call SvcA). Since the backend service can come and go, in my nginx config I have something that looks like: resolver kube-dns.kube-system.svc.cluster.local valid=60s ipv6=off; server { # stuff location / { set $backend "SvcA.default.svc.cluster.local:8000"; proxy_pass http://$backend; } } This setup works well on kubernetes, but I want a way have having the (almost) exact same set up on my local machine for testing/development but without all the overhead of using kubernetes. What I want to do is stick these two containers (nginx, SvcA) into a docker-compose file and have it working that way. The problem I've run into, is that the resolver for the nginx is hard-coded to be the url on kubernetes, and the solution I think may work is to have container that is a dns, and it's sole entry is to point "SvcA.default.svc.cluster.local" to the name docker-compose assigns. I'm unsure if this is the best way to solve the problem, and if it is, I don't know enough about DNS configuration to set this up. Is this the best solution to my problem, and if so, how would I configure a dns server to handle this? ### Response: i am not sure if you need a dns. you can do something like this, even if the URL is hardcoded eg docker-compose.yml version: '2' services: service1: ... networks: back-tier: ipv4_address: "172.16.238.10" service2: ... networks: back-tier: ipv4_adress: "172.16.238.11" networks: back-tier: driver: bridge ipam: driver: default config: - subnet: 172.16.238.0/24 gateway: 172.16.238.1 you can even set hostnames for each container, etc, you could also make a link between them. if you need it to be circular you can do it with extra_hosts parameter. if should be able to find all the info you need over here: https://docs.docker.com/compose/compose-file/ if the containers are on the same network they should be able to talk to each other
I think this may be an XY problem, so I'll include the context of the question since I don't know the best way to solve this problem. I have a kubernetes environment set up on AWS such that I have two parts, an nginx container, and a backend service (which I'll call SvcA). Since the backend service can come and go, in my nginx config I have something that looks like: resolver kube-dns.kube-system.svc.cluster.local valid=60s ipv6=off; server { # stuff location / { set $backend "SvcA.default.svc.cluster.local:8000"; proxy_pass http://$backend; } } This setup works well on kubernetes, but I want a way have having the (almost) exact same set up on my local machine for testing/development but without all the overhead of using kubernetes. What I want to do is stick these two containers (nginx, SvcA) into a docker-compose file and have it working that way. The problem I've run into, is that the resolver for the nginx is hard-coded to be the url on kubernetes, and the solution I think may work is to have container that is a dns, and it's sole entry is to point "SvcA.default.svc.cluster.local" to the name docker-compose assigns. I'm unsure if this is the best way to solve the problem, and if it is, I don't know enough about DNS configuration to set this up. Is this the best solution to my problem, and if so, how would I configure a dns server to handle this?
The CoreOS-kubernetes tooling is meant to deploy a fully functioning Kubernetes cluster, but leave optional/ addon applications as a decision for the cluster admin. In this case kibana & grafana are not strictly required for a fully functioning cluster -- so they are not deployed by default. Similarly with authentication, basic-auth is not enabled by default (cert based auth and Bearer tokens are). However, you should be able to add basic auth by creating a file and a adding a flag to the api-server manifest: Create a basic auth file following the format described here: http://kubernetes.io/docs/admin/authentication In /etc/kubernetes/manifests/kube-apiserver.yaml, add a flag pointing to the file you created above --basic-auth-file=SOMEFILE When you make the change to the kube-apiserver.yaml manifest, the kubelet will see the change an automatically restart the pod. If you're running apiservers on multiple hosts, be sure to make the above changes to each. Another option is to use the kubectl proxy command to first authenticate against your api-server. See: http://kubernetes.io/docs/user-guide/connecting-to-applications-proxy - essentially the kubectl proxy will authenticate then allow you to access the endpoint locally on your machine.
###Instruction: I am following the tutorial from Kubernetes on AWS by Coreos (I need a Cloudformation template) to create a Kubernetes inside my already existing VPC. Everything is configured properly and the cluster was successfully setup, but i am experiencing difficulties with Heapster/KubeDNS My cluster info and config view look like this: kubectl --kubeconfig=kubeconfig cluster-info Kubernetes master is running at https://my-cluster-endpoint.company.com. Heapster is running at https://my-cluster-endpoint.company.com./api/v1/proxy/namespaces/kube-system/services/heapster KubeDNS is running at https://my-cluster-endpoint.company.com./api/v1/proxy/namespaces/kube-system/services/kube-dns kubectl --kubeconfig=kubeconfig config view apiVersion: v1 clusters: - cluster: certificate-authority: credentials/ca.pem server: https://my-cluster-endpoint.company.com. name: kube-aws-my-cluster-name-cluster contexts: - context: cluster: kube-aws-my-cluster-name-cluster namespace: default user: kube-aws-my-cluster-name-admin name: kube-aws-my-cluster-name-context current-context: kube-aws-my-cluster-name-context kind: Config preferences: {} users: - name: kube-aws-my-cluster-name-admin user: client-certificate: credentials/admin.pem client-key: credentials/admin-key.pem So a few problems that I notice compared to the getting started guides from kubernetes.io: All the "out of the box" services like Kibana/Grafana are missing (but these you can probably install yourself) There is no "user" section with username and password to enter the dashboards only one with certificate As well when I try to reach these endpoints I immediately get "unauthorised" and the api does not even challenge me for username password So how do I set basic authentication for my newly created cluster OR is there a way to login with the .pem certificate? Thanks. ### Response: The CoreOS-kubernetes tooling is meant to deploy a fully functioning Kubernetes cluster, but leave optional/ addon applications as a decision for the cluster admin. In this case kibana & grafana are not strictly required for a fully functioning cluster -- so they are not deployed by default. Similarly with authentication, basic-auth is not enabled by default (cert based auth and Bearer tokens are). However, you should be able to add basic auth by creating a file and a adding a flag to the api-server manifest: Create a basic auth file following the format described here: http://kubernetes.io/docs/admin/authentication In /etc/kubernetes/manifests/kube-apiserver.yaml, add a flag pointing to the file you created above --basic-auth-file=SOMEFILE When you make the change to the kube-apiserver.yaml manifest, the kubelet will see the change an automatically restart the pod. If you're running apiservers on multiple hosts, be sure to make the above changes to each. Another option is to use the kubectl proxy command to first authenticate against your api-server. See: http://kubernetes.io/docs/user-guide/connecting-to-applications-proxy - essentially the kubectl proxy will authenticate then allow you to access the endpoint locally on your machine.
I am following the tutorial from Kubernetes on AWS by Coreos (I need a Cloudformation template) to create a Kubernetes inside my already existing VPC. Everything is configured properly and the cluster was successfully setup, but i am experiencing difficulties with Heapster/KubeDNS My cluster info and config view look like this: kubectl --kubeconfig=kubeconfig cluster-info Kubernetes master is running at https://my-cluster-endpoint.company.com. Heapster is running at https://my-cluster-endpoint.company.com./api/v1/proxy/namespaces/kube-system/services/heapster KubeDNS is running at https://my-cluster-endpoint.company.com./api/v1/proxy/namespaces/kube-system/services/kube-dns kubectl --kubeconfig=kubeconfig config view apiVersion: v1 clusters: - cluster: certificate-authority: credentials/ca.pem server: https://my-cluster-endpoint.company.com. name: kube-aws-my-cluster-name-cluster contexts: - context: cluster: kube-aws-my-cluster-name-cluster namespace: default user: kube-aws-my-cluster-name-admin name: kube-aws-my-cluster-name-context current-context: kube-aws-my-cluster-name-context kind: Config preferences: {} users: - name: kube-aws-my-cluster-name-admin user: client-certificate: credentials/admin.pem client-key: credentials/admin-key.pem So a few problems that I notice compared to the getting started guides from kubernetes.io: All the "out of the box" services like Kibana/Grafana are missing (but these you can probably install yourself) There is no "user" section with username and password to enter the dashboards only one with certificate As well when I try to reach these endpoints I immediately get "unauthorised" and the api does not even challenge me for username password So how do I set basic authentication for my newly created cluster OR is there a way to login with the .pem certificate? Thanks.
Running pods on the master node is definitely possible. The security risk you mention is one issue, but if you configure service accounts, it isn't actually much different for all deployed pods to have secure remote access to the apiserver vs. insecure local access. Another issue is resource contention. If you run a rogue pod on your master node that disrupts the master components, it can destabilize your entire cluster. Clearly this is a concern for production deployments, but if you are looking to maximize utilization of a small number of nodes in a development / experimentation environment, then it should be fine to run a couple of extra pods on the master. Finally, you need to make sure the master node has a sufficiently large pod cidr allocated to it. In some deployments, the master only gets a /30 which isn't going to allow you to run very many pods.
###Instruction: Many of the run-throughs for deploying Kubernetes master nodes suggest you use --register-schedulable=false to prevent user pods being scheduled to the master node (e.g. https://coreos.com/kubernetes/docs/latest/deploy-master.html). On a very small Kubernetes cluster it seems somewhat a wasteful of compute resources to effectively prevent an entire node from being used for pod scheduling unless absolutely essential. The answer to this question (Will (can) Kubernetes run Docker containers on the master node(s)?) suggests that it is indeed possible to run user pods on a master node - but doesn't address whether there are any issues associated with allowing this. The only information that I've been able to find to date that suggests there might be issues associated with allowing this is that it appears that pods on master nodes communicate insecurely (see http://kubernetes.io/docs/admin/master-node-communication/ and https://github.com/kubernetes/kubernetes/issues/13598). I assume that this would potentially allow a rogue pod running on a master node to access/hijack Kubernetes functionality not normally accessible to pods on non-master nodes. Probably not a big deal with if only running pods/containers developed internally - although I guess there's always the possibility of someone hacking access to a pod/container and thereby gaining access to the master node. Does this sound like a viable potential risk associated with this scenario (allowing user pods to run on a Kubernetes master node)? Are there any other potential issues associated with such a setup? ### Response: Running pods on the master node is definitely possible. The security risk you mention is one issue, but if you configure service accounts, it isn't actually much different for all deployed pods to have secure remote access to the apiserver vs. insecure local access. Another issue is resource contention. If you run a rogue pod on your master node that disrupts the master components, it can destabilize your entire cluster. Clearly this is a concern for production deployments, but if you are looking to maximize utilization of a small number of nodes in a development / experimentation environment, then it should be fine to run a couple of extra pods on the master. Finally, you need to make sure the master node has a sufficiently large pod cidr allocated to it. In some deployments, the master only gets a /30 which isn't going to allow you to run very many pods.
Many of the run-throughs for deploying Kubernetes master nodes suggest you use --register-schedulable=false to prevent user pods being scheduled to the master node (e.g. https://coreos.com/kubernetes/docs/latest/deploy-master.html). On a very small Kubernetes cluster it seems somewhat a wasteful of compute resources to effectively prevent an entire node from being used for pod scheduling unless absolutely essential. The answer to this question (Will (can) Kubernetes run Docker containers on the master node(s)?) suggests that it is indeed possible to run user pods on a master node - but doesn't address whether there are any issues associated with allowing this. The only information that I've been able to find to date that suggests there might be issues associated with allowing this is that it appears that pods on master nodes communicate insecurely (see http://kubernetes.io/docs/admin/master-node-communication/ and https://github.com/kubernetes/kubernetes/issues/13598). I assume that this would potentially allow a rogue pod running on a master node to access/hijack Kubernetes functionality not normally accessible to pods on non-master nodes. Probably not a big deal with if only running pods/containers developed internally - although I guess there's always the possibility of someone hacking access to a pod/container and thereby gaining access to the master node. Does this sound like a viable potential risk associated with this scenario (allowing user pods to run on a Kubernetes master node)? Are there any other potential issues associated with such a setup?
The NodePort is exposed on each Node in your cluster via the kube-proxy service. To connect, use the IP of that host (Node01) to connect to: telnet [IpOfNode] 30306
###Instruction: I'm also trying to expose a mysql server instance on a local kubernetes installation(1 master and one node, both on oracle linux) but I not being able to access to the pod. The pod configuration is this: apiVersion: v1 kind: Pod metadata: name: mysql labels: name: mysql spec: containers: - resources: limits : cpu: 1 image: docker.io/mariadb name: mysql env: - name: MYSQL_ROOT_PASSWORD value: 123456 ports: - containerPort: 3306 name: mysql And the service file: apiVersion: v1 kind: Service metadata: labels: name: mysql name: mysql spec: type: NodePort ports: - port: 3306 targetPort: 3306 nodePort: 30306 selector: name: mysql I can see that the pod is is running: # kubectl get pod mysql NAME READY STATUS RESTARTS AGE mysql 1/1 Running 0 3d And the service is connected to an endpoint: # kubectl describe service mysql Name: mysql Namespace: default Labels: name=mysql Selector: name=mysql Type: NodePort IP: 10.254.200.20 Port: <unset> 3306/TCP NodePort: <unset> 30306/TCP Endpoints: 11.0.14.2:3306 Session Affinity: None No events. I can see on netstat that kube-proxy is listening on port 30306 for all incoming connections. tcp6 6 0 :::30306 :::* LISTEN 53039/kube-proxy But somehow I don't get a response from mysql even on the localhost. # telnet localhost 30306 Trying ::1... Connected to localhost. Escape character is '^]'. Whereas a normal mysql installation responds with something of the following: $ telnet [REDACTED] 3306 Trying [REDACTED]... Connected to [REDACTED]. Escape character is '^]'. N [REDACTED]-log�gw&TS(gS�X]G/Q,(#uIJwmysql_native_password^] Notice the mysql part in the last line. On a final note there is this kubectl output: $ kubectl get service NAME CLUSTER-IP EXTERNAL-IP PORT(S) AGE kubernetes 10.254.0.1 <none> 443/TCP 9d mysql 10.254.200.20 nodes 3306/TCP 1h But I don't understand what "nodes" mean in the EXTERNAL-IP column. So what I want to happen is to open the access to the mysql service through the master IP(preferrably). How do I do that and what am I doing wrong? ### Response: The NodePort is exposed on each Node in your cluster via the kube-proxy service. To connect, use the IP of that host (Node01) to connect to: telnet [IpOfNode] 30306
I'm also trying to expose a mysql server instance on a local kubernetes installation(1 master and one node, both on oracle linux) but I not being able to access to the pod. The pod configuration is this: apiVersion: v1 kind: Pod metadata: name: mysql labels: name: mysql spec: containers: - resources: limits : cpu: 1 image: docker.io/mariadb name: mysql env: - name: MYSQL_ROOT_PASSWORD value: 123456 ports: - containerPort: 3306 name: mysql And the service file: apiVersion: v1 kind: Service metadata: labels: name: mysql name: mysql spec: type: NodePort ports: - port: 3306 targetPort: 3306 nodePort: 30306 selector: name: mysql I can see that the pod is is running: # kubectl get pod mysql NAME READY STATUS RESTARTS AGE mysql 1/1 Running 0 3d And the service is connected to an endpoint: # kubectl describe service mysql Name: mysql Namespace: default Labels: name=mysql Selector: name=mysql Type: NodePort IP: 10.254.200.20 Port: <unset> 3306/TCP NodePort: <unset> 30306/TCP Endpoints: 11.0.14.2:3306 Session Affinity: None No events. I can see on netstat that kube-proxy is listening on port 30306 for all incoming connections. tcp6 6 0 :::30306 :::* LISTEN 53039/kube-proxy But somehow I don't get a response from mysql even on the localhost. # telnet localhost 30306 Trying ::1... Connected to localhost. Escape character is '^]'. Whereas a normal mysql installation responds with something of the following: $ telnet [REDACTED] 3306 Trying [REDACTED]... Connected to [REDACTED]. Escape character is '^]'. N [REDACTED]-log�gw&TS(gS�X]G/Q,(#uIJwmysql_native_password^] Notice the mysql part in the last line. On a final note there is this kubectl output: $ kubectl get service NAME CLUSTER-IP EXTERNAL-IP PORT(S) AGE kubernetes 10.254.0.1 <none> 443/TCP 9d mysql 10.254.200.20 nodes 3306/TCP 1h But I don't understand what "nodes" mean in the EXTERNAL-IP column. So what I want to happen is to open the access to the mysql service through the master IP(preferrably). How do I do that and what am I doing wrong?
I can think of a couple of options that you could pursue: You could have the requests that transit just the cluster run over http instead of https if you trust the security of your cluster network. You could have your HAProxy instance serve a different certificate to internal requests using SNI. You would need a way to generate and distribute the internal certificates, but it would allow you to present the client a certificate that matches the Kubernetes service name. Continue to resolve the FQDN and not worry about routing requests out and then back into the cluster. This actually isn't that different than the upcoming cross-cluster service discovery/federation feature being built into Kubernetes cluster federation. There isn't really a way to inject/overwrite the external FQDN resolution to return the internal service IP.
###Instruction: We're running a lot of applications in Kubernetes and handle TLS termination inside a pod with HAProxy and a certificate generated with LetsEncrypt. This works really well for traffic coming from outside the Kubernetes cluster because the requests use the domain name as specified in the certificate. However for internal communication using the service name - with a url like https:/// - the host part of the url no longer matches what's defined in the certificate, resulting in failure. Is there any way to let Kubernetes' dns system resolve the full domain name to a specific service, so it doesn't get routed outside the cluster? ### Response: I can think of a couple of options that you could pursue: You could have the requests that transit just the cluster run over http instead of https if you trust the security of your cluster network. You could have your HAProxy instance serve a different certificate to internal requests using SNI. You would need a way to generate and distribute the internal certificates, but it would allow you to present the client a certificate that matches the Kubernetes service name. Continue to resolve the FQDN and not worry about routing requests out and then back into the cluster. This actually isn't that different than the upcoming cross-cluster service discovery/federation feature being built into Kubernetes cluster federation. There isn't really a way to inject/overwrite the external FQDN resolution to return the internal service IP.
We're running a lot of applications in Kubernetes and handle TLS termination inside a pod with HAProxy and a certificate generated with LetsEncrypt. This works really well for traffic coming from outside the Kubernetes cluster because the requests use the domain name as specified in the certificate. However for internal communication using the service name - with a url like https:/// - the host part of the url no longer matches what's defined in the certificate, resulting in failure. Is there any way to let Kubernetes' dns system resolve the full domain name to a specific service, so it doesn't get routed outside the cluster?
Today you would probably need to create a ReplicationController for each replica or component in your app. So if you have a 3 node replica of say Postgres, you would create 3 controllers for that. You could look at helm (https://helm.sh/) to help out here as well which has addresses some of this for you up front by automating some of the pieces. There is also a notion of PetSet which is being implemented and addresses this issue more. You can read up on some of those details here: https://github.com/kubernetes/kubernetes/issues/260
###Instruction: I am trying to model stateful component/services (e.g. CouchBase, Postgres, etc) in Kubernetes. In Kubernetes, replication controller object requires a template for pod to cookie cut (replicate) pods. If the pod is for a stateful component, then the template will be required to include the persistent volume claim. If I specify a persistent claim in template of a replication controller, then that might (have not tried it, but logically) result in sharing of persistent volume claim between different pods and as a consequence resulting in conflict between multiple pods. How to assign a different persistent volume claim to each pod when using replication controller for managing pods? How to model stateful components in Kubernetes using replication controller? ### Response: Today you would probably need to create a ReplicationController for each replica or component in your app. So if you have a 3 node replica of say Postgres, you would create 3 controllers for that. You could look at helm (https://helm.sh/) to help out here as well which has addresses some of this for you up front by automating some of the pieces. There is also a notion of PetSet which is being implemented and addresses this issue more. You can read up on some of those details here: https://github.com/kubernetes/kubernetes/issues/260
I am trying to model stateful component/services (e.g. CouchBase, Postgres, etc) in Kubernetes. In Kubernetes, replication controller object requires a template for pod to cookie cut (replicate) pods. If the pod is for a stateful component, then the template will be required to include the persistent volume claim. If I specify a persistent claim in template of a replication controller, then that might (have not tried it, but logically) result in sharing of persistent volume claim between different pods and as a consequence resulting in conflict between multiple pods. How to assign a different persistent volume claim to each pod when using replication controller for managing pods? How to model stateful components in Kubernetes using replication controller?
As Timo mentioned, you can use kubectl create namespace NAME to create a namespace using the command line client. You can also put the following into a yaml file and use kubectl create -f namespace.yaml to create a namespace: apiVersion: v1 kind: Namespace metadata: name: kube-system
###Instruction: The only way to create a new namespace according to documentation here is to make an API request curl -v -X POST -d'{"apiVersion":"v1","kind":"Namespace","metadata":{"name":"kube-system"}}' -H "Content-Type: application/json" "http://127.0.0.1:8080/api/v1/namespaces" Is there any way to do the same using config or cloud-config? ### Response: As Timo mentioned, you can use kubectl create namespace NAME to create a namespace using the command line client. You can also put the following into a yaml file and use kubectl create -f namespace.yaml to create a namespace: apiVersion: v1 kind: Namespace metadata: name: kube-system
The only way to create a new namespace according to documentation here is to make an API request curl -v -X POST -d'{"apiVersion":"v1","kind":"Namespace","metadata":{"name":"kube-system"}}' -H "Content-Type: application/json" "http://127.0.0.1:8080/api/v1/namespaces" Is there any way to do the same using config or cloud-config?
It's not --node-monitor-grace-period=10s --pod-eviction-timeout=10s useless, the point is "controller-manager" didn't load those parameters! I use command /bin/systemctl restart kube-controller-manager.service to start kube-controller-manager, cat "/usr/lib/systemd/system/kube-controller-manager.service" as below: [Unit] Description=Kubernetes Controller Manager Documentation=https://github.com/GoogleCloudPlatform/kubernetes [Service] EnvironmentFile=-/etc/kubernetes/config EnvironmentFile=-/etc/kubernetes/controller-manager User=root ExecStart=/usr/bin/kube-controller-manager --port=10252 --master=http://127.0.0.1:8080 Restart=on-failure LimitNOFILE=65536 [Install] WantedBy=multi-user.target cat /etc/kubernetes/controller-manager as below: ### # The following values are used to configure the kubernetes controller-manager # defaults from config and apiserver should be adequate # Add your own! KUBE_CONTROLLER_MANAGER_ARGS="--node-monitor-grace-period=10s --node-monitor-period=5s --pod-eviction-timeout=5m0s" If I add those parameters in /usr/lib/systemd/system/kube-controller-manager.service like: ExecStart=/usr/bin/kube-controller-manager --port=10252 --master=http://127.0.0.1:8080 --node-monitor-grace-period=10s --node-monitor-period=5s --pod-eviction-timeout=10s It's work! So I don't know why controller-manager didn't load the config file /etc/kubernetes/controller-manager.
###Instruction: My /etc/kubernetes/config as below: KUBE_LOGTOSTDERR="--logtostderr=false" KUBE_LOG_LEVEL="--v=5" KUBE_ALLOW_PRIV="--allow-privileged=false" KUBE_MASTER="--master=http://127.0.0.1:8080 --log-dir=/var/log/kubernetes --stderrthreshold=1" /etc/kubernetes/controller-manager like this:" KUBE_CONTROLLER_MANAGER_ARGS="--port=10252 --node-monitor-grace-period=10s --pod-eviction-timeout=10s --cluster-name=op-k8s" I created one deployment:"dep1" which have only one pod, and this pod deployed in a health node: "test1", then in test1 exec: systemctl stop kubelet.service ;systemctl stop kube-proxy.service ;systemctl stop docker to make an "node shutdown error". About 30s ago node: test1 become NotReady status(kubectl get node in kubemaster machine). But after five minutes that deployment: dep1's pod transfer to a another node. So I have two questions: How can I control the time when one node shutdown the pod in that node transfer to another health node? 2.-pod-eviction-timeout=10s, it seems that there is useless of this parameter cause kubelet is down no one can delete that pod. Thanks! ### Response: It's not --node-monitor-grace-period=10s --pod-eviction-timeout=10s useless, the point is "controller-manager" didn't load those parameters! I use command /bin/systemctl restart kube-controller-manager.service to start kube-controller-manager, cat "/usr/lib/systemd/system/kube-controller-manager.service" as below: [Unit] Description=Kubernetes Controller Manager Documentation=https://github.com/GoogleCloudPlatform/kubernetes [Service] EnvironmentFile=-/etc/kubernetes/config EnvironmentFile=-/etc/kubernetes/controller-manager User=root ExecStart=/usr/bin/kube-controller-manager --port=10252 --master=http://127.0.0.1:8080 Restart=on-failure LimitNOFILE=65536 [Install] WantedBy=multi-user.target cat /etc/kubernetes/controller-manager as below: ### # The following values are used to configure the kubernetes controller-manager # defaults from config and apiserver should be adequate # Add your own! KUBE_CONTROLLER_MANAGER_ARGS="--node-monitor-grace-period=10s --node-monitor-period=5s --pod-eviction-timeout=5m0s" If I add those parameters in /usr/lib/systemd/system/kube-controller-manager.service like: ExecStart=/usr/bin/kube-controller-manager --port=10252 --master=http://127.0.0.1:8080 --node-monitor-grace-period=10s --node-monitor-period=5s --pod-eviction-timeout=10s It's work! So I don't know why controller-manager didn't load the config file /etc/kubernetes/controller-manager.
My /etc/kubernetes/config as below: KUBE_LOGTOSTDERR="--logtostderr=false" KUBE_LOG_LEVEL="--v=5" KUBE_ALLOW_PRIV="--allow-privileged=false" KUBE_MASTER="--master=http://127.0.0.1:8080 --log-dir=/var/log/kubernetes --stderrthreshold=1" /etc/kubernetes/controller-manager like this:" KUBE_CONTROLLER_MANAGER_ARGS="--port=10252 --node-monitor-grace-period=10s --pod-eviction-timeout=10s --cluster-name=op-k8s" I created one deployment:"dep1" which have only one pod, and this pod deployed in a health node: "test1", then in test1 exec: systemctl stop kubelet.service ;systemctl stop kube-proxy.service ;systemctl stop docker to make an "node shutdown error". About 30s ago node: test1 become NotReady status(kubectl get node in kubemaster machine). But after five minutes that deployment: dep1's pod transfer to a another node. So I have two questions: How can I control the time when one node shutdown the pod in that node transfer to another health node? 2.-pod-eviction-timeout=10s, it seems that there is useless of this parameter cause kubelet is down no one can delete that pod. Thanks!
This is embarrassing. Looks like all daemons support a "--kubeconfig" flag that gives access to public and private key for authorization.
###Instruction: Reading the documentation from http://kubernetes.io/docs/admin/kube-proxy/ it doesn't look like I can connect to the apiserver via https. The same goes for scheduler and controller-manager, but those two maybe are supposed to run on the same machine as the apiserver and can connect via localhost. But what about the proxy? This is supposed to connect remotely to the apiserver. Is it possible to configure authentication and/or authorization from the proxy to the apiserver? ### Response: This is embarrassing. Looks like all daemons support a "--kubeconfig" flag that gives access to public and private key for authorization.
Reading the documentation from http://kubernetes.io/docs/admin/kube-proxy/ it doesn't look like I can connect to the apiserver via https. The same goes for scheduler and controller-manager, but those two maybe are supposed to run on the same machine as the apiserver and can connect via localhost. But what about the proxy? This is supposed to connect remotely to the apiserver. Is it possible to configure authentication and/or authorization from the proxy to the apiserver?
One of your DNS containers isn't ready. That's what "Ready 3/4" means. The best bet is to use the kubectl logs <pod> <container> command to get the logs of the container that is failing. You can add kubectl logs --previous ... if you need to get the logs from a container that already failed. Hopefully that will give you the information necessary to debug why that container isn't coming up.
###Instruction: I installed kubernetes 1.2.4 on 3 REHEL7 servers (no internet access, everything is pushed by ansible). EDIT: See the end of the question I've got everything working great excepting the kube-dns example given in documentation. I made several tests, several configuraiton, recreate the entire pods... And I always have this "MissingClusterDNS" error: enter code here20m 20m 2 {kubelet k8s-minion-1.XXXXXX} Warning MissingClusterDNS kubelet does not have ClusterDNS IP configured and cannot create Pod using "ClusterFirst" policy. Falling back to DNSDefault policy. As you can see, kube-dns is running: kubectl get svc kube-dns --namespace=kube-system NAME CLUSTER-IP EXTERNAL-IP PORT(S) AGE kube-dns 172.16.0.99 <none> 53/UDP,53/TCP 15m And kubelete has got correct options KUBELET_ARGS=" --cluster-dns=172.16.0.99 --cluster-domain=kubernetes.local " Proof: ps ax | grep kubelet 6077 ? Ssl 0:07 /opt/kubernetes/bin/kubelet --logtostderr=true --v=0 --address=0.0.0.0 --port=10250 --hostname-override=k8s-minion-1.XXXXXX --api-servers=http://k8s-master.XXXXXX:8080 --allow-privileged=false --cluster-dns=172.16.0.99 --cluster-domain=kubernetes.local But, the DNS pod as a not running container: kubectl get pods --namespace=kube-system NAME READY STATUS RESTARTS AGE kube-dns-v11-f2f4a 3/4 CrashLoopBackOff 7 18m And the log is explicit: Warning Unhealthy Readiness probe failed: Get http://172.16.23.2:8081/readiness: dial tcp 172.16.23.2:8081: connection refused ... Warning FailedSync Error syncing pod, skipping: failed to "StartContainer" for "kube2sky" with CrashLoopBackOff: "Back-off 5m0s restarting failed container=kube2sky pod=kube-dns-v11-f2f4a_kube-system(27d70b7c-36f9-11e6-b4fe-fa163ee85c45)" If you need more information: $ kubectl get pods --namespace=kube-system NAME READY STATUS RESTARTS AGE kube-dns-v11-f2f4a 3/4 CrashLoopBackOff 7 18m ------------------------- $ kubectl describe rc --namespace=kube-system Name: kube-dns-v11 Namespace: kube-system Image(s): our.registry/gcr.io/google_containers/etcd-amd64:2.2.1,our.registry/gcr.io/google_containers/kube2sky:1.14,our.registry/gcr.io/google_containers/skydns:2015-10-13-8c72f8c,our.registry/gcr.io/google_containers/exechealthz:1.0 Selector: k8s-app=kube-dns,version=v11 Labels: k8s-app=kube-dns,kubernetes.io/cluster-service=true,version=v11 Replicas: 1 current / 1 desired Pods Status: 1 Running / 0 Waiting / 0 Succeeded / 0 Failed Volumes: etcd-storage: Type: EmptyDir (a temporary directory that shares a pod's lifetime) Medium: Events: FirstSeen LastSeen Count From SubobjectPath Type Reason Message --------- -------- ----- ---- ------------- -------- ------ ------- 19m 19m 1 {replication-controller } Normal SuccessfulCreate Created pod: kube-dns-v11-f2f4a ------------------------------------------------------- $ kubectl get all --all-namespaces NAMESPACE NAME DESIRED CURRENT AGE kube-system kube-dns-v11 1 1 24m NAMESPACE NAME CLUSTER-IP EXTERNAL-IP PORT(S) AGE default kubernetes 172.16.0.1 <none> 443/TCP 27m kube-system kube-dns 172.16.0.99 <none> 53/UDP,53/TCP 24m NAMESPACE NAME READY STATUS RESTARTS AGE default busybox 1/1 Running 0 23m kube-system kube-dns-v11-f2f4a 3/4 CrashLoopBackOff 9 24m If someone can help me to understand the problem... Note I'm using https://github.com/kubernetes/kubernetes/tree/release-1.2/cluster/addons/dns rc and svc where I only changed: clusterIp to a valid ip in my kubernetes ip range cluster domain: kubernetes.local cluster dns: 172.16.0.99 EDIT: The problem for the 3/4 kube-dns working comes from certificates. So I can confirm that SkyDNS is working now. NAME READY STATUS RESTARTS AGE kube-dns-v11-c96d5 4/4 Running 0 9m Using cluster-api-tester: kubectl logs --tail=80 kube-dns-v11-c96d5 kube2sky --namespace=kube-system I0621 13:27:52.070730 1 kube2sky.go:462] Etcd server found: http://127.0.0.1:4001 I0621 13:27:53.073614 1 kube2sky.go:529] Using https://192.168.0.1:443 for kubernetes master I0621 13:27:53.073632 1 kube2sky.go:530] Using kubernetes API <nil> I0621 13:27:53.074020 1 kube2sky.go:598] Waiting for service: default/kubernetes I0621 13:27:53.166188 1 kube2sky.go:660] Successfully added DNS record for Kubernetes service. But others problems appear. now "Using kubernetes API nil" instead of the good version the busybox example from kubernetes documentation still won't resolv kubernetes.local I will more investigate. But I resolved the skydns starting issue. Thanks ### Response: One of your DNS containers isn't ready. That's what "Ready 3/4" means. The best bet is to use the kubectl logs <pod> <container> command to get the logs of the container that is failing. You can add kubectl logs --previous ... if you need to get the logs from a container that already failed. Hopefully that will give you the information necessary to debug why that container isn't coming up.
I installed kubernetes 1.2.4 on 3 REHEL7 servers (no internet access, everything is pushed by ansible). EDIT: See the end of the question I've got everything working great excepting the kube-dns example given in documentation. I made several tests, several configuraiton, recreate the entire pods... And I always have this "MissingClusterDNS" error: enter code here20m 20m 2 {kubelet k8s-minion-1.XXXXXX} Warning MissingClusterDNS kubelet does not have ClusterDNS IP configured and cannot create Pod using "ClusterFirst" policy. Falling back to DNSDefault policy. As you can see, kube-dns is running: kubectl get svc kube-dns --namespace=kube-system NAME CLUSTER-IP EXTERNAL-IP PORT(S) AGE kube-dns 172.16.0.99 <none> 53/UDP,53/TCP 15m And kubelete has got correct options KUBELET_ARGS=" --cluster-dns=172.16.0.99 --cluster-domain=kubernetes.local " Proof: ps ax | grep kubelet 6077 ? Ssl 0:07 /opt/kubernetes/bin/kubelet --logtostderr=true --v=0 --address=0.0.0.0 --port=10250 --hostname-override=k8s-minion-1.XXXXXX --api-servers=http://k8s-master.XXXXXX:8080 --allow-privileged=false --cluster-dns=172.16.0.99 --cluster-domain=kubernetes.local But, the DNS pod as a not running container: kubectl get pods --namespace=kube-system NAME READY STATUS RESTARTS AGE kube-dns-v11-f2f4a 3/4 CrashLoopBackOff 7 18m And the log is explicit: Warning Unhealthy Readiness probe failed: Get http://172.16.23.2:8081/readiness: dial tcp 172.16.23.2:8081: connection refused ... Warning FailedSync Error syncing pod, skipping: failed to "StartContainer" for "kube2sky" with CrashLoopBackOff: "Back-off 5m0s restarting failed container=kube2sky pod=kube-dns-v11-f2f4a_kube-system(27d70b7c-36f9-11e6-b4fe-fa163ee85c45)" If you need more information: $ kubectl get pods --namespace=kube-system NAME READY STATUS RESTARTS AGE kube-dns-v11-f2f4a 3/4 CrashLoopBackOff 7 18m ------------------------- $ kubectl describe rc --namespace=kube-system Name: kube-dns-v11 Namespace: kube-system Image(s): our.registry/gcr.io/google_containers/etcd-amd64:2.2.1,our.registry/gcr.io/google_containers/kube2sky:1.14,our.registry/gcr.io/google_containers/skydns:2015-10-13-8c72f8c,our.registry/gcr.io/google_containers/exechealthz:1.0 Selector: k8s-app=kube-dns,version=v11 Labels: k8s-app=kube-dns,kubernetes.io/cluster-service=true,version=v11 Replicas: 1 current / 1 desired Pods Status: 1 Running / 0 Waiting / 0 Succeeded / 0 Failed Volumes: etcd-storage: Type: EmptyDir (a temporary directory that shares a pod's lifetime) Medium: Events: FirstSeen LastSeen Count From SubobjectPath Type Reason Message --------- -------- ----- ---- ------------- -------- ------ ------- 19m 19m 1 {replication-controller } Normal SuccessfulCreate Created pod: kube-dns-v11-f2f4a ------------------------------------------------------- $ kubectl get all --all-namespaces NAMESPACE NAME DESIRED CURRENT AGE kube-system kube-dns-v11 1 1 24m NAMESPACE NAME CLUSTER-IP EXTERNAL-IP PORT(S) AGE default kubernetes 172.16.0.1 <none> 443/TCP 27m kube-system kube-dns 172.16.0.99 <none> 53/UDP,53/TCP 24m NAMESPACE NAME READY STATUS RESTARTS AGE default busybox 1/1 Running 0 23m kube-system kube-dns-v11-f2f4a 3/4 CrashLoopBackOff 9 24m If someone can help me to understand the problem... Note I'm using https://github.com/kubernetes/kubernetes/tree/release-1.2/cluster/addons/dns rc and svc where I only changed: clusterIp to a valid ip in my kubernetes ip range cluster domain: kubernetes.local cluster dns: 172.16.0.99 EDIT: The problem for the 3/4 kube-dns working comes from certificates. So I can confirm that SkyDNS is working now. NAME READY STATUS RESTARTS AGE kube-dns-v11-c96d5 4/4 Running 0 9m Using cluster-api-tester: kubectl logs --tail=80 kube-dns-v11-c96d5 kube2sky --namespace=kube-system I0621 13:27:52.070730 1 kube2sky.go:462] Etcd server found: http://127.0.0.1:4001 I0621 13:27:53.073614 1 kube2sky.go:529] Using https://192.168.0.1:443 for kubernetes master I0621 13:27:53.073632 1 kube2sky.go:530] Using kubernetes API <nil> I0621 13:27:53.074020 1 kube2sky.go:598] Waiting for service: default/kubernetes I0621 13:27:53.166188 1 kube2sky.go:660] Successfully added DNS record for Kubernetes service. But others problems appear. now "Using kubernetes API nil" instead of the good version the busybox example from kubernetes documentation still won't resolv kubernetes.local I will more investigate. But I resolved the skydns starting issue. Thanks
GKE is a managed/hosted Kubernetes (i.e. it is managed for you so you can concentrate on running your pods/containers applications) Kubernetes does handle: Running pods, scheduling them on nodes, guarantee no of replicas per Replication Controller settings (i.e. relaunch pods if they fail, relocate them if the node fails) Services: proxy traffic to the right pod wherever it is located. Jobs In addition, there are several 'add-ons' to Kubernetes, some of which are part of what makes GKE: DNS (you can't really live without it, even thought it's an add-on) Metrics monitoring: with influxdb, grafana Dashboard None of these are out-of-the-box, although they are fairly easy to setup, but you need to maintain them. There is no real 'logging' add-on, but there are various projects to do this (using Logspout, logstash, elasticsearch etc...) In short Kubernetes does the orchestration, the rest are services that would run on top of Kubernetes. GKE brings you all these components out-of-the-box, and you don't have to maintain them. They're setup for you, and they're more 'integrated' with the Google portal. One important thing that everyone needs is the LoadBalancer part: - Since Pods are ephemeral containers, that can be rescheduled anywhere and at any time, they are not static, so ingress traffic needs to be managed separately. This can be done within Kubernetes by using a DaemonSet to fix a Pod on a specific node, and use a hostPort for that Pod to bind to the node's IP. Obviously this lacks fault tolerance, so you could use multiple and do DNS round robin load balancing. GKE takes care of all this too with external Load Balancing. (On AWS, it's similar, with ALB taking care of load balancing in Kubernetes)
###Instruction: I know that GKE is driven by kubernetes underneath. But I don't seem to still get is that what part is taken care by GKE and what by k8s in the layering? The main purpose of both, as it appears to me is to manage containers in a cluster. Basically, I am looking for a simpler explanation with an example. ### Response: GKE is a managed/hosted Kubernetes (i.e. it is managed for you so you can concentrate on running your pods/containers applications) Kubernetes does handle: Running pods, scheduling them on nodes, guarantee no of replicas per Replication Controller settings (i.e. relaunch pods if they fail, relocate them if the node fails) Services: proxy traffic to the right pod wherever it is located. Jobs In addition, there are several 'add-ons' to Kubernetes, some of which are part of what makes GKE: DNS (you can't really live without it, even thought it's an add-on) Metrics monitoring: with influxdb, grafana Dashboard None of these are out-of-the-box, although they are fairly easy to setup, but you need to maintain them. There is no real 'logging' add-on, but there are various projects to do this (using Logspout, logstash, elasticsearch etc...) In short Kubernetes does the orchestration, the rest are services that would run on top of Kubernetes. GKE brings you all these components out-of-the-box, and you don't have to maintain them. They're setup for you, and they're more 'integrated' with the Google portal. One important thing that everyone needs is the LoadBalancer part: - Since Pods are ephemeral containers, that can be rescheduled anywhere and at any time, they are not static, so ingress traffic needs to be managed separately. This can be done within Kubernetes by using a DaemonSet to fix a Pod on a specific node, and use a hostPort for that Pod to bind to the node's IP. Obviously this lacks fault tolerance, so you could use multiple and do DNS round robin load balancing. GKE takes care of all this too with external Load Balancing. (On AWS, it's similar, with ALB taking care of load balancing in Kubernetes)
I know that GKE is driven by kubernetes underneath. But I don't seem to still get is that what part is taken care by GKE and what by k8s in the layering? The main purpose of both, as it appears to me is to manage containers in a cluster. Basically, I am looking for a simpler explanation with an example.
I'm still not sure how to make clients connect to a single server that transparently routes all connections to the minions. -> To do this you need a load balancer, which unfortunately is not a default Kubernetes building bloc. You need to set up a reverse proxy that will send the traffic to the minion, like a nginx pod and a service using hostPort: <port> that will bind the port to the host. That means the pod needs to stay on that node, and to do that you would want to use a DaemonSet that uses the node name as selector for example. Obviously, this is not very fault tolerant, so you can setup multiple reverse proxies and use DNS round robin resolution to forward traffic to one of the proxy pods. Somewhere, at some point, you need a fixed IP to talk to your service over the internet, so you need to insure there is a static pod somewhere to handle that.
###Instruction: I'm also trying to expose a mysql server instance on a local kubernetes installation(1 master and one node, both on oracle linux) but I not being able to access to the pod. The pod configuration is this: apiVersion: v1 kind: Pod metadata: name: mysql labels: name: mysql spec: containers: - resources: limits : cpu: 1 image: docker.io/mariadb name: mysql env: - name: MYSQL_ROOT_PASSWORD value: 123456 ports: - containerPort: 3306 name: mysql And the service file: apiVersion: v1 kind: Service metadata: labels: name: mysql name: mysql spec: type: NodePort ports: - port: 3306 targetPort: 3306 nodePort: 30306 selector: name: mysql I can see that the pod is is running: # kubectl get pod mysql NAME READY STATUS RESTARTS AGE mysql 1/1 Running 0 3d And the service is connected to an endpoint: # kubectl describe service mysql Name: mysql Namespace: default Labels: name=mysql Selector: name=mysql Type: NodePort IP: 10.254.200.20 Port: <unset> 3306/TCP NodePort: <unset> 30306/TCP Endpoints: 11.0.14.2:3306 Session Affinity: None No events. I can see on netstat that kube-proxy is listening on port 30306 for all incoming connections. tcp6 6 0 :::30306 :::* LISTEN 53039/kube-proxy But somehow I don't get a response from mysql even on the localhost. # telnet localhost 30306 Trying ::1... Connected to localhost. Escape character is '^]'. Whereas a normal mysql installation responds with something of the following: $ telnet [REDACTED] 3306 Trying [REDACTED]... Connected to [REDACTED]. Escape character is '^]'. N [REDACTED]-log�gw&TS(gS�X]G/Q,(#uIJwmysql_native_password^] Notice the mysql part in the last line. On a final note there is this kubectl output: $ kubectl get service NAME CLUSTER-IP EXTERNAL-IP PORT(S) AGE kubernetes 10.254.0.1 <none> 443/TCP 9d mysql 10.254.200.20 nodes 3306/TCP 1h But I don't understand what "nodes" mean in the EXTERNAL-IP column. So what I want to happen is to open the access to the mysql service through the master IP(preferrably). How do I do that and what am I doing wrong? ### Response: I'm still not sure how to make clients connect to a single server that transparently routes all connections to the minions. -> To do this you need a load balancer, which unfortunately is not a default Kubernetes building bloc. You need to set up a reverse proxy that will send the traffic to the minion, like a nginx pod and a service using hostPort: <port> that will bind the port to the host. That means the pod needs to stay on that node, and to do that you would want to use a DaemonSet that uses the node name as selector for example. Obviously, this is not very fault tolerant, so you can setup multiple reverse proxies and use DNS round robin resolution to forward traffic to one of the proxy pods. Somewhere, at some point, you need a fixed IP to talk to your service over the internet, so you need to insure there is a static pod somewhere to handle that.
I'm also trying to expose a mysql server instance on a local kubernetes installation(1 master and one node, both on oracle linux) but I not being able to access to the pod. The pod configuration is this: apiVersion: v1 kind: Pod metadata: name: mysql labels: name: mysql spec: containers: - resources: limits : cpu: 1 image: docker.io/mariadb name: mysql env: - name: MYSQL_ROOT_PASSWORD value: 123456 ports: - containerPort: 3306 name: mysql And the service file: apiVersion: v1 kind: Service metadata: labels: name: mysql name: mysql spec: type: NodePort ports: - port: 3306 targetPort: 3306 nodePort: 30306 selector: name: mysql I can see that the pod is is running: # kubectl get pod mysql NAME READY STATUS RESTARTS AGE mysql 1/1 Running 0 3d And the service is connected to an endpoint: # kubectl describe service mysql Name: mysql Namespace: default Labels: name=mysql Selector: name=mysql Type: NodePort IP: 10.254.200.20 Port: <unset> 3306/TCP NodePort: <unset> 30306/TCP Endpoints: 11.0.14.2:3306 Session Affinity: None No events. I can see on netstat that kube-proxy is listening on port 30306 for all incoming connections. tcp6 6 0 :::30306 :::* LISTEN 53039/kube-proxy But somehow I don't get a response from mysql even on the localhost. # telnet localhost 30306 Trying ::1... Connected to localhost. Escape character is '^]'. Whereas a normal mysql installation responds with something of the following: $ telnet [REDACTED] 3306 Trying [REDACTED]... Connected to [REDACTED]. Escape character is '^]'. N [REDACTED]-log�gw&TS(gS�X]G/Q,(#uIJwmysql_native_password^] Notice the mysql part in the last line. On a final note there is this kubectl output: $ kubectl get service NAME CLUSTER-IP EXTERNAL-IP PORT(S) AGE kubernetes 10.254.0.1 <none> 443/TCP 9d mysql 10.254.200.20 nodes 3306/TCP 1h But I don't understand what "nodes" mean in the EXTERNAL-IP column. So what I want to happen is to open the access to the mysql service through the master IP(preferrably). How do I do that and what am I doing wrong?
Kubernetes just manages the containers. As far as I know, it is actually the container engine (Docker, rkt) which implements the CPU limitation. That limitation is not a hard limit, as you already observed. but rather a percentage of the available resources. Kubernetes (if set up with monitoring for this purpose), takes the used resource values and uses them to determine if you need a new pod (assuming you have set up some auto scaling). Kubernetes can not rate limit the existing pod since it is not actually running the containers in the pod.
###Instruction: Are Kubernetes CPU limits "hard" limits? Say I have a node with 1 CPU with two pods scheduled and running/ready/active, each with requests.limits.cpu of 500m. Pod A uses up 1 CPU for a while--this is normal/allowed. Eventually, pod B wants some CPU. Will Kubernetes (or Linux) make sure that pod B can get the .5 CPU it asks for? Update on Thu Jun 23 16:55:25 UTC 2016 I'm still looking for a definitive answer, but it sounds like these may be hard limits in Linux/Docker. @danielmartins wrote this in the k8s slack channel: I believe you can find this out by running docker inspect on the containers in which you set the limits. Checking one of my containers, I see that Kubernetes set CpuPeriod, CpuQuota for them. The Docker docs (https://docs.docker.com/engine/reference/run/) mention the CFS documentation (https://www.kernel.org/doc/Documentation/scheduler/sched-bwc.txt), and from the information there, it seems that these are hard limits ### Response: Kubernetes just manages the containers. As far as I know, it is actually the container engine (Docker, rkt) which implements the CPU limitation. That limitation is not a hard limit, as you already observed. but rather a percentage of the available resources. Kubernetes (if set up with monitoring for this purpose), takes the used resource values and uses them to determine if you need a new pod (assuming you have set up some auto scaling). Kubernetes can not rate limit the existing pod since it is not actually running the containers in the pod.
Are Kubernetes CPU limits "hard" limits? Say I have a node with 1 CPU with two pods scheduled and running/ready/active, each with requests.limits.cpu of 500m. Pod A uses up 1 CPU for a while--this is normal/allowed. Eventually, pod B wants some CPU. Will Kubernetes (or Linux) make sure that pod B can get the .5 CPU it asks for? Update on Thu Jun 23 16:55:25 UTC 2016 I'm still looking for a definitive answer, but it sounds like these may be hard limits in Linux/Docker. @danielmartins wrote this in the k8s slack channel: I believe you can find this out by running docker inspect on the containers in which you set the limits. Checking one of my containers, I see that Kubernetes set CpuPeriod, CpuQuota for them. The Docker docs (https://docs.docker.com/engine/reference/run/) mention the CFS documentation (https://www.kernel.org/doc/Documentation/scheduler/sched-bwc.txt), and from the information there, it seems that these are hard limits
For kubernetes v1.2+, CPU resource limits are enforced using hardcapping, and requests are enforced using shares. The change was noted in the release note and there is an issue open to update the documentation.
###Instruction: Are Kubernetes CPU limits "hard" limits? Say I have a node with 1 CPU with two pods scheduled and running/ready/active, each with requests.limits.cpu of 500m. Pod A uses up 1 CPU for a while--this is normal/allowed. Eventually, pod B wants some CPU. Will Kubernetes (or Linux) make sure that pod B can get the .5 CPU it asks for? Update on Thu Jun 23 16:55:25 UTC 2016 I'm still looking for a definitive answer, but it sounds like these may be hard limits in Linux/Docker. @danielmartins wrote this in the k8s slack channel: I believe you can find this out by running docker inspect on the containers in which you set the limits. Checking one of my containers, I see that Kubernetes set CpuPeriod, CpuQuota for them. The Docker docs (https://docs.docker.com/engine/reference/run/) mention the CFS documentation (https://www.kernel.org/doc/Documentation/scheduler/sched-bwc.txt), and from the information there, it seems that these are hard limits ### Response: For kubernetes v1.2+, CPU resource limits are enforced using hardcapping, and requests are enforced using shares. The change was noted in the release note and there is an issue open to update the documentation.
Are Kubernetes CPU limits "hard" limits? Say I have a node with 1 CPU with two pods scheduled and running/ready/active, each with requests.limits.cpu of 500m. Pod A uses up 1 CPU for a while--this is normal/allowed. Eventually, pod B wants some CPU. Will Kubernetes (or Linux) make sure that pod B can get the .5 CPU it asks for? Update on Thu Jun 23 16:55:25 UTC 2016 I'm still looking for a definitive answer, but it sounds like these may be hard limits in Linux/Docker. @danielmartins wrote this in the k8s slack channel: I believe you can find this out by running docker inspect on the containers in which you set the limits. Checking one of my containers, I see that Kubernetes set CpuPeriod, CpuQuota for them. The Docker docs (https://docs.docker.com/engine/reference/run/) mention the CFS documentation (https://www.kernel.org/doc/Documentation/scheduler/sched-bwc.txt), and from the information there, it seems that these are hard limits
I finally managed my problem... Shame on me (or not). I've taken kubelet sources to understand what happends and now I found. In the "kubelet" file, I set: KUBE_ARGS="--cluster-dns=10.10.0.10 --cluster-domain=cluster.local" And the log I added in source says that "cluster-dns" option as this value: 10.10.0.10 --cluster-domain=cluster.local That's mainly because the config file is interpreted by SystemD as a "bash environment vars" so KUBE_ARGS is "one argument", and it's badly parsed by kubelet service. The solution is to split variable in two and change kubelet.service file to use vars. After a call to systemctl daemon-reload; systemctl restart kubelet everything is ok. I opened an issue here: https://github.com/kubernetes/kubernetes/issues/27722 where I explain that the comment in example config file is ambiguous and/or the arguments are not parsed as expected.
###Instruction: I've install a Kubernetes 1.2.4 on 3 minons/master (1 master/minion, 2 minions) and installed the SkyDNS addons. After fixing SSL cert problems, I know have SkyDNS working. But kubeletes still says that I didn't set cluster-dns and cluster-domain. (see edits at the bottom) But you can see --cluster-dns=192.168.0.10 --cluster-domain=cluster.local: ps ax | grep kubelet 18717 ? Ssl 0:04 /opt/kubernetes/bin/kubelet --logtostderr=true --v=0 --address=0.0.0.0 --port=10250 --hostname-override=k8s-minion-1 --api-servers=http://k8s-master:8080 --allow-privileged=false --cluster-dns=192.168.0.10 --cluster-domain=cluster.local Launching this pod: apiVersion: v1 kind: Pod metadata: name: busybox namespace: default spec: containers: - image: busybox command: - sleep - "3600" imagePullPolicy: IfNotPresent name: busybox restartPolicy: Always I see: kubectl describe pod busybox 7m 7m 2 {kubelet k8s-master.XXX} Warning MissingClusterDNS kubelet does not have ClusterDNS IP configured and cannot create Pod using "ClusterFirst" policy. Falling back to DNSDefault policy. I restarted kubelete services before to launch this pod, and I have no other pod running. If I launch docker container using "--dns" option: docker run --rm -it --dns 192.168.0.10 busybox nslookup cluster.local Server: 192.168.0.10 Address 1: 192.168.0.10 Name: cluster.local Address 1: 192.168.0.10 Address 2: 172.16.50.2 Address 3: 192.168.0.1 Address 4: 172.16.96.3 docker run --rm -it --dns 192.168.0.10 busybox cat /etc/resolv.conf search XXX YYYY nameserver 192.168.0.10 That's absolutly normal (I've hidden my client dns) But the pod says something else: kubectl exec busybox -- nslookup cluster.local Server: XXX.YYY.XXX.YYY Address 1: XXX.YYYY.XXXX.YYY XXX.domain.fr nslookup: can't resolve 'cluster.local' error: error executing remote command: Error executing command in container: Error executing in Docker Container: 1 I tried to set "--dns" option to the docker daemon, but the error is the same. See that logs: kubectl get pods --namespace=kube-system NAME READY STATUS RESTARTS AGE kube-dns-v11-osikn 4/4 Running 0 13m And: kubectl logs kube-dns-v11-osikn kube2sky --namespace=kube-system I0621 15:44:48.168080 1 kube2sky.go:462] Etcd server found: http://127.0.0.1:4001 I0621 15:44:49.170404 1 kube2sky.go:529] Using https://192.168.0.1:443 for kubernetes master I0621 15:44:49.170422 1 kube2sky.go:530] Using kubernetes API <nil> I0621 15:44:49.170823 1 kube2sky.go:598] Waiting for service: default/kubernetes I0621 15:44:49.209691 1 kube2sky.go:660] Successfully added DNS record for Kubernetes service. "Using kubernetes API <nil>" is a problem, isn't it ? edit: I forced kube-master-url in the pod to let kube2sky contacting the master. kubectl logs kube-dns-v11-osikn skydns --namespace=kube-system 2016/06/21 15:44:50 skydns: falling back to default configuration, could not read from etcd: 100: Key not found (/skydns/config) [10] 2016/06/21 15:44:50 skydns: ready for queries on cluster.local. for tcp://0.0.0.0:53 [rcache 0] 2016/06/21 15:44:50 skydns: ready for queries on cluster.local. for udp://0.0.0.0:53 [rcache 0] Note this too: kubectl get pods --all-namespaces NAMESPACE NAME READY STATUS RESTARTS AGE default busybox 1/1 Running 0 17m kube-system kube-dns-v11-osikn 4/4 Running 0 18m So I've got no problem with skydns. I'm sure that the problem comes from kubelet, I've tried to remove /var/lib/kubelet and restart the entire cluster. I've tried to restart kubelete services before and after installing dns also. I changed docker configuration, removed "--dns" option afterwoard, and I've got the same behaviour: Docker + dns is ok, Kubelet gives a MissingClusterDNS error saying that kubelet has got no configured cluster dns. So please... Help (one more time :) ) EDITS: - now kube2sky doesn't complain about <nil> api version forcing kube2sky option - I can force nslookup to use my sky DNS: kubectl exec busybox -- nslookup kubernetes.default.svc.cluster.local 192.168.0.10 Server: 192.168.0.10 Address 1: 192.168.0.10 Name: kubernetes.default.svc.cluster.local Address 1: 192.168.0.1 But the "MissingClusterDNS" error remains on pod creation, as if kubelet doesn't the startup options "--cluster-dns" and "--cluster-domain" @Brendan Burns: kubectl get services --namespace=kube-system NAME CLUSTER-IP EXTERNAL-IP PORT(S) AGE kube-dns 192.168.0.10 <none> 53/UDP,53/TCP 12m ### Response: I finally managed my problem... Shame on me (or not). I've taken kubelet sources to understand what happends and now I found. In the "kubelet" file, I set: KUBE_ARGS="--cluster-dns=10.10.0.10 --cluster-domain=cluster.local" And the log I added in source says that "cluster-dns" option as this value: 10.10.0.10 --cluster-domain=cluster.local That's mainly because the config file is interpreted by SystemD as a "bash environment vars" so KUBE_ARGS is "one argument", and it's badly parsed by kubelet service. The solution is to split variable in two and change kubelet.service file to use vars. After a call to systemctl daemon-reload; systemctl restart kubelet everything is ok. I opened an issue here: https://github.com/kubernetes/kubernetes/issues/27722 where I explain that the comment in example config file is ambiguous and/or the arguments are not parsed as expected.
I've install a Kubernetes 1.2.4 on 3 minons/master (1 master/minion, 2 minions) and installed the SkyDNS addons. After fixing SSL cert problems, I know have SkyDNS working. But kubeletes still says that I didn't set cluster-dns and cluster-domain. (see edits at the bottom) But you can see --cluster-dns=192.168.0.10 --cluster-domain=cluster.local: ps ax | grep kubelet 18717 ? Ssl 0:04 /opt/kubernetes/bin/kubelet --logtostderr=true --v=0 --address=0.0.0.0 --port=10250 --hostname-override=k8s-minion-1 --api-servers=http://k8s-master:8080 --allow-privileged=false --cluster-dns=192.168.0.10 --cluster-domain=cluster.local Launching this pod: apiVersion: v1 kind: Pod metadata: name: busybox namespace: default spec: containers: - image: busybox command: - sleep - "3600" imagePullPolicy: IfNotPresent name: busybox restartPolicy: Always I see: kubectl describe pod busybox 7m 7m 2 {kubelet k8s-master.XXX} Warning MissingClusterDNS kubelet does not have ClusterDNS IP configured and cannot create Pod using "ClusterFirst" policy. Falling back to DNSDefault policy. I restarted kubelete services before to launch this pod, and I have no other pod running. If I launch docker container using "--dns" option: docker run --rm -it --dns 192.168.0.10 busybox nslookup cluster.local Server: 192.168.0.10 Address 1: 192.168.0.10 Name: cluster.local Address 1: 192.168.0.10 Address 2: 172.16.50.2 Address 3: 192.168.0.1 Address 4: 172.16.96.3 docker run --rm -it --dns 192.168.0.10 busybox cat /etc/resolv.conf search XXX YYYY nameserver 192.168.0.10 That's absolutly normal (I've hidden my client dns) But the pod says something else: kubectl exec busybox -- nslookup cluster.local Server: XXX.YYY.XXX.YYY Address 1: XXX.YYYY.XXXX.YYY XXX.domain.fr nslookup: can't resolve 'cluster.local' error: error executing remote command: Error executing command in container: Error executing in Docker Container: 1 I tried to set "--dns" option to the docker daemon, but the error is the same. See that logs: kubectl get pods --namespace=kube-system NAME READY STATUS RESTARTS AGE kube-dns-v11-osikn 4/4 Running 0 13m And: kubectl logs kube-dns-v11-osikn kube2sky --namespace=kube-system I0621 15:44:48.168080 1 kube2sky.go:462] Etcd server found: http://127.0.0.1:4001 I0621 15:44:49.170404 1 kube2sky.go:529] Using https://192.168.0.1:443 for kubernetes master I0621 15:44:49.170422 1 kube2sky.go:530] Using kubernetes API <nil> I0621 15:44:49.170823 1 kube2sky.go:598] Waiting for service: default/kubernetes I0621 15:44:49.209691 1 kube2sky.go:660] Successfully added DNS record for Kubernetes service. "Using kubernetes API <nil>" is a problem, isn't it ? edit: I forced kube-master-url in the pod to let kube2sky contacting the master. kubectl logs kube-dns-v11-osikn skydns --namespace=kube-system 2016/06/21 15:44:50 skydns: falling back to default configuration, could not read from etcd: 100: Key not found (/skydns/config) [10] 2016/06/21 15:44:50 skydns: ready for queries on cluster.local. for tcp://0.0.0.0:53 [rcache 0] 2016/06/21 15:44:50 skydns: ready for queries on cluster.local. for udp://0.0.0.0:53 [rcache 0] Note this too: kubectl get pods --all-namespaces NAMESPACE NAME READY STATUS RESTARTS AGE default busybox 1/1 Running 0 17m kube-system kube-dns-v11-osikn 4/4 Running 0 18m So I've got no problem with skydns. I'm sure that the problem comes from kubelet, I've tried to remove /var/lib/kubelet and restart the entire cluster. I've tried to restart kubelete services before and after installing dns also. I changed docker configuration, removed "--dns" option afterwoard, and I've got the same behaviour: Docker + dns is ok, Kubelet gives a MissingClusterDNS error saying that kubelet has got no configured cluster dns. So please... Help (one more time :) ) EDITS: - now kube2sky doesn't complain about <nil> api version forcing kube2sky option - I can force nslookup to use my sky DNS: kubectl exec busybox -- nslookup kubernetes.default.svc.cluster.local 192.168.0.10 Server: 192.168.0.10 Address 1: 192.168.0.10 Name: kubernetes.default.svc.cluster.local Address 1: 192.168.0.1 But the "MissingClusterDNS" error remains on pod creation, as if kubelet doesn't the startup options "--cluster-dns" and "--cluster-domain" @Brendan Burns: kubectl get services --namespace=kube-system NAME CLUSTER-IP EXTERNAL-IP PORT(S) AGE kube-dns 192.168.0.10 <none> 53/UDP,53/TCP 12m
If you want to run a preconfigured load test, you can check out the instructions for the kubernetes scale-demo that shows how to serve 1 million QPS of static files using nginx, which is very similar to your test setup. Also keep in mind that a single VM (regardless of the number of pods running on it) will have a limit to how much bandwidth it can use and how many packets-per-second it can process. To serve more load, you should create a larger VM type or add additional VMs.
###Instruction: In trying to achieve a highly available web server set up, I ran a load test against an extremely simple NGINX docker container serving a single static file. At first, I tried with a single node (n1-standard-4) & single pod cluster, to benchmark how much one "unit" could do. This single node/pod setup could cope with around 20k concurrent requests before starting to timeout for some requests/drop in throughput. I then added another node of the same machine type and scaled the pods to two replicas. Once I confirmed both pods/nodes were up, I ran the test again with 20k. Performance was good so I bumped up to 40k - expecting that I would see similar results to the 20k on the 1 node/pod setup. However, the performance was very bad, never with requests per second jumping violently between 15k and 30k. I tried the same test again with 4 nodes/pods and saw similar, if not slightly worse results. My question(s) are: Am I wrong to think that my concurrent requests should scale linearly this way with GKE/containers/kubernetes? What am I missing in order to achieve the desired results of being able to cope with N concurrent users with M nodes/pods in the cluster? EDIT: I also do not believe it is an issue with the load testing tool - as I am using an external paid service that claims to be able to simulate up to 100k concurrent requests. EDIT 2: Here's some more information about the setup: Dockerfile: FROM nginx ADD nginx.conf /etc/nginx/nginx.conf ADD index.html /usr/share/nginx/html/index.html ADD data.json /usr/share/nginx/html/data.json nginx.conf: user nginx; worker_processes 4; error_log /var/log/nginx/error.log warn; pid /var/run/nginx.pid; events { worker_connections 4096; } http { include /etc/nginx/mime.types; default_type application/octet-stream; log_format main '$remote_addr - $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"'; access_log off; sendfile on; #tcp_nopush on; keepalive_timeout 65; #gzip on; server { listen 80 default_server; listen [::]:80 default_server; root /usr/share/nginx/html; # Serve the index.html page location / { try_files /index.html =404; } } include /etc/nginx/conf.d/*.conf; } index.html: <head><title>Load Test Page</title></head><body><h3>Load Test!</h3></body> I used the "LoadBalancer" service, which I believe setups a Google Cloud Balancer (I confirmed this and saw the nodes being added to it). Here are the files below I used with kubernetes to manage the cluster. rc.yml: apiVersion: v1 kind: ReplicationController metadata: name: nginx-rc labels: name: nginx-rc spec: replicas: 2 selector: name: nginx-server template: metadata: labels: name: nginx-server name: nginx-server spec: containers: - name: nginx-server image: [[ my image ]] ports: - containerPort: 80 hostPort: 80 services.yml: apiVersion: v1 kind: Service metadata: labels: name: nginx-lb name: nginx-lb spec: ports: - port: 80 targetPort: 80 selector: name: nginx-server type: LoadBalancer ### Response: If you want to run a preconfigured load test, you can check out the instructions for the kubernetes scale-demo that shows how to serve 1 million QPS of static files using nginx, which is very similar to your test setup. Also keep in mind that a single VM (regardless of the number of pods running on it) will have a limit to how much bandwidth it can use and how many packets-per-second it can process. To serve more load, you should create a larger VM type or add additional VMs.
In trying to achieve a highly available web server set up, I ran a load test against an extremely simple NGINX docker container serving a single static file. At first, I tried with a single node (n1-standard-4) & single pod cluster, to benchmark how much one "unit" could do. This single node/pod setup could cope with around 20k concurrent requests before starting to timeout for some requests/drop in throughput. I then added another node of the same machine type and scaled the pods to two replicas. Once I confirmed both pods/nodes were up, I ran the test again with 20k. Performance was good so I bumped up to 40k - expecting that I would see similar results to the 20k on the 1 node/pod setup. However, the performance was very bad, never with requests per second jumping violently between 15k and 30k. I tried the same test again with 4 nodes/pods and saw similar, if not slightly worse results. My question(s) are: Am I wrong to think that my concurrent requests should scale linearly this way with GKE/containers/kubernetes? What am I missing in order to achieve the desired results of being able to cope with N concurrent users with M nodes/pods in the cluster? EDIT: I also do not believe it is an issue with the load testing tool - as I am using an external paid service that claims to be able to simulate up to 100k concurrent requests. EDIT 2: Here's some more information about the setup: Dockerfile: FROM nginx ADD nginx.conf /etc/nginx/nginx.conf ADD index.html /usr/share/nginx/html/index.html ADD data.json /usr/share/nginx/html/data.json nginx.conf: user nginx; worker_processes 4; error_log /var/log/nginx/error.log warn; pid /var/run/nginx.pid; events { worker_connections 4096; } http { include /etc/nginx/mime.types; default_type application/octet-stream; log_format main '$remote_addr - $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"'; access_log off; sendfile on; #tcp_nopush on; keepalive_timeout 65; #gzip on; server { listen 80 default_server; listen [::]:80 default_server; root /usr/share/nginx/html; # Serve the index.html page location / { try_files /index.html =404; } } include /etc/nginx/conf.d/*.conf; } index.html: <head><title>Load Test Page</title></head><body><h3>Load Test!</h3></body> I used the "LoadBalancer" service, which I believe setups a Google Cloud Balancer (I confirmed this and saw the nodes being added to it). Here are the files below I used with kubernetes to manage the cluster. rc.yml: apiVersion: v1 kind: ReplicationController metadata: name: nginx-rc labels: name: nginx-rc spec: replicas: 2 selector: name: nginx-server template: metadata: labels: name: nginx-server name: nginx-server spec: containers: - name: nginx-server image: [[ my image ]] ports: - containerPort: 80 hostPort: 80 services.yml: apiVersion: v1 kind: Service metadata: labels: name: nginx-lb name: nginx-lb spec: ports: - port: 80 targetPort: 80 selector: name: nginx-server type: LoadBalancer
Ah...your django container exited voluntarily without any error message, right after it was started, and that's expected. The django image comes with a default command of python3. Without overriding the command/args in the pod yaml file, the container will exit immediately. The doc you followed was simply trying to show how to create multiple containers in a pod, but the example is not realistic and doesn't set up a working application. Feel free to file a github issue against https://github.com/kubernetes/kubernetes.github.io
###Instruction: My kubectl version Client Version: version.Info{Major:"1", Minor:"2", GitVersion:"v1.2.4", GitCommit:"3eed1e3be6848b877ff80a93da3785d9034d0a4f", GitTreeState:"clean"} Server Version: version.Info{Major:"1", Minor:"2", GitVersion:"v1.2.4", GitCommit:"3eed1e3be6848b877ff80a93da3785d9034d0a4f", GitTreeState:"clean"} I followed Creating Multi-Container Pods After launching the pod, One container is UP but not other. kubectl get pods NAME READY STATUS RESTARTS AGE redis-django 1/2 CrashLoopBackOff 9 22m Then I did kubectl describe redis-django. At the bottom I saw Error syncing pod, skipping error 31m <invalid> 150 {kubelet 172.25.30.21} spec.containers{frontend} Warning BackOff Back-off restarting failed docker container 25m <invalid> 121 {kubelet 172.25.30.21} Warning FailedSync Error syncing pod, skipping: failed to "StartContainer" for "frontend" with CrashLoopBackOff: "Back-off 5m0s restarting failed container=frontend pod=redis-django_default(9f35ffcd-391e-11e6-b160-0022195df673)" How can I reslove this error? any help! Thanks! OS: Ubuntu 14 UPDATE Previsoly I used below yaml file which was found at Creating Multi-Container Pods apiVersion: v1 kind: Pod metadata: name: redis-django labels: app: web spec: containers: - name: key-value-store image: redis ports: - containerPort: 6379 - name: frontend image: django ports: - containerPort: 8000 frontend container was not started. Then I changed the yaml file to two redis containers with different names and ports. But, the result is same(Getting Error syncing pod, skipping) Later I have changed yaml file to, only one django container. This pod status CrashLoopBackOff and the Error syncing pod, skipping UPDATE-2 I tail -f /var/log/upstart/kublet.log, which is giving same error. Kubelet is continously trying to start the container, but it is not! I0623 12:15:13.943046 445 manager.go:2050] Back-off 5m0s restarting failed container=key-value-store pod=redis-django_default(94683d3c-392e-11e6-b160-0022195df673) E0623 12:15:13.943100 445 pod_workers.go:138] Error syncing pod 94683d3c-392e-11e6-b160-0022195df673, skipping: failed to "StartContainer" for "key-value-store" with CrashLoopBackOff: "Back-off 5m0s restarting failed container=key-value-store pod=redis-django_default(94683d3c-392e-11e6-b160-0022195df673)" UPDATE-3 root@vm1:~/kubernetes/cluster/ubuntu/binaries# kubectl describe pod redis-django Name: redis-django Namespace: default Node: 192.168.1.10/192.168.1.10 Start Time: Thu, 23 Jun 2016 22:58:03 -0700 Labels: app=web Status: Running IP: 172.16.20.2 Controllers: <none> Containers: key-value-store: Container ID: docker://8dbdd6826c354243964f0306427082223d3da49bf2aaf30e15961ea00362fe42 Image: redis Image ID: docker://sha256:4465e4bcad80b5b43cef0bace96a8ef0a55c0050be439c1fb0ecd64bc0b8cce4 Port: 6379/TCP QoS Tier: cpu: BestEffort memory: BestEffort State: Running Started: Thu, 23 Jun 2016 22:58:10 -0700 Ready: True Restart Count: 0 Environment Variables: frontend: Container ID: docker://9c89602739abe7331b3beb3a79e92a7cc42e2a7e40e11618413c8bcfd0afbc16 Image: django Image ID: docker://sha256:0cb63b45e2b9a8de5763fc9c98b79c38b6217df718238251a21c8c4176fb3d68 Port: 8000/TCP QoS Tier: cpu: BestEffort memory: BestEffort State: Terminated Reason: Completed Exit Code: 0 Started: Thu, 23 Jun 2016 22:58:41 -0700 Finished: Thu, 23 Jun 2016 22:58:41 -0700 Last State: Terminated Reason: Completed Exit Code: 0 Started: Thu, 23 Jun 2016 22:58:22 -0700 Finished: Thu, 23 Jun 2016 22:58:22 -0700 Ready: False Restart Count: 2 Environment Variables: Conditions: Type Status Ready False Volumes: default-token-0oq7p: Type: Secret (a volume populated by a Secret) SecretName: default-token-0oq7p Events: FirstSeen LastSeen Count From SubobjectPath Type Reason Message --------- -------- ----- ---- ------------- -------- ------ ------- 49s 49s 1 {default-scheduler } Normal Scheduled Successfully assigned redis-django to 192.168.1.10 48s 48s 1 {kubelet 192.168.1.10} spec.containers{key-value-store} Normal Pulling pulling image "redis" 43s 43s 1 {kubelet 192.168.1.10} spec.containers{key-value-store} Normal Pulled Successfully pulled image "redis" 43s 43s 1 {kubelet 192.168.1.10} spec.containers{key-value-store} Normal Created Created container with docker id 8dbdd6826c35 42s 42s 1 {kubelet 192.168.1.10} spec.containers{key-value-store} Normal Started Started container with docker id 8dbdd6826c35 37s 37s 1 {kubelet 192.168.1.10} spec.containers{frontend} Normal Started Started container with docker id 3872ceae75d4 37s 37s 1 {kubelet 192.168.1.10} spec.containers{frontend} Normal Created Created container with docker id 3872ceae75d4 30s 30s 1 {kubelet 192.168.1.10} spec.containers{frontend} Normal Created Created container with docker id d97b99b6780c 30s 30s 1 {kubelet 192.168.1.10} spec.containers{frontend} Normal Started Started container with docker id d97b99b6780c 29s 29s 1 {kubelet 192.168.1.10} Warning FailedSync Error syncing pod, skipping: failed to "StartContainer" for "frontend" with CrashLoopBackOff: "Back-off 10s restarting failed container=frontend pod=redis-django_default(9d0a966a-39d0-11e6-9027-000c293d51ab)" 42s 16s 3 {kubelet 192.168.1.10} spec.containers{frontend} Normal Pulling pulling image "django" 11s 11s 1 {kubelet 192.168.1.10} spec.containers{frontend} Normal Started Started container with docker id 9c89602739ab 38s 11s 3 {kubelet 192.168.1.10} spec.containers{frontend} Normal Pulled Successfully pulled image "django" 11s 11s 1 {kubelet 192.168.1.10} spec.containers{frontend} Normal Created Created container with docker id 9c89602739ab 29s 10s 2 {kubelet 192.168.1.10} spec.containers{frontend} Warning BackOff Back-off restarting failed docker container 10s 10s 1 {kubelet 192.168.1.10} Warning FailedSync Error syncing pod, skipping: failed to "StartContainer" for "frontend" with CrashLoopBackOff: "Back-off 20s restarting failed container=frontend pod=redis-django_default(9d0a966a-39d0-11e6-9027-000c293d51ab)" For container frontend: Not showing any logs messages root@vm1:~/kubernetes/cluster/ubuntu/binaries# kubectl logs redis-django -p -c frontend root@vm1:~/kubernetes/cluster/ubuntu/binaries# kubectl logs redis-django -p -c key-value-store Error from server: previous terminated container "key-value-store" in pod "redis-django" not found root@vm1:~/kubernetes/cluster/ubuntu/binaries# docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 8dbdd6826c35 redis "docker-entrypoint.sh" 2 minutes ago Up 2 minutes k8s_key-value-store.f572c2d_redis-django_default_9d0a966a-39d0-11e6-9027-000c293d51ab_11101aea 8995bbf9f4f4 gcr.io/google_containers/pause:2.0 "/pause" 2 minutes ago Up 2 minutes k8s_POD.48e5231f_redis-django_default_9d0a966a-39d0-11e6-9027-000c293d51ab_c00025b0 root@vm1:~/kubernetes/cluster/ubuntu/binaries# ### Response: Ah...your django container exited voluntarily without any error message, right after it was started, and that's expected. The django image comes with a default command of python3. Without overriding the command/args in the pod yaml file, the container will exit immediately. The doc you followed was simply trying to show how to create multiple containers in a pod, but the example is not realistic and doesn't set up a working application. Feel free to file a github issue against https://github.com/kubernetes/kubernetes.github.io
My kubectl version Client Version: version.Info{Major:"1", Minor:"2", GitVersion:"v1.2.4", GitCommit:"3eed1e3be6848b877ff80a93da3785d9034d0a4f", GitTreeState:"clean"} Server Version: version.Info{Major:"1", Minor:"2", GitVersion:"v1.2.4", GitCommit:"3eed1e3be6848b877ff80a93da3785d9034d0a4f", GitTreeState:"clean"} I followed Creating Multi-Container Pods After launching the pod, One container is UP but not other. kubectl get pods NAME READY STATUS RESTARTS AGE redis-django 1/2 CrashLoopBackOff 9 22m Then I did kubectl describe redis-django. At the bottom I saw Error syncing pod, skipping error 31m <invalid> 150 {kubelet 172.25.30.21} spec.containers{frontend} Warning BackOff Back-off restarting failed docker container 25m <invalid> 121 {kubelet 172.25.30.21} Warning FailedSync Error syncing pod, skipping: failed to "StartContainer" for "frontend" with CrashLoopBackOff: "Back-off 5m0s restarting failed container=frontend pod=redis-django_default(9f35ffcd-391e-11e6-b160-0022195df673)" How can I reslove this error? any help! Thanks! OS: Ubuntu 14 UPDATE Previsoly I used below yaml file which was found at Creating Multi-Container Pods apiVersion: v1 kind: Pod metadata: name: redis-django labels: app: web spec: containers: - name: key-value-store image: redis ports: - containerPort: 6379 - name: frontend image: django ports: - containerPort: 8000 frontend container was not started. Then I changed the yaml file to two redis containers with different names and ports. But, the result is same(Getting Error syncing pod, skipping) Later I have changed yaml file to, only one django container. This pod status CrashLoopBackOff and the Error syncing pod, skipping UPDATE-2 I tail -f /var/log/upstart/kublet.log, which is giving same error. Kubelet is continously trying to start the container, but it is not! I0623 12:15:13.943046 445 manager.go:2050] Back-off 5m0s restarting failed container=key-value-store pod=redis-django_default(94683d3c-392e-11e6-b160-0022195df673) E0623 12:15:13.943100 445 pod_workers.go:138] Error syncing pod 94683d3c-392e-11e6-b160-0022195df673, skipping: failed to "StartContainer" for "key-value-store" with CrashLoopBackOff: "Back-off 5m0s restarting failed container=key-value-store pod=redis-django_default(94683d3c-392e-11e6-b160-0022195df673)" UPDATE-3 root@vm1:~/kubernetes/cluster/ubuntu/binaries# kubectl describe pod redis-django Name: redis-django Namespace: default Node: 192.168.1.10/192.168.1.10 Start Time: Thu, 23 Jun 2016 22:58:03 -0700 Labels: app=web Status: Running IP: 172.16.20.2 Controllers: <none> Containers: key-value-store: Container ID: docker://8dbdd6826c354243964f0306427082223d3da49bf2aaf30e15961ea00362fe42 Image: redis Image ID: docker://sha256:4465e4bcad80b5b43cef0bace96a8ef0a55c0050be439c1fb0ecd64bc0b8cce4 Port: 6379/TCP QoS Tier: cpu: BestEffort memory: BestEffort State: Running Started: Thu, 23 Jun 2016 22:58:10 -0700 Ready: True Restart Count: 0 Environment Variables: frontend: Container ID: docker://9c89602739abe7331b3beb3a79e92a7cc42e2a7e40e11618413c8bcfd0afbc16 Image: django Image ID: docker://sha256:0cb63b45e2b9a8de5763fc9c98b79c38b6217df718238251a21c8c4176fb3d68 Port: 8000/TCP QoS Tier: cpu: BestEffort memory: BestEffort State: Terminated Reason: Completed Exit Code: 0 Started: Thu, 23 Jun 2016 22:58:41 -0700 Finished: Thu, 23 Jun 2016 22:58:41 -0700 Last State: Terminated Reason: Completed Exit Code: 0 Started: Thu, 23 Jun 2016 22:58:22 -0700 Finished: Thu, 23 Jun 2016 22:58:22 -0700 Ready: False Restart Count: 2 Environment Variables: Conditions: Type Status Ready False Volumes: default-token-0oq7p: Type: Secret (a volume populated by a Secret) SecretName: default-token-0oq7p Events: FirstSeen LastSeen Count From SubobjectPath Type Reason Message --------- -------- ----- ---- ------------- -------- ------ ------- 49s 49s 1 {default-scheduler } Normal Scheduled Successfully assigned redis-django to 192.168.1.10 48s 48s 1 {kubelet 192.168.1.10} spec.containers{key-value-store} Normal Pulling pulling image "redis" 43s 43s 1 {kubelet 192.168.1.10} spec.containers{key-value-store} Normal Pulled Successfully pulled image "redis" 43s 43s 1 {kubelet 192.168.1.10} spec.containers{key-value-store} Normal Created Created container with docker id 8dbdd6826c35 42s 42s 1 {kubelet 192.168.1.10} spec.containers{key-value-store} Normal Started Started container with docker id 8dbdd6826c35 37s 37s 1 {kubelet 192.168.1.10} spec.containers{frontend} Normal Started Started container with docker id 3872ceae75d4 37s 37s 1 {kubelet 192.168.1.10} spec.containers{frontend} Normal Created Created container with docker id 3872ceae75d4 30s 30s 1 {kubelet 192.168.1.10} spec.containers{frontend} Normal Created Created container with docker id d97b99b6780c 30s 30s 1 {kubelet 192.168.1.10} spec.containers{frontend} Normal Started Started container with docker id d97b99b6780c 29s 29s 1 {kubelet 192.168.1.10} Warning FailedSync Error syncing pod, skipping: failed to "StartContainer" for "frontend" with CrashLoopBackOff: "Back-off 10s restarting failed container=frontend pod=redis-django_default(9d0a966a-39d0-11e6-9027-000c293d51ab)" 42s 16s 3 {kubelet 192.168.1.10} spec.containers{frontend} Normal Pulling pulling image "django" 11s 11s 1 {kubelet 192.168.1.10} spec.containers{frontend} Normal Started Started container with docker id 9c89602739ab 38s 11s 3 {kubelet 192.168.1.10} spec.containers{frontend} Normal Pulled Successfully pulled image "django" 11s 11s 1 {kubelet 192.168.1.10} spec.containers{frontend} Normal Created Created container with docker id 9c89602739ab 29s 10s 2 {kubelet 192.168.1.10} spec.containers{frontend} Warning BackOff Back-off restarting failed docker container 10s 10s 1 {kubelet 192.168.1.10} Warning FailedSync Error syncing pod, skipping: failed to "StartContainer" for "frontend" with CrashLoopBackOff: "Back-off 20s restarting failed container=frontend pod=redis-django_default(9d0a966a-39d0-11e6-9027-000c293d51ab)" For container frontend: Not showing any logs messages root@vm1:~/kubernetes/cluster/ubuntu/binaries# kubectl logs redis-django -p -c frontend root@vm1:~/kubernetes/cluster/ubuntu/binaries# kubectl logs redis-django -p -c key-value-store Error from server: previous terminated container "key-value-store" in pod "redis-django" not found root@vm1:~/kubernetes/cluster/ubuntu/binaries# docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 8dbdd6826c35 redis "docker-entrypoint.sh" 2 minutes ago Up 2 minutes k8s_key-value-store.f572c2d_redis-django_default_9d0a966a-39d0-11e6-9027-000c293d51ab_11101aea 8995bbf9f4f4 gcr.io/google_containers/pause:2.0 "/pause" 2 minutes ago Up 2 minutes k8s_POD.48e5231f_redis-django_default_9d0a966a-39d0-11e6-9027-000c293d51ab_c00025b0 root@vm1:~/kubernetes/cluster/ubuntu/binaries#
The kubernetes service discovery mechanism (DNS or environment variable) doesn't populate the external IP. One way to work around is to create a static IP first, then assign it to your service. Or you can exec kubectl inside your cluster to get the external IP but that's nasty.
###Instruction: Is it possible to get the external IP address for a POD? It doesn't appear to be populating in the environmental variables for a service, so I was wondering if there was another way to get that information. Basically: I'm setting up a proftpd service, and it needs to send out its external ip as well as a port for passive communication. Right now, it's sending the local IP address which is causing FTP clients to fail. ### Response: The kubernetes service discovery mechanism (DNS or environment variable) doesn't populate the external IP. One way to work around is to create a static IP first, then assign it to your service. Or you can exec kubectl inside your cluster to get the external IP but that's nasty.
Is it possible to get the external IP address for a POD? It doesn't appear to be populating in the environmental variables for a service, so I was wondering if there was another way to get that information. Basically: I'm setting up a proftpd service, and it needs to send out its external ip as well as a port for passive communication. Right now, it's sending the local IP address which is causing FTP clients to fail.
The apiserver may become unreachable if it gets temporarily overloaded or if it is upgraded or repaired. This should be unrelated to routes being removed and recreated, although it's possible that the node manager does not behave correctly when it is restarted.
###Instruction: I've created a 3 nodes GKE cluster which is running fine but I noticed a few times that my components are not able to reach the API Server during 3 or 4 minutes. I recently had the same problem again on a fresh new cluster so I decided to look a bit closer. In the Compute Engine Operations section I noticed at the same time that the 3 routes had been removed and recreated 4 minutes later... This task had been scheduled by a @cloudservices.gserviceaccount.com address so from the cluster directly I suppose. What is causing this behavior, forcing the routes to be deleted and recreated randomly ? ### Response: The apiserver may become unreachable if it gets temporarily overloaded or if it is upgraded or repaired. This should be unrelated to routes being removed and recreated, although it's possible that the node manager does not behave correctly when it is restarted.
I've created a 3 nodes GKE cluster which is running fine but I noticed a few times that my components are not able to reach the API Server during 3 or 4 minutes. I recently had the same problem again on a fresh new cluster so I decided to look a bit closer. In the Compute Engine Operations section I noticed at the same time that the 3 routes had been removed and recreated 4 minutes later... This task had been scheduled by a @cloudservices.gserviceaccount.com address so from the cluster directly I suppose. What is causing this behavior, forcing the routes to be deleted and recreated randomly ?
Is it feasible that you have not labeled all your nodes with same key-value pairs? You need to ensure that each node in which you want Kubernetes to schedule your pod is having same key-value pair label and configuration are similar, as Kubernetes will schedule only on those nodes labeled with kubernetes.io/hostname: myapp01 and configurations matches what is defined in replication controller.
###Instruction: Using Replication controller when I schedule 2 (two) replicas of a pod I expect 1 (one) replica each in each Nodes (VMs). Instead I find both replicas are created in same pod. This will make 1 Node a single point of failure which I need to avoid. For 2 Pods: 1 pod in Node A, 1 pod in Node B For 3 Pods: 2 pod in Node A, 1 pod in Node B which kubernetes can schedule as per resource availability Any suggestions on what is not correctly configured? apiVersion: v1 kind: ReplicationController metadata: name: myweb-rc spec: replicas: 2 selector: role: "myweb" template: metadata: labels: role: "myweb" spec: containers: - name: tomcat image: myregistry.my.com/dev/cert/my-web/myweb/deployment_build_app-671-354-1.0.0-snapshot ports: - name: tomcat containerPort: 8080 readinessProbe: httpGet: path: /app port: 8080 initialDelaySeconds: 30 timeoutSeconds: 1 resources: requests: cpu: 1000m memory: 100Mi limits: cpu: 2000m memory: 7629Mi imagePullSecrets: - name: myregistrykey nodeSelector: kubernetes.io/hostname: myapp01 ### Response: Is it feasible that you have not labeled all your nodes with same key-value pairs? You need to ensure that each node in which you want Kubernetes to schedule your pod is having same key-value pair label and configuration are similar, as Kubernetes will schedule only on those nodes labeled with kubernetes.io/hostname: myapp01 and configurations matches what is defined in replication controller.
Using Replication controller when I schedule 2 (two) replicas of a pod I expect 1 (one) replica each in each Nodes (VMs). Instead I find both replicas are created in same pod. This will make 1 Node a single point of failure which I need to avoid. For 2 Pods: 1 pod in Node A, 1 pod in Node B For 3 Pods: 2 pod in Node A, 1 pod in Node B which kubernetes can schedule as per resource availability Any suggestions on what is not correctly configured? apiVersion: v1 kind: ReplicationController metadata: name: myweb-rc spec: replicas: 2 selector: role: "myweb" template: metadata: labels: role: "myweb" spec: containers: - name: tomcat image: myregistry.my.com/dev/cert/my-web/myweb/deployment_build_app-671-354-1.0.0-snapshot ports: - name: tomcat containerPort: 8080 readinessProbe: httpGet: path: /app port: 8080 initialDelaySeconds: 30 timeoutSeconds: 1 resources: requests: cpu: 1000m memory: 100Mi limits: cpu: 2000m memory: 7629Mi imagePullSecrets: - name: myregistrykey nodeSelector: kubernetes.io/hostname: myapp01
If you take a look at cluster/vagrant/util.sh, the possible providers are: vmware_fusion, vmware_workstation, parallels, virtualbox, libvirt, vsphere.
###Instruction: I got this errors when restarting or reinstalling Kubernetes, any clue how to solve them: ... calling verify-prereqs Can't find the necessary components for the parallels vagrant provider. Possible reasons could be: - vmrun utility is not in your path - Vagrant plugin was not found. - VAGRANT_DEFAULT_PROVIDER is set, but not found. Please fix and retry. ### Response: If you take a look at cluster/vagrant/util.sh, the possible providers are: vmware_fusion, vmware_workstation, parallels, virtualbox, libvirt, vsphere.
I got this errors when restarting or reinstalling Kubernetes, any clue how to solve them: ... calling verify-prereqs Can't find the necessary components for the parallels vagrant provider. Possible reasons could be: - vmrun utility is not in your path - Vagrant plugin was not found. - VAGRANT_DEFAULT_PROVIDER is set, but not found. Please fix and retry.
Setting up HA controllers for kubernetes is not trivial and I can't provide all the details here but I'll outline what was successful for me. Use kube-aws to set up a single-controller cluster: https://coreos.com/kubernetes/docs/latest/kubernetes-on-aws.html. This will create CloudFormation stack templates and cloud-config templates that you can use as a starting point. Go the AWS CloudFormation Management Console, click the "Template" tab and copy out the complete stack configuration. Alternatively, use $ kube-aws up --export to generate the cloudformation stack file. User the userdata cloud-config templates generated by kube-aws and replace the variables with actual values. This guide will help you determine what those values should be: https://coreos.com/kubernetes/docs/latest/getting-started.html. In my case I ended up with four cloud-configs: cloud-config-controller-0 cloud-config-controller-1 cloud-config-controller-2 cloud-config-worker Validate your new cloud-configs here: https://coreos.com/validate/ Insert your cloud-configs into the CloudFormation stack config. First compress and encode your cloud config: $ gzip -k cloud-config-controller-0 $ cat cloud-config-controller-0.gz | base64 > cloud-config-controller-0.enc Now copy the content into your encoded cloud-config into the CloudFormation config. Look for the UserData key for the appropriate InstanceController. (I added additional InstanceController objects for the additional controllers.) Update the stack at the AWS CloudFormation Management Console using your newly created CloudFormation config. You will also need to generate TLS asssets: https://coreos.com/kubernetes/docs/latest/openssl.html. These assets will have to be compressed and encoded (same gzip and base64 as above), then inserted into your userdata cloud-configs. When debugging on the server, journalctl is your friend: $ journalctl -u oem-cloudinit # to debug problems with your cloud-config $ journalctl -u etcd2 $ journalctl -u kubelet Hope that helps.
###Instruction: What I am trying to do: I have setup kubernete cluster using documentation available on Kubernetes website (http_kubernetes.io/v1.1/docs/getting-started-guides/aws.html). Using kube-up.sh, i was able to bring kubernete cluster up with 1 master and 3 minions (as highlighted in blue rectangle in the diagram below). From the documentation as far as i know we can add minions as and when required, So from my point of view k8s master instance is single point of failure when it comes to high availability. Kubernetes Master HA on AWS So I am trying to setup HA k8s master layer with the three master nodes as shown above in the diagram. For accomplishing this I am following kubernetes high availability cluster guide, http_kubernetes.io/v1.1/docs/admin/high-availability.html#establishing-a-redundant-reliable-data-storage-layer What I have done: Setup k8s cluster using kube-up.sh and provider aws (master1 and minion1, minion2, and minion3) Setup two fresh master instance’s (master2 and master3) I then started configuring etcd cluster on master1, master 2 and master 3 by following below mentioned link: http_kubernetes.io/v1.1/docs/admin/high-availability.html#establishing-a-redundant-reliable-data-storage-layer So in short i have copied etcd.yaml from the kubernetes website (http_kubernetes.io/v1.1/docs/admin/high-availability/etcd.yaml) and updated Node_IP, Node_Name and Discovery Token on all the three nodes as shown below. NODE_NAME NODE_IP DISCOVERY_TOKEN Master1 172.20.3.150 https_discovery.etcd.io/5d84f4e97f6e47b07bf81be243805bed Master2 172.20.3.200 https_discovery.etcd.io/5d84f4e97f6e47b07bf81be243805bed Master3 172.20.3.250 https_discovery.etcd.io/5d84f4e97f6e47b07bf81be243805bed And on running etcdctl member list on all the three nodes, I am getting: $ docker exec <container-id> etcdctl member list ce2a822cea30bfca: name=default peerURLs=http_localhost:2380,http_localhost:7001 clientURLs=http_127.0.0.1:4001 As per documentation we need to keep etcd.yaml in /etc/kubernete/manifest, this directory already contains etcd.manifest and etcd-event.manifest files. For testing I modified etcd.manifest file with etcd parameters. After making above changes I forcefully terminated docker container, container was existing after few seconds and I was getting below mentioned error on running kubectl get nodes: error: couldn't read version from server: Get httplocalhost:8080/api: dial tcp 127.0.0.1:8080: connection refused So please kindly suggest how can I setup k8s master highly available setup on AWS. ### Response: Setting up HA controllers for kubernetes is not trivial and I can't provide all the details here but I'll outline what was successful for me. Use kube-aws to set up a single-controller cluster: https://coreos.com/kubernetes/docs/latest/kubernetes-on-aws.html. This will create CloudFormation stack templates and cloud-config templates that you can use as a starting point. Go the AWS CloudFormation Management Console, click the "Template" tab and copy out the complete stack configuration. Alternatively, use $ kube-aws up --export to generate the cloudformation stack file. User the userdata cloud-config templates generated by kube-aws and replace the variables with actual values. This guide will help you determine what those values should be: https://coreos.com/kubernetes/docs/latest/getting-started.html. In my case I ended up with four cloud-configs: cloud-config-controller-0 cloud-config-controller-1 cloud-config-controller-2 cloud-config-worker Validate your new cloud-configs here: https://coreos.com/validate/ Insert your cloud-configs into the CloudFormation stack config. First compress and encode your cloud config: $ gzip -k cloud-config-controller-0 $ cat cloud-config-controller-0.gz | base64 > cloud-config-controller-0.enc Now copy the content into your encoded cloud-config into the CloudFormation config. Look for the UserData key for the appropriate InstanceController. (I added additional InstanceController objects for the additional controllers.) Update the stack at the AWS CloudFormation Management Console using your newly created CloudFormation config. You will also need to generate TLS asssets: https://coreos.com/kubernetes/docs/latest/openssl.html. These assets will have to be compressed and encoded (same gzip and base64 as above), then inserted into your userdata cloud-configs. When debugging on the server, journalctl is your friend: $ journalctl -u oem-cloudinit # to debug problems with your cloud-config $ journalctl -u etcd2 $ journalctl -u kubelet Hope that helps.
What I am trying to do: I have setup kubernete cluster using documentation available on Kubernetes website (http_kubernetes.io/v1.1/docs/getting-started-guides/aws.html). Using kube-up.sh, i was able to bring kubernete cluster up with 1 master and 3 minions (as highlighted in blue rectangle in the diagram below). From the documentation as far as i know we can add minions as and when required, So from my point of view k8s master instance is single point of failure when it comes to high availability. Kubernetes Master HA on AWS So I am trying to setup HA k8s master layer with the three master nodes as shown above in the diagram. For accomplishing this I am following kubernetes high availability cluster guide, http_kubernetes.io/v1.1/docs/admin/high-availability.html#establishing-a-redundant-reliable-data-storage-layer What I have done: Setup k8s cluster using kube-up.sh and provider aws (master1 and minion1, minion2, and minion3) Setup two fresh master instance’s (master2 and master3) I then started configuring etcd cluster on master1, master 2 and master 3 by following below mentioned link: http_kubernetes.io/v1.1/docs/admin/high-availability.html#establishing-a-redundant-reliable-data-storage-layer So in short i have copied etcd.yaml from the kubernetes website (http_kubernetes.io/v1.1/docs/admin/high-availability/etcd.yaml) and updated Node_IP, Node_Name and Discovery Token on all the three nodes as shown below. NODE_NAME NODE_IP DISCOVERY_TOKEN Master1 172.20.3.150 https_discovery.etcd.io/5d84f4e97f6e47b07bf81be243805bed Master2 172.20.3.200 https_discovery.etcd.io/5d84f4e97f6e47b07bf81be243805bed Master3 172.20.3.250 https_discovery.etcd.io/5d84f4e97f6e47b07bf81be243805bed And on running etcdctl member list on all the three nodes, I am getting: $ docker exec <container-id> etcdctl member list ce2a822cea30bfca: name=default peerURLs=http_localhost:2380,http_localhost:7001 clientURLs=http_127.0.0.1:4001 As per documentation we need to keep etcd.yaml in /etc/kubernete/manifest, this directory already contains etcd.manifest and etcd-event.manifest files. For testing I modified etcd.manifest file with etcd parameters. After making above changes I forcefully terminated docker container, container was existing after few seconds and I was getting below mentioned error on running kubectl get nodes: error: couldn't read version from server: Get httplocalhost:8080/api: dial tcp 127.0.0.1:8080: connection refused So please kindly suggest how can I setup k8s master highly available setup on AWS.
The Kubernetes Network-SIG team has been working on the network isolation issue for a while, and there is an experimental API in kubernetes 1.2 to support this. The basic idea is to provide network policy on a per-namespace basis. A third party network controller can then react to changes to resources and enforces the policy. See the last blog post about this topic for the details. EDIT: This answer is more about the open-source kubernetes, not for GKE specifically.
###Instruction: I'm trying to isolate services from one another. Suppose ops-human has a bunch of mysql stores running on Google Container Engine, and dev-human has a bunch of node apps running on the same cluster. I do NOT want dev-human to be able to access any of ops-human's mysql instances in any way. Simplest solution: put both of these in separate subnets. How do I do such a thing? I'm open to other implementations as well. ### Response: The Kubernetes Network-SIG team has been working on the network isolation issue for a while, and there is an experimental API in kubernetes 1.2 to support this. The basic idea is to provide network policy on a per-namespace basis. A third party network controller can then react to changes to resources and enforces the policy. See the last blog post about this topic for the details. EDIT: This answer is more about the open-source kubernetes, not for GKE specifically.
I'm trying to isolate services from one another. Suppose ops-human has a bunch of mysql stores running on Google Container Engine, and dev-human has a bunch of node apps running on the same cluster. I do NOT want dev-human to be able to access any of ops-human's mysql instances in any way. Simplest solution: put both of these in separate subnets. How do I do such a thing? I'm open to other implementations as well.
1) Is node 127.0.0.1 my local development machine? This has got me confused me the most. When a node registers, you provide the IP or name to register with. By default, the node is just registering 127.0.0.1. This is referencing your VM running linux, not your host machine. 2) Is my following understanding correct: The cluster (nodes, kubernetes API server) has internal IP addresses in 10.0.0.x and their corresponding external IP addresses are 192.168.99.x. The 2 pods will then have IPs in the range like 10.0.1.x and 10.0.2.x ? Yup, the 10.0.0.x network is your overlay network. The 192.168.99.x are your "public" addresses which are visible outside of the cluster. 3) Why is the external IP for the services not there? Not even, for the kubernetes service. Isn't the 192.168.99.43 an external IP here? The external IP is typically used to ingress traffic via a specific IP. The kubernetes service is using a clusterIP service type which means it's only visible to the internal cluster. 4) Most importantly, how do I connect to the nginx service from my laptop? The easiest way to view your nginx service is to make it type NodePort, then deploy the service. After that, describe the service to get the port that was assigned (or after you create it will tell you as well). Then hit the ip of your VM and provide the auto assigned NodePort. e.g. http://192.168.99.100:30001
###Instruction: I have installed minikube on my ubuntu 16.04 machine and have started a cluster, with a message "Kubernetes is available at https://192.168.99.100:443" Next, I deployed nginx service with the following command > kubectl.sh run my-nginx --image=nginx --replicas=2 --port=80 --expose > kubectl.sh get pods -o wide NAME READY STATUS RESTARTS AGE NODE my-nginx-2494149703-8jnh4 1/1 Running 0 13m 127.0.0.1 my-nginx-2494149703-q09be 1/1 Running 0 13m 127.0.0.1 > kubectl.sh get services -o wide NAME CLUSTER-IP EXTERNAL-IP PORT(S) AGE SELECTOR kubernetes 10.0.0.1 <none> 443/TCP 14m <none> my-nginx 10.0.0.83 <none> 80/TCP 13m run=my-nginx > kubectl.sh get nodes -o wide NAME STATUS AGE 127.0.0.1 Ready 16m Questions: 1) Is node 127.0.0.1 my local development machine? This has got me confused me the most. 2) Is my following understanding correct: The cluster (nodes, kubernetes API server) has internal IP addresses in 10.0.0.x and their corresponding external IP addresses are 192.168.99.x. The 2 pods will then have IPs in the range like 10.0.1.x and 10.0.2.x ? 3) Why is the external IP for the services not there? Not even, for the kubernetes service. Isn't the 192.168.99.43 an external IP here? 4) Most importantly, how do I connect to the nginx service from my laptop? ### Response: 1) Is node 127.0.0.1 my local development machine? This has got me confused me the most. When a node registers, you provide the IP or name to register with. By default, the node is just registering 127.0.0.1. This is referencing your VM running linux, not your host machine. 2) Is my following understanding correct: The cluster (nodes, kubernetes API server) has internal IP addresses in 10.0.0.x and their corresponding external IP addresses are 192.168.99.x. The 2 pods will then have IPs in the range like 10.0.1.x and 10.0.2.x ? Yup, the 10.0.0.x network is your overlay network. The 192.168.99.x are your "public" addresses which are visible outside of the cluster. 3) Why is the external IP for the services not there? Not even, for the kubernetes service. Isn't the 192.168.99.43 an external IP here? The external IP is typically used to ingress traffic via a specific IP. The kubernetes service is using a clusterIP service type which means it's only visible to the internal cluster. 4) Most importantly, how do I connect to the nginx service from my laptop? The easiest way to view your nginx service is to make it type NodePort, then deploy the service. After that, describe the service to get the port that was assigned (or after you create it will tell you as well). Then hit the ip of your VM and provide the auto assigned NodePort. e.g. http://192.168.99.100:30001
I have installed minikube on my ubuntu 16.04 machine and have started a cluster, with a message "Kubernetes is available at https://192.168.99.100:443" Next, I deployed nginx service with the following command > kubectl.sh run my-nginx --image=nginx --replicas=2 --port=80 --expose > kubectl.sh get pods -o wide NAME READY STATUS RESTARTS AGE NODE my-nginx-2494149703-8jnh4 1/1 Running 0 13m 127.0.0.1 my-nginx-2494149703-q09be 1/1 Running 0 13m 127.0.0.1 > kubectl.sh get services -o wide NAME CLUSTER-IP EXTERNAL-IP PORT(S) AGE SELECTOR kubernetes 10.0.0.1 <none> 443/TCP 14m <none> my-nginx 10.0.0.83 <none> 80/TCP 13m run=my-nginx > kubectl.sh get nodes -o wide NAME STATUS AGE 127.0.0.1 Ready 16m Questions: 1) Is node 127.0.0.1 my local development machine? This has got me confused me the most. 2) Is my following understanding correct: The cluster (nodes, kubernetes API server) has internal IP addresses in 10.0.0.x and their corresponding external IP addresses are 192.168.99.x. The 2 pods will then have IPs in the range like 10.0.1.x and 10.0.2.x ? 3) Why is the external IP for the services not there? Not even, for the kubernetes service. Isn't the 192.168.99.43 an external IP here? 4) Most importantly, how do I connect to the nginx service from my laptop?
If you use the stock controllers you will be able to switch on hostname and go to different backends services. It sounds like you don't want to enumerate all the subdomains -> service mappings, in which case you probably need to write your own controller that writes out an nginx config that uses $http_host in the appropriate proxy_pass or redirect lines. Give it a shot (https://github.com/kubernetes/contrib/tree/master/ingress/controllers) and file bugs in that same repo if you need help.
###Instruction: I need for each of my users to access a service at a custom url eg. abccompany.mycloudapp.com , each service being a kubernetes service I'm looking at ingress controllers but I need a way to use a wildcard host field and somehow read the value into the path: and service: fields ; here's a sample ingress controller of what I have in mind: apiVersion: extensions/v1beta1 kind: Ingress metadata: name: test spec: rules: - host: *.bar.com http: paths: - path: /{{ value of * in * .bar.com }} backend: serviceName: {{value of * in *.bar.com }}Svc servicePort: 80 ### Response: If you use the stock controllers you will be able to switch on hostname and go to different backends services. It sounds like you don't want to enumerate all the subdomains -> service mappings, in which case you probably need to write your own controller that writes out an nginx config that uses $http_host in the appropriate proxy_pass or redirect lines. Give it a shot (https://github.com/kubernetes/contrib/tree/master/ingress/controllers) and file bugs in that same repo if you need help.
I need for each of my users to access a service at a custom url eg. abccompany.mycloudapp.com , each service being a kubernetes service I'm looking at ingress controllers but I need a way to use a wildcard host field and somehow read the value into the path: and service: fields ; here's a sample ingress controller of what I have in mind: apiVersion: extensions/v1beta1 kind: Ingress metadata: name: test spec: rules: - host: *.bar.com http: paths: - path: /{{ value of * in * .bar.com }} backend: serviceName: {{value of * in *.bar.com }}Svc servicePort: 80
For AWS ELB you cannot make a permanent IP address as the IP address for AWS ELB is dynamic and changes frequently. So you have to use "aae55ce563ca611e692c10a83aef9ddc-467886677.eu-west-1.elb.amazonaws.com" as the Canonical name for your application. Also refer this question Amazon EC2 Elastic Load Balancer: Does its IP ever Change?
###Instruction: How can I publish a service in an AWS kubernetes cluster at a permanent IP address, so that I can add a DNS record? I define service xxx of type LoadBalancer in kubernetes, and kubectl describe service xxx gives me something like: LoadBalancer Ingress: aae55ce563ca611e692c10a83aef9ddc-467886677.eu-west-1.elb.amazonaws.com Port: <unset> 9004/TCP Indeed, I can access the application on aae55ce563ca611e692c10a83aef9ddc-467886677.eu-west-1.elb.amazonaws.com:9004. How can I make this a permanent IP address? ### Response: For AWS ELB you cannot make a permanent IP address as the IP address for AWS ELB is dynamic and changes frequently. So you have to use "aae55ce563ca611e692c10a83aef9ddc-467886677.eu-west-1.elb.amazonaws.com" as the Canonical name for your application. Also refer this question Amazon EC2 Elastic Load Balancer: Does its IP ever Change?
How can I publish a service in an AWS kubernetes cluster at a permanent IP address, so that I can add a DNS record? I define service xxx of type LoadBalancer in kubernetes, and kubectl describe service xxx gives me something like: LoadBalancer Ingress: aae55ce563ca611e692c10a83aef9ddc-467886677.eu-west-1.elb.amazonaws.com Port: <unset> 9004/TCP Indeed, I can access the application on aae55ce563ca611e692c10a83aef9ddc-467886677.eu-west-1.elb.amazonaws.com:9004. How can I make this a permanent IP address?
You can use rolling update which creates a temporarpy replication controller to scale the new version of the pods up, and then scales down the old version afterwards. In the future, you might want to swtich to using Deployment, which allows declarative deployments.
###Instruction: I have a kubernetes container running on GCE. One of the service is nginx that working as proxy, and with replication controller it hass 10 replicas. Now i need to change the nginx.conf for some tweaking. Is there a way for me to reload all the nginx pods? Right now the only way for me is scale it 0, then scale it up again to 10. This will cause short downtime. ### Response: You can use rolling update which creates a temporarpy replication controller to scale the new version of the pods up, and then scales down the old version afterwards. In the future, you might want to swtich to using Deployment, which allows declarative deployments.
I have a kubernetes container running on GCE. One of the service is nginx that working as proxy, and with replication controller it hass 10 replicas. Now i need to change the nginx.conf for some tweaking. Is there a way for me to reload all the nginx pods? Right now the only way for me is scale it 0, then scale it up again to 10. This will cause short downtime.
You need a rediness probe on your Green pods. Cluster DNS will only work within a single cluster, so you will have to put both your nginx pods (green and grid) behind a single service, and use the DNS name of that service to talk to it. Then if one of the pods fails a readiness probe, all traffic directed to the cluster DNS name will get sent to the others. Example nginx pod with readiness probe: https://github.com/kubernetes/kubernetes/blob/master/test/e2e/testing-manifests/kubectl/pod-with-readiness-probe.yaml
###Instruction: I have a set of http server instances. We can assume a simple apache or nginx instances. However, the set of instances comprises of two sub-sets, (1) instances that runs in an infrastructure that fed by green energy (2) infra. that runs on regular grid energy. The two runs the SAME software stack, say kubernetes. Also, it can run in the same WAN if not LAN, i.e., same datacenter. I want to load-balance traffic to the first resource set, the green set, when I have green energy available. Lets assume I have an optimized mechanism that knows when I have enough green-energy to run a workload. How can I use clusterDNS to allow traffic to the set of pods that are fed by green-energy. In other words I want to have the clusterDNS to biased toward a specific resource set. Also, I want to know how can populate instances (and exclude) dynamically to the green-energy pods sets? I tired to look at https://github.com/kubernetes/kubernetes/tree/release-1.2/examples/cluster-dns/README.html but it is not available and I wonder if you can share some ideas on how to tackle this using kubernetes. ### Response: You need a rediness probe on your Green pods. Cluster DNS will only work within a single cluster, so you will have to put both your nginx pods (green and grid) behind a single service, and use the DNS name of that service to talk to it. Then if one of the pods fails a readiness probe, all traffic directed to the cluster DNS name will get sent to the others. Example nginx pod with readiness probe: https://github.com/kubernetes/kubernetes/blob/master/test/e2e/testing-manifests/kubectl/pod-with-readiness-probe.yaml
I have a set of http server instances. We can assume a simple apache or nginx instances. However, the set of instances comprises of two sub-sets, (1) instances that runs in an infrastructure that fed by green energy (2) infra. that runs on regular grid energy. The two runs the SAME software stack, say kubernetes. Also, it can run in the same WAN if not LAN, i.e., same datacenter. I want to load-balance traffic to the first resource set, the green set, when I have green energy available. Lets assume I have an optimized mechanism that knows when I have enough green-energy to run a workload. How can I use clusterDNS to allow traffic to the set of pods that are fed by green-energy. In other words I want to have the clusterDNS to biased toward a specific resource set. Also, I want to know how can populate instances (and exclude) dynamically to the green-energy pods sets? I tired to look at https://github.com/kubernetes/kubernetes/tree/release-1.2/examples/cluster-dns/README.html but it is not available and I wonder if you can share some ideas on how to tackle this using kubernetes.
I managed to solve this issue by removing all kubectl configurations and reinstalling it. Make sure after downloading, the binary is executable and move it into your PATH: $ chmod +x kubectl $ mv kubectl /usr/local/bin/kubectl
###Instruction: I have started playing with kubernetes. I followed the guide to set it up locally via minikube. I have perfectly managed to configure I am facing a weird issue. Whenever I try running some command using kubectl I get segmentation fault (core dumped). Even when I tried accessing the directory 'kubectl', it threw the same error. I have searched around the internet and have tried different solutions, but no luck ### Response: I managed to solve this issue by removing all kubectl configurations and reinstalling it. Make sure after downloading, the binary is executable and move it into your PATH: $ chmod +x kubectl $ mv kubectl /usr/local/bin/kubectl
I have started playing with kubernetes. I followed the guide to set it up locally via minikube. I have perfectly managed to configure I am facing a weird issue. Whenever I try running some command using kubectl I get segmentation fault (core dumped). Even when I tried accessing the directory 'kubectl', it threw the same error. I have searched around the internet and have tried different solutions, but no luck
I found the answer myself. 2 causes: (1) There is an environment variable specific to my web app that I forgot to set in apache.wsgi; (2) There are several small errors in the original apache configuration file. I post the working /etc/apache2/sites-available/000-default.conf here: ServerName 0.0.0.0 <VirtualHost _default_:443> DocumentRoot /usr/local/my_app LoadModule ssl_module /usr/lib64/apache2-prefork/mod_ssl.so SSLEngine on SSLCertificateFile /etc/letsencrypt/live/host/cert1.pem SSLCertificateKeyFile /etc/letsencrypt/live/host/privkey1.pem SSLCertificateChainFile /etc/letsencrypt/live/host/chain1.pem WSGIDaemonProcess python-app user=www-data group=www-data threads=15 maximum-requests=10000 python-path=/usr/local/lib/python2.7/dist-packages WSGIScriptAlias / /usr/local/my_app/apache/apache.wsgi WSGIProcessGroup python-app CustomLog "|/usr/bin/rotatelogs /usr/local/my_app/apache/logs/access.log.%Y%m%d-%H%M%S 5M" combined ErrorLog "|/usr/bin/rotatelogs /usr/local/my_app/apache/logs/error.log.%Y%m%d-%H%M%S 5M" LogLevel warn <Directory /usr/local/my_app> Order deny,allow Allow from all Require all granted </Directory> </VirtualHost> Start the pod with commands sudo a2enmod ssl && sudo /usr/sbin/apache2ctl -D FOREGROUND, and containerPort should be 443. The Kubernetes script for the service is as simple as follows: apiVersion: v1 kind: Service metadata: name: web labels: name: web spec: type: NodePort ports: - nodePort: 30001 port: 443 targetPort: 443 protocol: TCP selector: name: web Now I can visit my web site at https://XXX.XXX.XXX.XXX:30001. Special thanks to the owner of this github repo and NorbertvanNobelen. Hope this helps!
###Instruction: I have a local Kubernetes cluster on a single machine, and I successfully deployed a flask web app using apache server, so there shouldn't be any problem with the cluster setup. However, I need to upgrade the website to https, so I used letsencrypt to generate ssl certificates and volume mapped them into the container. I also successfully deployed the app without docker, i.e. directly start the apache server using sudo /usr/sbin/apache2ctl -D FOREGROUND. I can visit my website at https://XXX.XXX.XXX.edu without problem. However, when I started putting everything into Docker and Kubernetes, and visited https://XXX.XXX.XXX.edu:30001, the browser gave me this error: This site can’t be reached XXX.XXX.XXX.edu took too long to respond Here is how I deployed: I first started the service kubectl create -f web-service.yaml: apiVersion: v1 kind: Service metadata: name: web labels: name: web role: "ssl-proxy" spec: type: NodePort ports: - nodePort: 30001 name: "https" port: 443 targetPort: 443 protocol: "TCP" - nodePort: 30000 name: "http" port: 80 targetPort: 80 protocol: "TCP" selector: name: web role: "ssl-proxy" Then I started the pod kubectl create -f web-controller.yaml: apiVersion: v1 kind: ReplicationController metadata: labels: name: web name: web-controller spec: replicas: 1 selector: name: web template: metadata: labels: name: web spec: containers: - image: XXX/web_app command: ['/bin/sh', '-c'] args: ['sudo a2enmod ssl && service apache2 restart && sudo /usr/sbin/apache2ctl -D FOREGROUND && python fake.py'] name: web ports: - containerPort: 443 name: http-server volumeMounts: - mountPath: /etc/letsencrypt/live/host name: test-volume readOnly: false volumes: - hostPath: path: /etc/letsencrypt/archive/XXX.XXX.XXX.edu name: test-volume The log of the pod looks like: root@XXX:~# kubectl logs web-controller-ontne Considering dependency setenvif for ssl: Module setenvif already enabled Considering dependency mime for ssl: Module mime already enabled Considering dependency socache_shmcb for ssl: Module socache_shmcb already enabled Module ssl already enabled * Restarting web server apache2 [Mon Jun 27 14:34:48.753153 2016] [so:warn] [pid 30:tid 140046645868416] AH01574: module ssl_module is already loaded, skipping ...done. [Mon Jun 27 14:34:49.820047 2016] [so:warn] [pid 119:tid 139909591328640] AH01574: module ssl_module is already loaded, skipping httpd (pid 33) already running root@XXX:~# The pod is running, but I got the following apache error log: [Mon Jun 27 17:13:50.912683 2016] [ssl:warn] [pid 33:tid 140513871427456] AH01909: RSA certificate configured for 0.0.0.0i:443 does NOT include an ID which matches the server name I think the problem is that, I am using NodePort and exposing port 30001, so I have to visit https://XXX.XXX.XXX.edu:30001 which does not match XXX.XXX.XXX.edu (just the domain name without the arbitrary port number 30001). This is my /etc/apache2/sites-available/000-default.conf in the docker container: <VirtualHost _default_:30001> DocumentRoot /usr/local/my_app LoadModule ssl_module /usr/lib64/apache2-prefork/mod_ssl.so SSLEngine on SSLCertificateFile /etc/letsencrypt/live/host/cert1.pem SSLCertificateKeyFile /etc/letsencrypt/live/host/privkey1.pem SSLCertificateChainFile /etc/letsencrypt/live/host/chain1.pem WSGIDaemonProcess python-app user=www-data group=www-data threads=15 maximum-requests=10000 python-path=/usr/local/lib/python2.7/dist-p ackages WSGIScriptAlias / /usr/local/my_app/apache/apache.wsgi WSGIProcessGroup python-app CustomLog "|/usr/bin/rotatelogs /usr/local/my_app/apache/logs/access.log.%Y%m%d-%H%M%S 5M" combined ErrorLog "|/usr/bin/rotatelogs /usr/local/my_app/apache/logs/error.log.%Y%m%d-%H%M%S 5M" LogLevel warn <Directory /usr/local/my_app> Order deny,allow Allow from all Require all granted </Directory> </VirtualHost> How to modify it so that apache serves https requests at port 30001 rather than 443? Thank you very much! ### Response: I found the answer myself. 2 causes: (1) There is an environment variable specific to my web app that I forgot to set in apache.wsgi; (2) There are several small errors in the original apache configuration file. I post the working /etc/apache2/sites-available/000-default.conf here: ServerName 0.0.0.0 <VirtualHost _default_:443> DocumentRoot /usr/local/my_app LoadModule ssl_module /usr/lib64/apache2-prefork/mod_ssl.so SSLEngine on SSLCertificateFile /etc/letsencrypt/live/host/cert1.pem SSLCertificateKeyFile /etc/letsencrypt/live/host/privkey1.pem SSLCertificateChainFile /etc/letsencrypt/live/host/chain1.pem WSGIDaemonProcess python-app user=www-data group=www-data threads=15 maximum-requests=10000 python-path=/usr/local/lib/python2.7/dist-packages WSGIScriptAlias / /usr/local/my_app/apache/apache.wsgi WSGIProcessGroup python-app CustomLog "|/usr/bin/rotatelogs /usr/local/my_app/apache/logs/access.log.%Y%m%d-%H%M%S 5M" combined ErrorLog "|/usr/bin/rotatelogs /usr/local/my_app/apache/logs/error.log.%Y%m%d-%H%M%S 5M" LogLevel warn <Directory /usr/local/my_app> Order deny,allow Allow from all Require all granted </Directory> </VirtualHost> Start the pod with commands sudo a2enmod ssl && sudo /usr/sbin/apache2ctl -D FOREGROUND, and containerPort should be 443. The Kubernetes script for the service is as simple as follows: apiVersion: v1 kind: Service metadata: name: web labels: name: web spec: type: NodePort ports: - nodePort: 30001 port: 443 targetPort: 443 protocol: TCP selector: name: web Now I can visit my web site at https://XXX.XXX.XXX.XXX:30001. Special thanks to the owner of this github repo and NorbertvanNobelen. Hope this helps!
I have a local Kubernetes cluster on a single machine, and I successfully deployed a flask web app using apache server, so there shouldn't be any problem with the cluster setup. However, I need to upgrade the website to https, so I used letsencrypt to generate ssl certificates and volume mapped them into the container. I also successfully deployed the app without docker, i.e. directly start the apache server using sudo /usr/sbin/apache2ctl -D FOREGROUND. I can visit my website at https://XXX.XXX.XXX.edu without problem. However, when I started putting everything into Docker and Kubernetes, and visited https://XXX.XXX.XXX.edu:30001, the browser gave me this error: This site can’t be reached XXX.XXX.XXX.edu took too long to respond Here is how I deployed: I first started the service kubectl create -f web-service.yaml: apiVersion: v1 kind: Service metadata: name: web labels: name: web role: "ssl-proxy" spec: type: NodePort ports: - nodePort: 30001 name: "https" port: 443 targetPort: 443 protocol: "TCP" - nodePort: 30000 name: "http" port: 80 targetPort: 80 protocol: "TCP" selector: name: web role: "ssl-proxy" Then I started the pod kubectl create -f web-controller.yaml: apiVersion: v1 kind: ReplicationController metadata: labels: name: web name: web-controller spec: replicas: 1 selector: name: web template: metadata: labels: name: web spec: containers: - image: XXX/web_app command: ['/bin/sh', '-c'] args: ['sudo a2enmod ssl && service apache2 restart && sudo /usr/sbin/apache2ctl -D FOREGROUND && python fake.py'] name: web ports: - containerPort: 443 name: http-server volumeMounts: - mountPath: /etc/letsencrypt/live/host name: test-volume readOnly: false volumes: - hostPath: path: /etc/letsencrypt/archive/XXX.XXX.XXX.edu name: test-volume The log of the pod looks like: root@XXX:~# kubectl logs web-controller-ontne Considering dependency setenvif for ssl: Module setenvif already enabled Considering dependency mime for ssl: Module mime already enabled Considering dependency socache_shmcb for ssl: Module socache_shmcb already enabled Module ssl already enabled * Restarting web server apache2 [Mon Jun 27 14:34:48.753153 2016] [so:warn] [pid 30:tid 140046645868416] AH01574: module ssl_module is already loaded, skipping ...done. [Mon Jun 27 14:34:49.820047 2016] [so:warn] [pid 119:tid 139909591328640] AH01574: module ssl_module is already loaded, skipping httpd (pid 33) already running root@XXX:~# The pod is running, but I got the following apache error log: [Mon Jun 27 17:13:50.912683 2016] [ssl:warn] [pid 33:tid 140513871427456] AH01909: RSA certificate configured for 0.0.0.0i:443 does NOT include an ID which matches the server name I think the problem is that, I am using NodePort and exposing port 30001, so I have to visit https://XXX.XXX.XXX.edu:30001 which does not match XXX.XXX.XXX.edu (just the domain name without the arbitrary port number 30001). This is my /etc/apache2/sites-available/000-default.conf in the docker container: <VirtualHost _default_:30001> DocumentRoot /usr/local/my_app LoadModule ssl_module /usr/lib64/apache2-prefork/mod_ssl.so SSLEngine on SSLCertificateFile /etc/letsencrypt/live/host/cert1.pem SSLCertificateKeyFile /etc/letsencrypt/live/host/privkey1.pem SSLCertificateChainFile /etc/letsencrypt/live/host/chain1.pem WSGIDaemonProcess python-app user=www-data group=www-data threads=15 maximum-requests=10000 python-path=/usr/local/lib/python2.7/dist-p ackages WSGIScriptAlias / /usr/local/my_app/apache/apache.wsgi WSGIProcessGroup python-app CustomLog "|/usr/bin/rotatelogs /usr/local/my_app/apache/logs/access.log.%Y%m%d-%H%M%S 5M" combined ErrorLog "|/usr/bin/rotatelogs /usr/local/my_app/apache/logs/error.log.%Y%m%d-%H%M%S 5M" LogLevel warn <Directory /usr/local/my_app> Order deny,allow Allow from all Require all granted </Directory> </VirtualHost> How to modify it so that apache serves https requests at port 30001 rather than 443? Thank you very much!
As @error2007s said, you can't get a static IP for ELB. But if all you want is to assign a domain name to your ELB, then you can use a CNAME record pointing to aae55ce563ca611e692c10a83aef9ddc-467886677.eu-west-1.elb.amazonaws.com. If you're using Route53 you can also define an alias for better performance. Create a record set under your hosted zone, choose type A, select Yes under "Alias: ", and finally select your ELB from the dropdown box. Both options are documented by Amazon: http://docs.aws.amazon.com/ElasticLoadBalancing/latest/DeveloperGuide/using-domain-names-with-elb.html
###Instruction: How can I publish a service in an AWS kubernetes cluster at a permanent IP address, so that I can add a DNS record? I define service xxx of type LoadBalancer in kubernetes, and kubectl describe service xxx gives me something like: LoadBalancer Ingress: aae55ce563ca611e692c10a83aef9ddc-467886677.eu-west-1.elb.amazonaws.com Port: <unset> 9004/TCP Indeed, I can access the application on aae55ce563ca611e692c10a83aef9ddc-467886677.eu-west-1.elb.amazonaws.com:9004. How can I make this a permanent IP address? ### Response: As @error2007s said, you can't get a static IP for ELB. But if all you want is to assign a domain name to your ELB, then you can use a CNAME record pointing to aae55ce563ca611e692c10a83aef9ddc-467886677.eu-west-1.elb.amazonaws.com. If you're using Route53 you can also define an alias for better performance. Create a record set under your hosted zone, choose type A, select Yes under "Alias: ", and finally select your ELB from the dropdown box. Both options are documented by Amazon: http://docs.aws.amazon.com/ElasticLoadBalancing/latest/DeveloperGuide/using-domain-names-with-elb.html
How can I publish a service in an AWS kubernetes cluster at a permanent IP address, so that I can add a DNS record? I define service xxx of type LoadBalancer in kubernetes, and kubectl describe service xxx gives me something like: LoadBalancer Ingress: aae55ce563ca611e692c10a83aef9ddc-467886677.eu-west-1.elb.amazonaws.com Port: <unset> 9004/TCP Indeed, I can access the application on aae55ce563ca611e692c10a83aef9ddc-467886677.eu-west-1.elb.amazonaws.com:9004. How can I make this a permanent IP address?
There's a separate container that'll have the network stats for your entire pod, since all the containers in a pod share the same network namespace. If your container is named skydns and its pod is named kube-dns in the kube-system namespace (and thus the name of your skydns container looks something like k8s_skydns.<short-hash>_kube-dns-v11-ulru9_kube-system_<hash>), then there'll be another container called k8s_POD.<short-hash>_kube-dns-v11-ulru9_kube-system_<hash>, which the distinguishing characteristic being that it has the string POD where the container name typically goes. There was a discussion explaining the purpose of the pause container on the Kubernertes email list here: https://groups.google.com/forum/#!topic/google-containers/jVjv0QK4b_o
###Instruction: facing some problem while using docker stats command in kubernetes.. While i using docker stats in my kube-node its not displaying the NET I/O.. My kube version is 1.2.4 and my docker version is 1.9.1. CONTAINER CPU % MEM USAGE / LIMIT MEM % NET I/O BLOCK I/O 494ffcff748a 0.06% 508.2 MB / 7.864 GB 6.46% 0 B / 0 B 106.4 MB / 5.841 MB Particularly in GKE its not showing NET I/O. Do i need to enable anything to get this NET I/O values?.. Thanks Advance... ### Response: There's a separate container that'll have the network stats for your entire pod, since all the containers in a pod share the same network namespace. If your container is named skydns and its pod is named kube-dns in the kube-system namespace (and thus the name of your skydns container looks something like k8s_skydns.<short-hash>_kube-dns-v11-ulru9_kube-system_<hash>), then there'll be another container called k8s_POD.<short-hash>_kube-dns-v11-ulru9_kube-system_<hash>, which the distinguishing characteristic being that it has the string POD where the container name typically goes. There was a discussion explaining the purpose of the pause container on the Kubernertes email list here: https://groups.google.com/forum/#!topic/google-containers/jVjv0QK4b_o
facing some problem while using docker stats command in kubernetes.. While i using docker stats in my kube-node its not displaying the NET I/O.. My kube version is 1.2.4 and my docker version is 1.9.1. CONTAINER CPU % MEM USAGE / LIMIT MEM % NET I/O BLOCK I/O 494ffcff748a 0.06% 508.2 MB / 7.864 GB 6.46% 0 B / 0 B 106.4 MB / 5.841 MB Particularly in GKE its not showing NET I/O. Do i need to enable anything to get this NET I/O values?.. Thanks Advance...
I left the cluster overnight and it is now working. It either seems it takes quite some to bootstrap or something was fixed on the Google Cloud side.
###Instruction: I'm new to Kubernetes and I'm trying to do HTTP Load Balancing on Google Container Engine with TLS (using the included GCE Ingress Controller). The error I have is repeatable even following Google's official tutorial. For readability I summarize the procedure in config.yaml: apiVersion: extensions/v1beta1 kind: Deployment metadata: name: nginx spec: replicas: 1 template: metadata: labels: name: nginx spec: containers: - name: nginx image: nginx ports: - containerPort: 80 --- apiVersion: v1 kind: Service metadata: name: nginx labels: name: nginx spec: type: NodePort ports: - port: 80 targetPort: 80 selector: name: nginx --- apiVersion: extensions/v1beta1 kind: Ingress metadata: name: basic-ingress spec: backend: serviceName: nginx servicePort: 80 Then: kubectl create -f config.yaml export NODE_PORT=$(kubectl get -o jsonpath="{.spec.ports[0].nodePort}" services nginx) gcloud compute firewall-rules create allow-130-211-0-0-22 --source-ranges 130.211.0.0/22 --allow tcp:$NODE_PORT curl <ip_of_load_balancer> (I removed the tags on the firewall rule so it will apply for all). But I get a 502 Server Error, which according to the docs means it's likely bootstrapping (but it always stays like this). I can see on the console that the backend is unhealthy. In the docs, to avoid this one needs: a firewall rule (which is done above) Service must respond with 200 (but I tested the nginx image locally and the service via a general Load Balancer, works fine) So what is the cause of this error and how can I further debug this? ### Response: I left the cluster overnight and it is now working. It either seems it takes quite some to bootstrap or something was fixed on the Google Cloud side.
I'm new to Kubernetes and I'm trying to do HTTP Load Balancing on Google Container Engine with TLS (using the included GCE Ingress Controller). The error I have is repeatable even following Google's official tutorial. For readability I summarize the procedure in config.yaml: apiVersion: extensions/v1beta1 kind: Deployment metadata: name: nginx spec: replicas: 1 template: metadata: labels: name: nginx spec: containers: - name: nginx image: nginx ports: - containerPort: 80 --- apiVersion: v1 kind: Service metadata: name: nginx labels: name: nginx spec: type: NodePort ports: - port: 80 targetPort: 80 selector: name: nginx --- apiVersion: extensions/v1beta1 kind: Ingress metadata: name: basic-ingress spec: backend: serviceName: nginx servicePort: 80 Then: kubectl create -f config.yaml export NODE_PORT=$(kubectl get -o jsonpath="{.spec.ports[0].nodePort}" services nginx) gcloud compute firewall-rules create allow-130-211-0-0-22 --source-ranges 130.211.0.0/22 --allow tcp:$NODE_PORT curl <ip_of_load_balancer> (I removed the tags on the firewall rule so it will apply for all). But I get a 502 Server Error, which according to the docs means it's likely bootstrapping (but it always stays like this). I can see on the console that the backend is unhealthy. In the docs, to avoid this one needs: a firewall rule (which is done above) Service must respond with 200 (but I tested the nginx image locally and the service via a general Load Balancer, works fine) So what is the cause of this error and how can I further debug this?
There is not a command that will allow you to restart the Kubernetes master in GKE (since the master is considered a part of the managed service). There is automated infrastructure (and then an oncall engineer from Google) that is responsible for restarting the master if it is unhealthy. In this particular cases, restarting the master had no effect on restoring it to normal behavior because Google Compute Engine Incident #16011 caused an outage on 2016-06-28 for GKE masters running in us-central1-a (even though that isn't indicated on the Google Cloud Status Dashboard). During the incident, many masters were unavailable. If you had tried to create a GCE cluster using kube-up.sh during that time, you would have similarly seen that it would be unable to create a functional master VM due to the SSD Persistent disk latency issues.
###Instruction: The kubernetes master in one of my GKE clusters became unresponsive last night following the infrastructure issue in us-central1-a. Whenever I run "kubectl get pods" in the default namespace I get the following error message: Error from server: an error on the server has prevented the request from succeeding If I run "kubectl get pods --namespace=kube-system", I only see the kube-proxy and the fluentd-logging daemon. I have trying scaling the cluster down to 0 and then scaling it back up. I have also tried downgrading and upgrading the cluster but that seems to apply only to the nodes (not the master). Is there any GKE/K8S API command to issue a restart to the kubernetes master? ### Response: There is not a command that will allow you to restart the Kubernetes master in GKE (since the master is considered a part of the managed service). There is automated infrastructure (and then an oncall engineer from Google) that is responsible for restarting the master if it is unhealthy. In this particular cases, restarting the master had no effect on restoring it to normal behavior because Google Compute Engine Incident #16011 caused an outage on 2016-06-28 for GKE masters running in us-central1-a (even though that isn't indicated on the Google Cloud Status Dashboard). During the incident, many masters were unavailable. If you had tried to create a GCE cluster using kube-up.sh during that time, you would have similarly seen that it would be unable to create a functional master VM due to the SSD Persistent disk latency issues.
The kubernetes master in one of my GKE clusters became unresponsive last night following the infrastructure issue in us-central1-a. Whenever I run "kubectl get pods" in the default namespace I get the following error message: Error from server: an error on the server has prevented the request from succeeding If I run "kubectl get pods --namespace=kube-system", I only see the kube-proxy and the fluentd-logging daemon. I have trying scaling the cluster down to 0 and then scaling it back up. I have also tried downgrading and upgrading the cluster but that seems to apply only to the nodes (not the master). Is there any GKE/K8S API command to issue a restart to the kubernetes master?
This problem has been documented several times, for example here https://github.com/kubernetes/kubernetes/issues/14642. Kubernetes v1.3.0 should have a fix. As a workaround (in GCP) you can restart your VMs. Hope this helps!
###Instruction: this is getting out of hand... have good specs of GKE, yet, I'm getting timeout for mount paths, I have posted this issue in github, but they said, it would be better if posted in SO. please fix this.. 2m 2m 1 {scheduler } Scheduled Successfully assigned mongodb-shard1-master-gp0qa to gke-cluster-1-micro-a0f27b19-node-0p2j 1m 1m 1 {kubelet gke-cluster-1-micro-a0f27b19-node-0p2j} FailedMount Unable to mount volumes for pod "mongodb-shard1-master-gp0qa_default": Could not attach GCE PD "shard1-node1-master". Timeout waiting for mount paths to be created. 1m 1m 1 {kubelet gke-cluster-1-micro-a0f27b19-node-0p2j} FailedSync Error syncing pod, skipping: Could not attach GCE PD "shard1-node1-master". Timeout waiting for mount paths to be created. ### Response: This problem has been documented several times, for example here https://github.com/kubernetes/kubernetes/issues/14642. Kubernetes v1.3.0 should have a fix. As a workaround (in GCP) you can restart your VMs. Hope this helps!
this is getting out of hand... have good specs of GKE, yet, I'm getting timeout for mount paths, I have posted this issue in github, but they said, it would be better if posted in SO. please fix this.. 2m 2m 1 {scheduler } Scheduled Successfully assigned mongodb-shard1-master-gp0qa to gke-cluster-1-micro-a0f27b19-node-0p2j 1m 1m 1 {kubelet gke-cluster-1-micro-a0f27b19-node-0p2j} FailedMount Unable to mount volumes for pod "mongodb-shard1-master-gp0qa_default": Could not attach GCE PD "shard1-node1-master". Timeout waiting for mount paths to be created. 1m 1m 1 {kubelet gke-cluster-1-micro-a0f27b19-node-0p2j} FailedSync Error syncing pod, skipping: Could not attach GCE PD "shard1-node1-master". Timeout waiting for mount paths to be created.
GKE does support custom subnet networks. The problem you're having is that GKE enforces that the cluster-ipv4-cidr range is disjoint from all subnetworks in which VMs may have their IPs allocated from, because that would lead to ambiguity in where packets should be routed on the internal network. cluster-ipv4-cidr determines which CIDR ranges should be used for the containers in the cluster, while the subnet used determines which IP addresses are used for all VMs created in that network. To fix the problem, simply stop specifying the --cluster-ipv4-cidr flag in your gcloud command. GKE will then pick a safe cluster-ipv4-cidr range for you.
###Instruction: I'm trying to launch a GKE cluster with a "custom" type network, vs. a "auto" type network. I use the following command to launch my cluster: $ gcloud container clusters create --cluster-ipv4-cidr=10.0.0.0/14 --network=ttest --subnetwork=ttest --num-nodes=1 jt I get the following error: Creating cluster jt...done. ERROR: (gcloud.container.clusters.create) Operation [<Operation name: u'operation-1467037655793-e319dc5e' operationType: OperationTypeValueValuesEnum(CREATE_CLUSTER, 1) selfLink: u'https://container.googleapis.com/v1/projects/TRUNCATED/zones/us-east1-b/operations/operation-1467037655793-e319dc5e' status: StatusValueValuesEnum(DONE, 3) statusMessage: u'Requested CIDR 10.0.0.0/14 is not available in network "ttest".' targetLink: u'https://container.googleapis.com/v1/projects/TRUNCATED/zones/us-east1-b/clusters/jt' zone: u'us-east1-b'>] finished with error: Requested CIDR 10.0.0.0/14 is not available in network "ttest". It seems to want a network or subnetwork with a /14 address range, so the command should ideally work, but it doesn't. Which is very odd, because here is what my networks look like: The ttest network: $ gcloud compute networks describe ttest autoCreateSubnetworks: false creationTimestamp: '2016-06-27T07:25:03.691-07:00' id: '5404409453117999568' kind: compute#network name: ttest selfLink: https://www.googleapis.com/compute/v1/projects/myproject/global/networks/ttest subnetworks: - https://www.googleapis.com/compute/v1/projects/myproject/regions/us-east1/subnetworks/ttest x_gcloud_mode: custom The ttest subnetwork: $ gcloud compute networks subnets describe ttest creationTimestamp: '2016-06-27T07:25:21.649-07:00' gatewayAddress: 10.0.0.1 id: '6237639993374575038' ipCidrRange: 10.0.0.0/14 kind: compute#subnetwork name: ttest network: https://www.googleapis.com/compute/v1/projects/myproject/global/networks/ttest region: https://www.googleapis.com/compute/v1/projects/myproject/regions/us-east1 selfLink: https://www.googleapis.com/compute/v1/projects/myproject/regions/us-east1/subnetworks/ttest I've tried the same thing with a manually created legacy network with --range=10.0.0.0/8 and then tried creating a cluster in that network, that doesn't seem to work either. It would seem the /14 rule is hardcoded into the GKE configs somewhere, but I don't really know what it wants in the custom network to launch the containers. The GKE container launch command works with any network where the mode/type is "auto". I pored over whatever documentation seemed relevant to me, but without much luck. The only that sticks out the following snippet from this page: The following restrictions exist when using subnetworks with other products: Google Managed VMs: Supported only on auto subnetwork networks. Cannot be deployed in a custom subnet networks. Does GKE use Managed VMs under the hood? Is that what's causing the problem? ### Response: GKE does support custom subnet networks. The problem you're having is that GKE enforces that the cluster-ipv4-cidr range is disjoint from all subnetworks in which VMs may have their IPs allocated from, because that would lead to ambiguity in where packets should be routed on the internal network. cluster-ipv4-cidr determines which CIDR ranges should be used for the containers in the cluster, while the subnet used determines which IP addresses are used for all VMs created in that network. To fix the problem, simply stop specifying the --cluster-ipv4-cidr flag in your gcloud command. GKE will then pick a safe cluster-ipv4-cidr range for you.
I'm trying to launch a GKE cluster with a "custom" type network, vs. a "auto" type network. I use the following command to launch my cluster: $ gcloud container clusters create --cluster-ipv4-cidr=10.0.0.0/14 --network=ttest --subnetwork=ttest --num-nodes=1 jt I get the following error: Creating cluster jt...done. ERROR: (gcloud.container.clusters.create) Operation [<Operation name: u'operation-1467037655793-e319dc5e' operationType: OperationTypeValueValuesEnum(CREATE_CLUSTER, 1) selfLink: u'https://container.googleapis.com/v1/projects/TRUNCATED/zones/us-east1-b/operations/operation-1467037655793-e319dc5e' status: StatusValueValuesEnum(DONE, 3) statusMessage: u'Requested CIDR 10.0.0.0/14 is not available in network "ttest".' targetLink: u'https://container.googleapis.com/v1/projects/TRUNCATED/zones/us-east1-b/clusters/jt' zone: u'us-east1-b'>] finished with error: Requested CIDR 10.0.0.0/14 is not available in network "ttest". It seems to want a network or subnetwork with a /14 address range, so the command should ideally work, but it doesn't. Which is very odd, because here is what my networks look like: The ttest network: $ gcloud compute networks describe ttest autoCreateSubnetworks: false creationTimestamp: '2016-06-27T07:25:03.691-07:00' id: '5404409453117999568' kind: compute#network name: ttest selfLink: https://www.googleapis.com/compute/v1/projects/myproject/global/networks/ttest subnetworks: - https://www.googleapis.com/compute/v1/projects/myproject/regions/us-east1/subnetworks/ttest x_gcloud_mode: custom The ttest subnetwork: $ gcloud compute networks subnets describe ttest creationTimestamp: '2016-06-27T07:25:21.649-07:00' gatewayAddress: 10.0.0.1 id: '6237639993374575038' ipCidrRange: 10.0.0.0/14 kind: compute#subnetwork name: ttest network: https://www.googleapis.com/compute/v1/projects/myproject/global/networks/ttest region: https://www.googleapis.com/compute/v1/projects/myproject/regions/us-east1 selfLink: https://www.googleapis.com/compute/v1/projects/myproject/regions/us-east1/subnetworks/ttest I've tried the same thing with a manually created legacy network with --range=10.0.0.0/8 and then tried creating a cluster in that network, that doesn't seem to work either. It would seem the /14 rule is hardcoded into the GKE configs somewhere, but I don't really know what it wants in the custom network to launch the containers. The GKE container launch command works with any network where the mode/type is "auto". I pored over whatever documentation seemed relevant to me, but without much luck. The only that sticks out the following snippet from this page: The following restrictions exist when using subnetworks with other products: Google Managed VMs: Supported only on auto subnetwork networks. Cannot be deployed in a custom subnet networks. Does GKE use Managed VMs under the hood? Is that what's causing the problem?
Here's the document about lifecycle hooks you might find useful. Your option 1 won't work and should give you the error you saw, it should be ["/bin/cp","/var/lib/postgres/data","/tmpdatavolume/"] instead. Option 2 is also the right way to specify it. Can you kubectl exec into your pod and type those commands to see what error messages that generates? Do something like kubectl exec <pod-name> -i -t -- bash -il The error message shown in option 3 means that you're not passing a valid configuration to the API server. To learn the API definition, see v1.Lifecycle and after a few clicks into its child fields you'll find args isn't valid under lifecycle.postStart.exec. Alternatively, you can find those API definition using kubectl explain, e.g. kubectl explain pods.spec.containers.lifecycle.postStart.exec in this case.
###Instruction: im successfully running kubernetes, gcloud and postgres but i wanna make some modifications after pod startup , im trying to move some files so i tried these 3 options 1 image: paunin/postgresql-cluster-pgsql lifecycle: postStart: exec: command: [/bin/cp /var/lib/postgres/data /tmpdatavolume/] 2 image: paunin/postgresql-cluster-pgsql lifecycle: postStart: exec: command: - "cp" - "/var/lib/postgres/data" - "/tmpdatavolume/" 3 image: paunin/postgresql-cluster-pgsql lifecycle: postStart: exec: command: ["/bin/cp "] args: ["/var/lib/postgres/data","/tmpdatavolume/"] on option 1 and 2, im getting the same errors (from kubectl get events ) Killing container with docker id f436e40f5df2: PostStart handler: Error ex ecuting in Docker Container: -1 and on option 3 it wont even let me upload the yaml file giving me this error error validating "postgres-master.yaml": error validating data: found invalid field args for v1.ExecAction; if you choose to ignore these errors, turn validation off with --validate=false any help would be appreciated! thanks. pd: i just pasted part of my yaml file since i wasnt getting any errors since i added those new lines ### Response: Here's the document about lifecycle hooks you might find useful. Your option 1 won't work and should give you the error you saw, it should be ["/bin/cp","/var/lib/postgres/data","/tmpdatavolume/"] instead. Option 2 is also the right way to specify it. Can you kubectl exec into your pod and type those commands to see what error messages that generates? Do something like kubectl exec <pod-name> -i -t -- bash -il The error message shown in option 3 means that you're not passing a valid configuration to the API server. To learn the API definition, see v1.Lifecycle and after a few clicks into its child fields you'll find args isn't valid under lifecycle.postStart.exec. Alternatively, you can find those API definition using kubectl explain, e.g. kubectl explain pods.spec.containers.lifecycle.postStart.exec in this case.
im successfully running kubernetes, gcloud and postgres but i wanna make some modifications after pod startup , im trying to move some files so i tried these 3 options 1 image: paunin/postgresql-cluster-pgsql lifecycle: postStart: exec: command: [/bin/cp /var/lib/postgres/data /tmpdatavolume/] 2 image: paunin/postgresql-cluster-pgsql lifecycle: postStart: exec: command: - "cp" - "/var/lib/postgres/data" - "/tmpdatavolume/" 3 image: paunin/postgresql-cluster-pgsql lifecycle: postStart: exec: command: ["/bin/cp "] args: ["/var/lib/postgres/data","/tmpdatavolume/"] on option 1 and 2, im getting the same errors (from kubectl get events ) Killing container with docker id f436e40f5df2: PostStart handler: Error ex ecuting in Docker Container: -1 and on option 3 it wont even let me upload the yaml file giving me this error error validating "postgres-master.yaml": error validating data: found invalid field args for v1.ExecAction; if you choose to ignore these errors, turn validation off with --validate=false any help would be appreciated! thanks. pd: i just pasted part of my yaml file since i wasnt getting any errors since i added those new lines
You can use following command to delete the POD forcefully. kubectl delete pod <PODNAME> --grace-period=0 --force --namespace <NAMESPACE>
###Instruction: I tried to delete a ReplicationController with 12 pods and I could see that some of the pods are stuck in Terminating status. My Kubernetes cluster consists of one control plane node and three worker nodes installed on Ubuntu virtual machines. What could be the reason for this issue? NAME READY STATUS RESTARTS AGE pod-186o2 1/1 Terminating 0 2h pod-4b6qc 1/1 Terminating 0 2h pod-8xl86 1/1 Terminating 0 1h pod-d6htc 1/1 Terminating 0 1h pod-vlzov 1/1 Terminating 0 1h ### Response: You can use following command to delete the POD forcefully. kubectl delete pod <PODNAME> --grace-period=0 --force --namespace <NAMESPACE>
I tried to delete a ReplicationController with 12 pods and I could see that some of the pods are stuck in Terminating status. My Kubernetes cluster consists of one control plane node and three worker nodes installed on Ubuntu virtual machines. What could be the reason for this issue? NAME READY STATUS RESTARTS AGE pod-186o2 1/1 Terminating 0 2h pod-4b6qc 1/1 Terminating 0 2h pod-8xl86 1/1 Terminating 0 1h pod-d6htc 1/1 Terminating 0 1h pod-vlzov 1/1 Terminating 0 1h
one solution is to deploy HA postgresql, for example https://github.com/sorintlab/stolon another is to have some network storage attached to all nodes(NFS, glusterFS) and use volumeMounts in the pods
###Instruction: We currently have a 2-node Kubernetes environment running on bare-metal machines (no GCE) and now we wish to set up a PostgreSQL instance on top of this. Our plan was to map a data volume for the PostgreSQL Data Directory to the node using the volumeMounts option in Kubernetes. However this would be a problem because if the Pod ever gets stopped, Kubernetes will re-launch it at random on one of the other nodes. Thus we have no guarantee that it will use the correct data directory on re-launch... So what is the best approach for maintaining a consistent and persistent PostgreSQL Data Directory across a Kubernetes cluster? ### Response: one solution is to deploy HA postgresql, for example https://github.com/sorintlab/stolon another is to have some network storage attached to all nodes(NFS, glusterFS) and use volumeMounts in the pods
We currently have a 2-node Kubernetes environment running on bare-metal machines (no GCE) and now we wish to set up a PostgreSQL instance on top of this. Our plan was to map a data volume for the PostgreSQL Data Directory to the node using the volumeMounts option in Kubernetes. However this would be a problem because if the Pod ever gets stopped, Kubernetes will re-launch it at random on one of the other nodes. Thus we have no guarantee that it will use the correct data directory on re-launch... So what is the best approach for maintaining a consistent and persistent PostgreSQL Data Directory across a Kubernetes cluster?
You can get YAML from the kubectl create configmap command and pipe it to kubectl apply, like this: kubectl create configmap foo --from-file foo.properties -o yaml --dry-run=client | kubectl apply -f -
###Instruction: I've been using K8S ConfigMap and Secret to manage our properties. My design is pretty simple, that keeps properties files in a git repo and use build server such as Thoughtworks GO to automatically deploy them to be ConfigMaps or Secrets (on choice condition) to my k8s cluster. Currently, I found it's not really efficient that I have to always delete the existing ConfigMap and Secret and create the new one to update as below: kubectl delete configmap foo kubectl create configmap foo --from-file foo.properties Is there a nice and simple way to make above one step and more efficient than deleting current? potentially what I'm doing now may compromise the container that uses these configmaps if it tries to mount while the old configmap is deleted and the new one hasn't been created. ### Response: You can get YAML from the kubectl create configmap command and pipe it to kubectl apply, like this: kubectl create configmap foo --from-file foo.properties -o yaml --dry-run=client | kubectl apply -f -
I've been using K8S ConfigMap and Secret to manage our properties. My design is pretty simple, that keeps properties files in a git repo and use build server such as Thoughtworks GO to automatically deploy them to be ConfigMaps or Secrets (on choice condition) to my k8s cluster. Currently, I found it's not really efficient that I have to always delete the existing ConfigMap and Secret and create the new one to update as below: kubectl delete configmap foo kubectl create configmap foo --from-file foo.properties Is there a nice and simple way to make above one step and more efficient than deleting current? potentially what I'm doing now may compromise the container that uses these configmaps if it tries to mount while the old configmap is deleted and the new one hasn't been created.
On Kubernetes, there is not a fully supported way to do this. I think this is not supported by docker either (https://github.com/docker/docker/issues/1824) As a work around, you could sort of do it this way: have one interface be the "default network interface" for pods. It is the one you configure Kubelet and docker to use. Most of your pods use this one. They get a PodIP. For "special" pods that need access to the other interface, or to both, use the "hostNet: true" parameter on those pods, and Kubernetes will not put the pod in a network container. These pods can bind to either interface. will not get a "podIP", but use the IPs of whichever interface they use. you will have to manage port conflicts yourself. You may want to use DaemonSet for these pods. you won't get any NetworkPolicy protection between pods with hostNet. all the pods on the same node with hostNet will be able to talk to each other on localhost, so you get less isolation. This workaround is good if only one or a few applications need "non-default" networking, and those apps are "system applications", managed by the same team that manages the cluster, rather than by a "less trusted" application team. Or if you have a small organization with only a few people running the Kubernetes cluster.
###Instruction: I am wondering if Mesos or K8s can offer resources from multiple network interfaces? I would like to attach multiple Network Interfaces (public eth0, private eth1) on mesos (or K8s) slave nodes and would like to bind specific applications that I run on Mesos's slave nodes on specific interfaces? does not mesos Or K8s need distinct physical networks like OpenStack has four distinct physical networks?? is there any reference guide or doc? ### Response: On Kubernetes, there is not a fully supported way to do this. I think this is not supported by docker either (https://github.com/docker/docker/issues/1824) As a work around, you could sort of do it this way: have one interface be the "default network interface" for pods. It is the one you configure Kubelet and docker to use. Most of your pods use this one. They get a PodIP. For "special" pods that need access to the other interface, or to both, use the "hostNet: true" parameter on those pods, and Kubernetes will not put the pod in a network container. These pods can bind to either interface. will not get a "podIP", but use the IPs of whichever interface they use. you will have to manage port conflicts yourself. You may want to use DaemonSet for these pods. you won't get any NetworkPolicy protection between pods with hostNet. all the pods on the same node with hostNet will be able to talk to each other on localhost, so you get less isolation. This workaround is good if only one or a few applications need "non-default" networking, and those apps are "system applications", managed by the same team that manages the cluster, rather than by a "less trusted" application team. Or if you have a small organization with only a few people running the Kubernetes cluster.
I am wondering if Mesos or K8s can offer resources from multiple network interfaces? I would like to attach multiple Network Interfaces (public eth0, private eth1) on mesos (or K8s) slave nodes and would like to bind specific applications that I run on Mesos's slave nodes on specific interfaces? does not mesos Or K8s need distinct physical networks like OpenStack has four distinct physical networks?? is there any reference guide or doc?
kubectl version also shows the apiserver version. For example, this is the output when I run it: $ kubectl version Client Version: version.Info{Major:"1", Minor:"2", GitVersion:"v1.2.4", GitCommit:"3eed1e3be6848b877ff80a93da3785d9034d0a4f", GitTreeState:"clean"} Server Version: version.Info{Major:"1", Minor:"2", GitVersion:"v1.2.4", GitCommit:"3eed1e3be6848b877ff80a93da3785d9034d0a4f", GitTreeState:"clean"} The second line ("Server Version") contains the apiserver version. There isn't a way to get the master's kubelet version if it isn't registered as one of the nodes (which it isn't if it isn't showing up in kubectl get nodes), but in most deployments it'll be the same version as the apiserver.
###Instruction: Let say I want to find the kubelet and apiserver version of my k8s master(s), what's the best way to do it? I am aware of the following commands: kubectl cluster-info which only shows the endpoints. kubectl get nodes; kubectl describe node <node>; which shows very detail information but only the nodes and not master. There's also kubectl version but that only shows the kubectl version and not the kubelet or apiserver version. What other commands can I use to identify the properties of my cluster? ### Response: kubectl version also shows the apiserver version. For example, this is the output when I run it: $ kubectl version Client Version: version.Info{Major:"1", Minor:"2", GitVersion:"v1.2.4", GitCommit:"3eed1e3be6848b877ff80a93da3785d9034d0a4f", GitTreeState:"clean"} Server Version: version.Info{Major:"1", Minor:"2", GitVersion:"v1.2.4", GitCommit:"3eed1e3be6848b877ff80a93da3785d9034d0a4f", GitTreeState:"clean"} The second line ("Server Version") contains the apiserver version. There isn't a way to get the master's kubelet version if it isn't registered as one of the nodes (which it isn't if it isn't showing up in kubectl get nodes), but in most deployments it'll be the same version as the apiserver.
Let say I want to find the kubelet and apiserver version of my k8s master(s), what's the best way to do it? I am aware of the following commands: kubectl cluster-info which only shows the endpoints. kubectl get nodes; kubectl describe node <node>; which shows very detail information but only the nodes and not master. There's also kubectl version but that only shows the kubectl version and not the kubelet or apiserver version. What other commands can I use to identify the properties of my cluster?