prompt
stringlengths
65
38.7k
response
stringlengths
41
29.1k
<p>I have a kubernetes cluster that has applications running in an Istio service mesh. In one application I am trying to send an email using SMTP. How do I set up Istio rules to allow my applications to use my external SMTP server?</p> <p>Initially I was getting an exception "Could not connect to SMTP host: in-v3.mailjet.com, port: 587, response: -1." as detailed <a href="https://github.com/istio/istio/issues/9379" rel="nofollow noreferrer">here</a>. After visiting this site I realized I needed to provide egress rules which I did as per below</p> <pre><code>apiVersion: networking.istio.io/v1alpha3 kind: ServiceEntry metadata: name: mailjet spec: hosts: - "in-v3.mailjet.com" location: MESH_EXTERNAL ports: - number: 587 name: tls protocol: TLS resolution: DNS --- apiVersion: networking.istio.io/v1alpha3 kind: VirtualService metadata: name: mailjet spec: hosts: - "*.mailjet.com" tls: - match: - port: 587 sni_hosts: - "*.mailjet.com" route: - destination: host: "*.mailjet.com" port: number: 587 weight: 100 </code></pre> <p>I am no longer getting the "Could not connect to SMTP host" exception but I am getting a SocketTieoutException</p> <pre><code>[0m[31m06:56:39,048 ERROR [stderr] (default task-55) at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1487) [0m[31m06:56:39,048 ERROR [stderr] (default task-55) at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1378) [0m[31m06:56:39,048 ERROR [stderr] (default task-55) at java.lang.Thread.run(Thread.java:748) [0m[31m06:56:39,048 ERROR [stderr] (default task-55) Caused by: javax.mail.MessagingException: Exception reading response; [0m[31m06:56:39,048 ERROR [stderr] (default task-55) nested exception is: [0m[31m06:56:39,048 ERROR [stderr] (default task-55) java.net.SocketTimeoutException: Read timed out [0m[31m06:56:39,048 ERROR [stderr] (default task-55) at com.sun.mail.smtp.SMTPTransport.readServerResponse(SMTPTransport.java:2460) [0m[31m06:56:39,048 ERROR [stderr] (default task-55) at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:2187) [0m[31m06:56:39,048 ERROR [stderr] (default task-55) at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:740) [0m[31m06:56:39,048 ERROR [stderr] (default task-55) at javax.mail.Service.connect(Service.java:366) [0m[31m06:56:39,049 ERROR [stderr] (default task-55) at javax.mail.Service.connect(Service.java:246) [0m[31m06:56:39,049 ERROR [stderr] (default task-55) at javax.mail.Service.connect(Service.java:267) [0m[31m06:56:39,049 ERROR [stderr] (default task-55) at org.keycloak.email.DefaultEmailSenderProvider.send(DefaultEmailSenderProvider.java:138) [0m[31m06:56:39,049 ERROR [stderr] (default task-55) ... 73 more [0m[31m06:56:39,049 ERROR [stderr] (default task-55) Caused by: java.net.SocketTimeoutException: Read timed out [0m[31m06:56:39,049 ERROR [stderr] (default task-55) at java.net.SocketInputStream.socketRead0(Native Method) [0m[31m06:56:39,049 ERROR [stderr] (default task-55) at java.net.SocketInputStream.socketRead(SocketInputStream.java:116) [0m[31m06:56:39,049 ERROR [stderr] (default task-55) at java.net.SocketInputStream.read(SocketInputStream.java:171) [0m[31m06:56:39,049 ERROR [stderr] (default task-55) at java.net.SocketInputStream.read(SocketInputStream.java:141) [0m[31m06:56:39,049 ERROR [stderr] (default task-55) at com.sun.mail.util.TraceInputStream.read(TraceInputStream.java:126) [0m[31m06:56:39,049 ERROR [stderr] (default task-55) at java.io.BufferedInputStream.fill(BufferedInputStream.java:246) [0m[31m06:56:39,049 ERROR [stderr] (default task-55) at java.io.BufferedInputStream.read(BufferedInputStream.java:265) [0m[31m06:56:39,049 ERROR [stderr] (default task-55) at com.sun.mail.util.LineInputStream.readLine(LineInputStream.java:106) [0m[31m06:56:39,049 ERROR [stderr] (default task-55) at com.sun.mail.smtp.SMTPTransport.readServerResponse(SMTPTransport.java:2440) [0m[31m06:56:39,049 ERROR [stderr] (default task-55) ... 79 more [0m[31m06:56:39,049 ERROR [org.keycloak.services.resources.admin.RealmAdminResource] (default task-55) Failed to send email javax.mail.MessagingException: Exception reading response; nested exception is: java.net.SocketTimeoutException: Read timed out </code></pre> <p>What do I need to do to successfully send an email within a Kubernetes cluster with an Istio service mesh?</p>
<p>After comparing with <a href="https://istio.io/blog/2018/egress-tcp/#mesh-external-service-entry-for-an-external-mysql-instance" rel="nofollow noreferrer">Mesh-external service entry for an external MySQL instance</a> I managed to get this working using TCP as per below. I tried TLS with the IP address but that did not work. It would be nice however if I did not have to specify the IP address</p> <pre><code>apiVersion: networking.istio.io/v1alpha3 kind: ServiceEntry metadata: name: mailjet spec: hosts: - in-v3.mailjet.com addresses: - 104.199.96.85/32 ports: - name: tls number: 587 protocol: tcp location: MESH_EXTERNAL --- apiVersion: networking.istio.io/v1alpha3 kind: VirtualService metadata: name: mailjet spec: hosts: - in-v3.mailjet.com tcp: - match: - port: 587 route: - destination: host: in-v3.mailjet.com port: number: 587 --- </code></pre>
<p>I'm trying to use istio for routing between microservices in my k8s cluster.</p> <p>In this example, I have the following applications</p> <p>frontend:v1 which needs to contact backend:v1 frontend:v2 which needs to contact backend:v2</p> <p>I have created the required istio configs and have got a response with no routing options but when I attempt to setup routing rules so that traffic with labels app=frontend and version=v1 are routed to the backend v1 subset, I get an error 404.</p> <p>Here is an example of my current VirtualService:</p> <pre><code>apiVersion: networking.istio.io/v1alpha3 kind: VirtualService metadata: name: backend-vs spec: hosts: - "backend.backend.svc.cluster.local" http: - match: - sourceLabels: app: frontend version: v1 route: - destination: host: backend.backend.svc.cluster.local subset: v1 port: number: 5000 </code></pre> <p>Eventually I want to be able to control which versions from the frontend go to the versioned subset on the backend and iterate these microservices independently.</p> <p>At present istio returns a 404 error.</p> <p>If i remove the sourceLabels match I can access the backend service from the frontend pods.</p> <p>TIA</p>
<p>I was able only to get this route works with <code>sourceLabels:</code> matching criteria by adapting the service to the frontend Pod and adding the related label within my test environment in the similar scenario; so far known issue <a href="https://github.com/istio/istio/issues/7787" rel="nofollow noreferrer">#7787</a>.</p>
<p>I'm setting up container deployments with a backend server and socket server. When I try to connect to my web server endpoint its fine, but when connecting to the socket server endpoint it's returning a 400</p> <p>I followed up several topics like: <a href="https://stackoverflow.com/questions/52514108/websocket-handshake-unexpected-response-code-400-in-kubernetes-ingress">WebSocket handshake: Unexpected response code: 400 in kubernetes-ingress</a></p> <p>But adding the annotation WebSocket-services and proxy timeout is not working. </p> <p>When I port forward the deployment pod it's working fine. So the problem must be the nginx ingress controller. </p> <pre><code>apiVersion: extensions/v1beta1 kind: Ingress metadata: name: ingress namespace: {{ include "namespace" . }} labels: helm.sh/chart: {{ include "chartname" . }} app.kubernetes.io/managed-by: {{ .Release.Service }} app.kubernetes.io/stage: {{ .Values.stage }} annotations: kubernetes.io/ingress.class: "nginx" nginx.ingress.kubernetes.io/proxy-read-timeout: "3600" nginx.ingress.kubernetes.io/proxy-send-timeout: "3600" spec: tls: - secretName: tls-certificate hosts: {{ range .Values.hosts }} - {{ . | quote }} {{ end }} rules: - host: mydomain.tk http: paths: - path: / backend: serviceName: web servicePort: http - path: /socket backend: serviceName: web servicePort: socket </code></pre> <p>And here is my service.yml file:</p> <pre><code>apiVersion: v1 kind: Service metadata: name: web namespace: {{ include "namespace" . }} labels: helm.sh/chart: {{ include "chartname" . }} app.kubernetes.io/managed-by: {{ .Release.Service }} app.kubernetes.io/stage: {{ .Values.stage }} spec: type: NodePort sessionAffinity: ClientIP ports: - port: {{ .Values.web.port }} targetPort: http protocol: TCP name: http - port: {{ .Values.web.socket }} targetPort: socket protocol: TCP name: socket selector: name: web </code></pre> <p>No matter what I'm doing it's always returning me a 400 on the /socket endpoint. </p> <p>I'm currently using the latest version of the nginx ingress and GKE version 1.11.7</p> <p>The output of ingress: </p> <pre><code>Name: ingress Namespace: backend Address: Default backend: default-http-backend:80 (10.48.0.9:8080) TLS: tls-certificate terminates mydomain.tk Rules: Host Path Backends ---- ---- -------- mydomain.tk / web:http (10.48.0.28:8080) /socket web:socket (10.48.0.28:9092) Annotations: kubernetes.io/ingress.class: nginx nginx.ingress.kubernetes.io/proxy-read-timeout: 3600 nginx.ingress.kubernetes.io/proxy-send-timeout: 3600 Events: Type Reason Age From Message ---- ------ ---- ---- ------- Normal CREATE 13s nginx-ingress-controller Ingress backend/ingress </code></pre>
<p>I got the problem resolved by basically adding cross origin headers to my applications.</p>
<p>Need to understand exactly how patch works. How could I patch "imagePullPolicy" for instance. Could someone explain in simple details how patch works.</p> <pre><code>kubectl patch statefulset my-set -p '{"spec":{"containers":{"imagePullPolicy":"IfNotPresent"}}}' </code></pre> <p>This is not working what is wrong with it?</p>
<p>In addition to @Colwins answer, you should also add mandatory key <strong>name</strong> into container spec, otherwise you'll get <code>does not contain declared merge key: name</code></p> <p>So, you kubectl command should look like:</p> <pre><code>kubectl patch statefulset my-set -p '{"spec": {"template": {"spec":{"containers":[{"name":"nginx","imagePullPolicy":"Never"}]}}}}' </code></pre>
<p>I am building a Kubernetes cluster following this <a href="https://www.profiq.com/kubernetes-cluster-setup-using-virtual-machines/" rel="nofollow noreferrer">tutorial</a>, and I have troubles to access the Kubernetes dashboard. I already created another question about it that you can see <a href="https://stackoverflow.com/questions/55596900/kubernetes-access-dashboard-from-remote-browser">here</a>, but while digging up into my cluster, I think that the problem might be somewhere else and that's why I create a new question.</p> <p>I start my master, by running the following commands: </p> <pre><code>&gt; kubeadm reset &gt; kubeadm init --apiserver-advertise-address=[MASTER_IP] &gt; file.txt &gt; tail -2 file.txt &gt; join.sh # I keep this file for later &gt; kubectl apply -f https://git.io/weave-kube/ &gt; kubectl -n kube-system get pod NAME READY STATUS RESTARTS AGE coredns-fb8b8dccf-kb2zq 0/1 Pending 0 2m46s coredns-fb8b8dccf-nnc5n 0/1 Pending 0 2m46s etcd-kubemaster 1/1 Running 0 93s kube-apiserver-kubemaster 1/1 Running 0 93s kube-controller-manager-kubemaster 1/1 Running 0 113s kube-proxy-lxhvs 1/1 Running 0 2m46s kube-scheduler-kubemaster 1/1 Running 0 93s </code></pre> <p>Here we can see that I have two <code>coredns</code> pods stuck in Pending state forever, and when I run the command : </p> <pre><code>&gt; kubectl -n kube-system describe pod coredns-fb8b8dccf-kb2zq </code></pre> <p>I can see in the Events part the following Warning : </p> <pre><code>Failed Scheduling : 0/1 nodes are available 1 node(s) had taints that the pod didn't tolerate. </code></pre> <p>Since it is a Warning and not and Error, and that as a Kubernetes newbie, <code>taints</code> does not mean much to me, I tried to connect a node to the master (using the previously saved command) : </p> <pre><code>&gt; cat join.sh kubeadm join [MASTER_IP]:6443 --token [TOKEN] \ --discovery-token-ca-cert-hash sha256:[ANOTHER_TOKEN] &gt; ssh [USER]@[WORKER_IP] 'bash' &lt; join.sh This node has joined the cluster. </code></pre> <p>On the master, I check that the node is connected: </p> <pre><code>&gt; kubectl get nodes NAME STATUS ROLES AGE VERSION kubemaster NotReady master 13m v1.14.1 kubeslave1 NotReady &lt;none&gt; 31s v1.14.1 </code></pre> <p>And I check my pods : </p> <pre><code>&gt; kubectl -n kube-system get pod NAME READY STATUS RESTARTS AGE coredns-fb8b8dccf-kb2zq 0/1 Pending 0 14m coredns-fb8b8dccf-nnc5n 0/1 Pending 0 14m etcd-kubemaster 1/1 Running 0 13m kube-apiserver-kubemaster 1/1 Running 0 13m kube-controller-manager-kubemaster 1/1 Running 0 13m kube-proxy-lxhvs 1/1 Running 0 14m kube-proxy-xllx4 0/1 ContainerCreating 0 2m16s kube-scheduler-kubemaster 1/1 Running 0 13m </code></pre> <p>We can see that another kube-proxy pod have been created and is stuck in ContainerCreating status.</p> <p>And when I am doing a describe again : </p> <pre><code>kubectl -n kube-system describe pod kube-proxy-xllx4 </code></pre> <p>I can see in the Events part multiple identical Warnings : </p> <pre><code>Failed create pod sandbox : rpx error: code = Unknown desc = failed pulling image "k8s.gcr.io/pause:3.1": Get https://k8s.gcr.io/v1/_ping: dial tcp: lookup k8s.gcr.io on [::1]:53 read up [::1]43133-&gt;[::1]:53: read: connection refused </code></pre> <p>Here are my repositories : </p> <pre><code>docker image ls REPOSITORY TAG k8s.gcr.io/kube-proxy v1.14.1 k8s.gcr.io/kube-apiserver v1.14.1 k8s.gcr.io/kube-controller-manager v1.14.1 k8s.gcr.io/kube-scheduler v1.14.1 k8s.gcr.io/coredns 1.3.1 k8s.gcr.io/etcd 3.3.10 k8s.gcr.io/pause 3.1 </code></pre> <p>And so, for the dashboard part, I tried to start it with the command </p> <pre><code>&gt; kubectl apply -f https://raw.githubusercontent.com/kubernetes/dashboard/master/aio/deploy/recommended/kubernetes-dashboard.yaml </code></pre> <p>But the dashboard pod is stuck in Pending state.</p> <pre><code>kubectl -n kube-system get pod NAME READY STATUS RESTARTS AGE coredns-fb8b8dccf-kb2zq 0/1 Pending 0 40m coredns-fb8b8dccf-nnc5n 0/1 Pending 0 40m etcd-kubemaster 1/1 Running 0 38m kube-apiserver-kubemaster 1/1 Running 0 38m kube-controller-manager-kubemaster 1/1 Running 0 39m kube-proxy-lxhvs 1/1 Running 0 40m kube-proxy-xllx4 0/1 ContainerCreating 0 27m kube-scheduler-kubemaster 1/1 Running 0 38m kubernetes-dashboard-5f7b999d65-qn8qn 1/1 Pending 0 8s </code></pre> <p>So, event though my problem originaly was that I cannot access to my dashboard, I guess that the real problem is deeper thant that.</p> <p>I know that I just put a lot of information here, but I am a k8s beginner and I am completely lost on this.</p>
<p>There is an issue I experienced with <code>coredns</code> pods stuck in a pending mode when setting up your own cluster; which I resolve by adding pod network.</p> <p>Looks like because there is no Network Addon installed, the nodes are taint as <code>not-ready</code>. Installing the Addon would remove the taints and the Pods will be able to schedule. In my case adding <em>flannel</em> fixed the issue.</p> <p>EDIT: There is a note about this in the official <a href="https://kubernetes.io/docs/setup/independent/create-cluster-kubeadm/#pod-network" rel="nofollow noreferrer">k8s documentation - Create cluster with kubeadm</a>:</p> <blockquote> <p>The network must be deployed before any applications. <strong><em>Also, CoreDNS will not start up before a network is installed.</em></strong> kubeadm only supports Container Network Interface (CNI) based networks (and does not support kubenet).</p> </blockquote>
<p>I am getting an error while running the following command. I have updated gcloud SDK but still facing same error.</p> <pre><code>kubectl get nodes Unable to connect to the server: error executing access token command "/Users/salayhin/google-cloud-sdk/bin/gcloud config config-helper --format=json": err=exit status 1 output= stderr=Traceback (most recent call last): File "/Users/salayhin/google-cloud-sdk/lib/gcloud.py", line 95, in &lt;module&gt; main() File "/Users/salayhin/google-cloud-sdk/lib/gcloud.py", line 54, in main from googlecloudsdk.core.util import encoding File "/Users/salayhin/google-cloud-sdk/lib/googlecloudsdk/__init__.py", line 23, in &lt;module&gt; from googlecloudsdk.core.util import lazy_regex File "/Users/salayhin/google-cloud-sdk/lib/googlecloudsdk/core/util/lazy_regex.py", line 25, in &lt;module&gt; from googlecloudsdk.core.util import lazy_regex_patterns ImportError: cannot import name lazy_regex_patterns </code></pre>
<p>It seems like it's just an error from the Google Cloud SDK happening <a href="https://github.com/google-cloud-sdk/google-cloud-sdk/blob/master/lib/googlecloudsdk/core/util/lazy_regex.py#L25" rel="nofollow noreferrer">here</a> indicating that you are probably missing <a href="https://github.com/google-cloud-sdk/google-cloud-sdk/blob/master/lib/googlecloudsdk/core/util/lazy_regex_patterns.py" rel="nofollow noreferrer">this file</a> on the same directory.</p> <p>I would recommend re-install the <a href="https://cloud.google.com/sdk/" rel="nofollow noreferrer">Google Cloud SDK</a> on whatever system you are using.</p>
<p>My Kubernetes StorageClass volume doesn't retain existing data when the pod is deleted and deployed back with my postgresql database. When I delete the pod, the new pod is created but the database is empty.</p> <p>I have followed variations of the different versions of the tutorials (<a href="https://kubernetes.io/docs/concepts/storage/persistent-volumes/" rel="nofollow noreferrer">https://kubernetes.io/docs/concepts/storage/persistent-volumes/</a>) but nothing seems to work.</p> <p>I paste all the YAML files cause the problem might be in the combination.</p> <p>storage-google.yaml</p> <pre><code>apiVersion: v1 kind: PersistentVolumeClaim metadata: name: spingular-pvc spec: storageClassName: standard accessModes: - ReadWriteOnce resources: requests: storage: 7Gi --- apiVersion: storage.k8s.io/v1 kind: StorageClass metadata: name: standard provisioner: kubernetes.io/gce-pd parameters: type: pd-standard zone: us-east4-a </code></pre> <p>jhipsterpress-postgresql.yml</p> <pre><code>apiVersion: v1 kind: Secret metadata: name: jhipsterpress-postgresql namespace: default labels: app: jhipsterpress-postgresql type: Opaque data: postgres-password: NjY0NXJxd24= --- apiVersion: extensions/v1beta1 kind: Deployment metadata: name: jhipsterpress-postgresql namespace: default spec: replicas: 1 template: metadata: labels: app: jhipsterpress-postgresql spec: volumes: - name: data persistentVolumeClaim: claimName: spingular-pvc containers: - name: postgres image: postgres:10.4 env: - name: POSTGRES_USER value: jhipsterpress - name: POSTGRES_PASSWORD valueFrom: secretKeyRef: name: jhipsterpress-postgresql key: postgres-password ports: - containerPort: 5432 volumeMounts: - name: data mountPath: /var/lib/postgresql/ --- apiVersion: v1 kind: Service metadata: name: jhipsterpress-postgresql namespace: default spec: selector: app: jhipsterpress-postgresql ports: - name: postgresqlport port: 5432 type: LoadBalancer </code></pre> <p>jhipsterpress-deployment.yml</p> <pre><code>apiVersion: apps/v1 kind: Deployment metadata: name: jhipsterpress namespace: default spec: replicas: 1 selector: matchLabels: app: jhipsterpress version: "v1" template: metadata: labels: app: jhipsterpress version: "v1" spec: initContainers: - name: init-ds image: busybox:latest command: - '/bin/sh' - '-c' - | while true do rt=$(nc -z -w 1 jhipsterpress-postgresql 5432) if [ $? -eq 0 ]; then echo "DB is UP" break fi echo "DB is not yet reachable;sleep for 10s before retry" sleep 10 done containers: - name: jhipsterpress-app image: galore/jhipsterpress env: - name: SPRING_PROFILES_ACTIVE value: prod - name: SPRING_DATASOURCE_URL value: jdbc:postgresql://jhipsterpress-postgresql.default.svc.cluster.local:5432/jhipsterpress - name: SPRING_DATASOURCE_USERNAME value: jhipsterpress - name: SPRING_DATASOURCE_PASSWORD valueFrom: secretKeyRef: name: jhipsterpress-postgresql key: postgres-password - name: JAVA_OPTS value: " -Xmx256m -Xms256m" resources: requests: memory: "256Mi" cpu: "500m" limits: memory: "512Mi" cpu: "1" ports: - name: http containerPort: 8080 readinessProbe: httpGet: path: /management/health port: http initialDelaySeconds: 20 periodSeconds: 15 failureThreshold: 6 livenessProbe: httpGet: path: /management/health port: http initialDelaySeconds: 120 </code></pre> <p>jhipsterpress-service.yml</p> <pre><code>apiVersion: v1 kind: Service metadata: name: jhipsterpress namespace: default labels: app: jhipsterpress spec: selector: app: jhipsterpress type: LoadBalancer ports: - name: http port: 8080 </code></pre> <p>When I included a Retain Policy I was getting this error:</p> <pre><code>@cloudshell:~ (academic-veld-230622)$ kubectl apply -f storage-google.yaml error: error validating "storage-google.yaml": error validating data: ValidationError(PersistentVolumeClaim.spec): unknown field "persistentVolumeReclaimPolicy" in io.k8s.api.core.v1.PersistentVolumeClaimSpec; if you choose to ignore these errors, turn validation off with --validate=false </code></pre> <p>Please, if you know of a complete example on a public image that works (in postgresql, I can make it work with Mongo), I will really appreciate it. </p> <p>Thanks to all.</p>
<p>Note that for this to work you need to have your PVC dynamically provision a PV to satisfy its requirements, then there will be a permanent <a href="https://kubernetes.io/docs/concepts/storage/persistent-volumes/#binding" rel="nofollow noreferrer">binding</a> between the PVC and PV and every time your workload uses the PVC then it will use the same PV. Specifically indicated by this excerpt:</p> <blockquote> <p>If a PV was dynamically provisioned for a new PVC, the loop will always bind that PV to the PVC</p> </blockquote> <p>If in your case the Google Persistent Disk is being provisioned by the PVC, and you can verify that on GCP it's the same PV used every time, then it's probably an issue with the pod startup process where it's removing all the data. (Is there any reason why you are using <code>/var/lib/postgresql/</code> vs <code>/var/lib/postgresql</code>?)</p> <p>Also, <code>persistentVolumeReclaimPolicy: Retain</code> applies to a PV, not a PVC. For dynamically provisioned PVs the value is <code>Delete</code>. In your case, it wouldn't apply because your dynamically provisioned volume should be bound to your PVC. In other words, you are not reclaiming the volume.</p> <p>Having said all that the recommended way to deploy a DB is using <a href="https://kubernetes.io/docs/concepts/workloads/controllers/statefulset/" rel="nofollow noreferrer">StatefulSets</a> similar to this <a href="https://kubernetes.io/docs/tasks/run-application/run-replicated-stateful-application/" rel="nofollow noreferrer">mysql</a> example using a <code>volumeClaimTemplate</code>.</p>
<p>I have many tenants running on one Kubernetes cluster (on AWS), where every tenant has one Pod that exposes one <strong>TCP</strong> port (<strong>not HTTP</strong>) and one <strong>UDP</strong> port.</p> <ul> <li>I don't need load balancing capabilities.</li> <li>The approach should expose an IP address that is externally available with a dedicated port for each tenant</li> <li>I don't want to expose the nodes directly to the internet</li> </ul> <p>I have the following service so far:</p> <pre><code>apiVersion: v1 kind: Service metadata: name: my-service labels: app: my-app spec: type: NodePort ports: - port: 8111 targetPort: 8111 protocol: UDP name: my-udp - port: 8222 targetPort: 8222 protocol: TCP name: my-tcp selector: app: my-app </code></pre> <p>What is the way to go?</p>
<ul> <li><a href="https://medium.com/kokster/how-to-setup-nginx-ingress-controller-on-aws-clusters-7bd244278509" rel="nofollow noreferrer">Deploy</a> a NGINX ingress controller on your AWS cluster</li> <li>Change your service my-service type from <code>NodePort</code> to <code>ClusterIP</code></li> <li>Edit the configMap <code>tcp-services</code> in the <code>ingress-nginx</code> namespace adding :</li> </ul> <blockquote> <pre><code>data: "8222": your-namespace/my-service:8222 </code></pre> </blockquote> <ul> <li>Same for configMap <code>udp-services</code> :</li> </ul> <blockquote> <pre><code>data: "8111": your-namespace/my-service:8111 </code></pre> </blockquote> <p>Now, you can access your application externally using the nginx-controller IP <code>&lt;ip:8222&gt;</code> (TCP) and <code>&lt;ip:8111&gt;</code> (UDP)</p>
<p>My project has an application server and a C++ library. The library is not dependent on the application server. The vendor has a Docker image for the application server. I need to deploy a C++ library that needs to be accessible from each of the application server nodes/pods.</p> <p>I've written a Dockerfile that builds on the vendors image, compiling and copying the libraries into place. It works, however, every time there's a new version of the application server I need to build my C++ library again from scratch. Given the lack of dependencies these doesn't seem optimal.</p> <p>Naively, what I was expecting was to be able to build the C++ library into an "empty" image and mount that (like a filesystem) in each pod. That way the server and the library are maintained separately.</p> <p>Is building on the vendor Dockerfile the "right" way to architect this? Or is there a solution more like my "idealised" vision?</p> <p>I expect the answer is obvious and I just need the right terminology to search for... pointers very much appreciated.</p>
<p>As you said you can build the C++ library into an "empty" image. And for all the deployments you can use this as base image. This way you can avoid building library for every deployment.</p> <p>Ex: Build image with C++ Library. Lets call this lib-img. When vendor is building image, vendor can use lib-img as base image, you can also add additional dependencies to lib-img which are needed by vendor.</p> <p>You can also use init containers to pull the library on the pods.</p>
<p>My project has an application server and a C++ library. The library is not dependent on the application server. The vendor has a Docker image for the application server. I need to deploy a C++ library that needs to be accessible from each of the application server nodes/pods.</p> <p>I've written a Dockerfile that builds on the vendors image, compiling and copying the libraries into place. It works, however, every time there's a new version of the application server I need to build my C++ library again from scratch. Given the lack of dependencies these doesn't seem optimal.</p> <p>Naively, what I was expecting was to be able to build the C++ library into an "empty" image and mount that (like a filesystem) in each pod. That way the server and the library are maintained separately.</p> <p>Is building on the vendor Dockerfile the "right" way to architect this? Or is there a solution more like my "idealised" vision?</p> <p>I expect the answer is obvious and I just need the right terminology to search for... pointers very much appreciated.</p>
<p>Using Kubernetes you have at least two options to manage the library separately from container image:</p> <ol> <li><a href="https://kubernetes.io/docs/concepts/workloads/pods/init-containers/" rel="nofollow noreferrer">Init containers</a>. If you put your library to external resource you can use <code>Init container</code> to <a href="https://kubernetes.io/docs/tasks/configure-pod-container/configure-pod-initialization/" rel="nofollow noreferrer">download</a> it and put inside the application server's pod file system. </li> <li><a href="https://kubernetes.io/docs/concepts/storage/volumes/#types-of-volumes" rel="nofollow noreferrer">Volumes</a>. You can also put the library to a network storage and attach it as a volume in <a href="https://kubernetes.io/docs/concepts/storage/persistent-volumes/#access-modes" rel="nofollow noreferrer">ReadOnlyMany</a> access mode to the application server pods.</li> </ol>
<p>I have a script that calls <code>kubectl -server $server --certificate-authority $ca --token $token get pod --all-namespaces</code> outside the cluster, where<code>$token</code> is from a service account <code>my-sa</code> (in namespace <code>my-ns</code>) with suitably restricted permissions under RBAC.</p> <p>I now want to refactor this such that the script calls <code>kubectl --kubeconfig my-service.conf get pod --all-namespaces</code> instead, i.e. it should refer to a kubeconfig file instead of setting local parameters. This is in following Kubernetes' own conventions around its own kubeconfigs in <code>/etc/kubernetes</code>.</p> <p>I've tried the following kubeconfig <code>my-service.conf</code>; <code>&lt;CA_DATA&gt;</code> is the base64-encoded content of <code>/etc/kubernetes/pki/ca.crt</code>, <code>&lt;SERVER&gt;</code> is same as <code>$server</code>, and <code>&lt;TOKEN&gt;</code> is same as <code>$token</code>:</p> <pre><code>apiVersion: v1 kind: Config clusters: - cluster: certificate-authority-data: &lt;CA_DATA&gt; server: &lt;SERVER&gt; name: my-cluster contexts: - context: name: default-context context: cluster: my-cluster user: default-user current-context: default-context users: - name: my-service user: token: &lt;TOKEN&gt; </code></pre> <p><code>kubectl --kubeconfig /dev/null --server $server --certificate-authority /etc/kubernetes/pki/ca.crt --token $token get pods --all-namespaces</code> works on the command line, but <code>kubectl --kubeconfig my-service.conf get pod --all-namespaces</code> produces the following error message:</p> <blockquote> <p>Error from server (Forbidden): pods is forbidden: User "system:anonymous" cannot list resource "pods" in API group "" at the cluster scope</p> </blockquote> <p>So there still be something wrong with the <a href="https://stackoverflow.com/questions/47770676/how-to-create-a-kubectl-config-file-for-serviceaccount">structure of my kubeconfig file</a>. Why did the client not <a href="https://kubernetes.io/docs/reference/access-authn-authz/authentication/" rel="nofollow noreferrer">authenticate as</a> <code>system:serviceaccount:my-ns:my-sa</code>? What could be wrong?</p> <p><strong>UPDATE</strong> I was wondering whether it was perhaps inappropriate to use service account tokens outside the cluster (Kubernetes' own kubeconfigs use client certificates instead). But then the <a href="https://kubernetes.io/docs/reference/access-authn-authz/authentication/" rel="nofollow noreferrer">documentation</a> clearly states: "service account bearer tokens are perfectly valid to use outside the cluster".</p>
<p>Your context config is referencing an inexistent credential...</p> <p>Your credential is specified as <code>- name: my-service</code>, so your context should be:</p> <pre><code>- context: name: default-context context: cluster: my-cluster user: my-service # instead of default-user </code></pre>
<p>Im not clear with the use of --record in kubectl command.</p> <pre><code>kubectl run nginx image=nginx --port=80 --record </code></pre> <p>detailed explanation with an example is much appreciated.</p>
<p>Using the --record flag when using kubectl annotates the objects created with that command with the command used to create them. When you list/retrieve these objects, the annotations will show up so that objects can be associated with a command.</p> <p>I should warn you, however, that there is talk of deprecating this flag in the Kubernetes official repository here</p> <p><a href="https://github.com/kubernetes/kubernetes/pull/20035" rel="nofollow noreferrer">https://github.com/kubernetes/kubernetes/pull/20035</a></p> <p>and here</p> <p><a href="https://github.com/kubernetes/kubernetes/issues/40422" rel="nofollow noreferrer">https://github.com/kubernetes/kubernetes/issues/40422</a></p>
<p>I want to learn how to update secrets in worker pods without killing and recreating the deployment.</p> <p>Currently pods pull in secrets to as env vars with:</p> <pre><code> env: - name: SECRET_ACCESS_KEY valueFrom: secretKeyRef: key: secret_access_key name: secrets </code></pre> <p>but this only happens when they startup.</p> <p>So if there is a need to change a secret I have to:</p> <ol> <li>Change the secret in <code>secrets.yaml</code></li> <li><code>kubectl apply -f secrets.yaml</code></li> <li><code>kubectl delete -f worker-deployment.yaml</code></li> <li><code>kubectl apply -f worker-deployment.yaml</code></li> </ol> <p>I really don't like step 3 and 4 as they terminate jobs in progress.</p> <p>What is a better workflow for updating env var secrets in place?</p>
<p>There is no way to do a "hot reload" for pod's environment variables.</p> <p>Although, you do not need to delete and recreate the deployment again to apply the new secret value. You only need to recreate the underlying pods. Some options are:</p> <ul> <li><code>kubectl delete pods</code> to recreate them</li> <li>Editing some deployment trivial value to trigger a <a href="https://kubernetes.io/docs/concepts/workloads/controllers/deployment/#updating-a-deployment" rel="noreferrer">Rolling Update</a> (e.g., <a href="https://gist.github.com/jmound/ff6fa539385d1a057c82fa9fa739492e" rel="noreferrer">changing the <code>terminationGracePeriodSeconds</code></a> from <code>30</code> to <code>31</code>).</li> <li>Use <code>kubectl rollout restart</code> to do a rolling restart on the deployment †</li> </ul> <p><em>† <code>rollout restart</code> is only available on kubernetes <a href="https://github.com/kubernetes/kubernetes/blob/master/CHANGELOG/CHANGELOG-1.15.md#cli-improvements" rel="noreferrer">v1.15+</a></em></p>
<p>Kata containers is trying to make containers secure by providing more isolation.</p> <blockquote> <p>lightweight Virtual Machines (VMs) that feel and perform like containers, but provide the workload isolation and security advantages of VMs.</p> </blockquote> <p>If I am building a playground/code fiddle (something like <a href="https://ideone.com" rel="nofollow noreferrer">ideone</a>), are they secure enough to compile and run untrusted code? </p> <p>Is this a good/intended use for this type of containers?</p>
<p>Any type of workload can potentially be used by <a href="https://katacontainers.io/" rel="nofollow noreferrer">Kata Containers</a>, just like regular containers. The idea behind them is providing the VM isolation that you don't get with regular containers. You can use Kata Container with <a href="https://github.com/kata-containers/runtime#introduction" rel="nofollow noreferrer">Docker and Kubernetes</a>.</p> <p>You can achieve a decent level of isolation with regular containers using things like <a href="https://en.wikipedia.org/wiki/Seccomp" rel="nofollow noreferrer">seccomp</a>, <a href="https://en.wikipedia.org/wiki/Security-Enhanced_Linux" rel="nofollow noreferrer">SELinux</a>, <a href="http://man7.org/linux/man-pages/man7/capabilities.7.html" rel="nofollow noreferrer">Capabilities</a>, and/or <a href="https://en.wikipedia.org/wiki/AppArmor" rel="nofollow noreferrer">AppArmor</a> but it can get quite complicated. Kata Containers offers a simpler alternative to that.</p>
<p>Some background: I have set up Airflow on Kubernetes (on AWS). I am able to run DAGs that query a database, send emails or do anything that doesn't require a package that isn't already a part of Airflow. For example, if I try to run a DAG that uses the Facebook-business SDK the DAG will obviously break because the dependency isn't available. I've tried a couple different ways of trying to get this dependency, along with others, installed but haven't been successful. </p> <p>I have tried to install python packages by modifying my scheduler and webserver deployments to do a pip install of my dependencies as part of an initContainer. When I do this, the DAG remains broken as it is unable to find the needed packages. When I open a shell to my pod I can see that the dependencies have not been installed (I check using <code>pip list</code>). I have also verified that there aren't other python/pip versions installed. </p> <p>I have also tried to install the dependencies by running a pip install when I open a shell to my pod. This way is successful in installing the dependency in the correct place and also makes it available. However, instead of the webserver UI showing that my DAG is broken, I get the <code>this dag isn't available in the webserver dagbag object</code> message. </p> <p>I would expect that running <code>pip install</code> as part of my initContainer or container would makes these dependencies available in my pod. However, this isn't the case. It's as if pip install runs without any issues, but by the time my pods are fully set up the python packages are nowhere to be found</p> <p><strong>I forgot to say that I have found a way to make it work, but it feels somewhat hacky and like there should be a better way</strong> - If I open a shell to my webserver container and install the needed dependencies and then open a shell to my scheduler and do the same thing, the dependencies are found and the DAG works. </p>
<p>The init container is a separate docker instance. Unless you rig up some sort of shared storage for your python libraries (which is quite dubious) any pip installs in the init container won't impact the running container of the pod. </p> <p>I see two options:</p> <p>1) Modify the docker image that you're using to include the packages you need</p> <p>2) Prepend a <code>pip install</code> to the command being run in the pod. It's not uncommon to string together a few commands with <code>&amp;&amp;</code> between them, in order to execute a sequence of operations in a starting pod. </p>
<p>I'm using EKS (Kubernetes) in AWS and I have problems with posting a payload at around 400 Kilobytes to any web server that runs in a container in that Kubernetes. I hit some kind of limit but it's not a limit in size, it seems at around 400 Kilobytes many times works but sometimes I get (testing with Python requests)</p> <pre><code>requests.exceptions.ChunkedEncodingError: ("Connection broken: ConnectionResetError(104, 'Connection reset by peer')", ConnectionResetError(104, 'Connection reset by peer')) </code></pre> <p>I test this with different containers (python web server on Alpine, Tomcat server on CentOS, nginx, etc).</p> <p>The more I increase the size over 400 Kilobytes, the more consistent I get: Connection reset by peer.</p> <p>Any ideas?</p>
<p>Thanks for your answers and comments, helped me get closer to the source of the problem. I did upgrade the AWS cluster from 1.11 to 1.12 and that cleared this error when accessing from service to service within Kubernetes. However, the error still persisted when accessing from outside the Kubernetes cluster using a public dns, thus the load balancer. So after testing some more I found out that now the problem lies in the ALB or the ALB controller for Kubernetes: <a href="https://kubernetes-sigs.github.io/aws-alb-ingress-controller/" rel="noreferrer">https://kubernetes-sigs.github.io/aws-alb-ingress-controller/</a> So I switched back to a Kubernetes service that generates an older-generation ELB and the problem was fixed. The ELB is not ideal, but it's a good work-around for the moment, until the ALB controller gets fixed or I have the right button to press to fix it.</p>
<p>I have a file has PV, Service and 2 Pod statefulset including Dynamic PVC. When I deployed the file, a problem happened at PVC status.</p> <pre><code># kubectl get pvc NAME STATUS VOLUME CAPACITY ACCESS MODES STORAGECLASS AGE www-web-0 Bound pv-test 10Gi RWO my-storage-class 7m19s www-web-1 Pending my-storage-class 7m17s </code></pre> <p>One of PVC's Status is "Pending" and the reason is "Storage class name not found". But one of PVC was created normally.</p> <p>Below is the content of the file.</p> <pre><code>apiVersion: v1 kind: PersistentVolume metadata: name: pv-test labels: type: local spec: accessModes: - ReadWriteOnce persistentVolumeReclaimPolicy: Delete storageClassName: "my-storage-class" capacity: storage: 10Gi hostPath: path: /tmp/data type: DirectoryOrCreate --- apiVersion: v1 kind: Service metadata: name: nginx labels: app: nginx spec: ports: - port: 80 name: web clusterIP: None selector: app: nginx --- apiVersion: apps/v1 kind: StatefulSet metadata: name: web spec: selector: matchLabels: app: nginx # has to match .spec.template.metadata.labels serviceName: "nginx" replicas: 2 # by default is 1 template: metadata: labels: app: nginx # has to match .spec.selector.matchLabels spec: terminationGracePeriodSeconds: 10 containers: - name: nginx image: k8s.gcr.io/nginx-slim:0.8 ports: - containerPort: 80 name: web volumeMounts: - name: www mountPath: /usr/share/nginx/html volumeClaimTemplates: - metadata: name: www spec: accessModes: [ "ReadWriteOnce" ] storageClassName: "my-storage-class" resources: requests: storage: 1Gi </code></pre> <p>If someone knows the cause, let me know. Thanks in advance.</p> <p>Describe information about PV, PVC (www-web-1), Pod (web-1) </p> <pre><code>kubectl describe pv pv-test Name: pv-test Labels: type=local Annotations: kubectl.kubernetes.io/last-applied-configuration: {"apiVersion":"v1","kind":"PersistentVolume","metadata":{"annotations":{},"labels":{"type":"local"},"name":"pv-test"},"spec":{"accessModes... pv.kubernetes.io/bound-by-controller: yes Finalizers: [kubernetes.io/pv-protection] StorageClass: my-storage-class Status: Bound Claim: default/www-web-0 Reclaim Policy: Delete Access Modes: RWX VolumeMode: Filesystem Capacity: 10Gi Node Affinity: &lt;none&gt; Message: Source: Type: HostPath (bare host directory volume) Path: /tmp/data HostPathType: DirectoryOrCreate Events: &lt;none&gt; #kubectl describe pvc www-web-1 Name: www-web-1 Namespace: default StorageClass: my-storage-class Status: Pending Volume: Labels: app=nginx Annotations: &lt;none&gt; Finalizers: [kubernetes.io/pvc-protection] Capacity: Access Modes: VolumeMode: Filesystem Events: Type Reason Age From Message ---- ------ ---- ---- ------- Warning ProvisioningFailed 20s (x7 over 2m) persistentvolume-controller storageclass.storage.k8s.io "my-storage-class" not found Mounted By: web-1 #kubectl describe po web-1 Name: web-1 Namespace: default Priority: 0 PriorityClassName: &lt;none&gt; Node: &lt;none&gt; Labels: app=nginx controller-revision-hash=web-6596ffb49b statefulset.kubernetes.io/pod-name=web-1 Annotations: &lt;none&gt; Status: Pending IP: Controlled By: StatefulSet/web Containers: nginx: Image: k8s.gcr.io/nginx-slim:0.8 Port: 80/TCP Host Port: 0/TCP Environment: &lt;none&gt; Mounts: /usr/share/nginx/html from www (rw) /var/run/secrets/kubernetes.io/serviceaccount from default-token-lnfvq (ro) Conditions: Type Status PodScheduled False Volumes: www: Type: PersistentVolumeClaim (a reference to a PersistentVolumeClaim in the same namespace) ClaimName: www-web-1 ReadOnly: false default-token-lnfvq: Type: Secret (a volume populated by a Secret) SecretName: default-token-lnfvq Optional: false QoS Class: BestEffort Node-Selectors: &lt;none&gt; Tolerations: node.kubernetes.io/not-ready:NoExecute for 300s node.kubernetes.io/unreachable:NoExecute for 300s Events: Type Reason Age From Message ---- ------ ---- ---- ------- Warning FailedScheduling 3m43s (x183 over 8m46s) default-scheduler pod has unbound immediate PersistentVolumeClaims (repeated 3 times) </code></pre>
<p>Your volume <code>pv-test</code> has <code>accessModes: - ReadWriteOnce</code> I think you need to create one more volume for second pod.</p> <p>So I think if <code>www-web-1</code> is also trying to mount <code>pv-test</code> it won't be able to mount it.</p>
<p>Not able to use subPathExpr or subPath in volume when kind is Deployment.</p> <p>Tried using subpath giving some env variable, but is was not creating the folder with value, it is getting created with ${xyz}</p> <pre><code>--- apiVersion: apps/v1 kind: Deployment metadata: name: abc spec: replicas: 1 selector: matchLabels: app: abc template: metadata: labels: app: abc spec: env: - name: NAME valueFrom: fieldRef: fieldPath: metadata.name volumeMounts: - mountPath: /opt/logs name: abc subPath: $(NAME) volumes: - name: abc hostPath: path: /opt/abc type: Directory </code></pre> <p>i want to create the volume directory with pod hostname, but not able to create</p> <p>example : if pod name is xyzservice-3216544-fv4</p> <p>i want to create the volume directory like /opt/abc/xyzservice-3216544-fv4</p>
<p>What's your Kubernetes Cluster Version?<br> <strong><a href="https://kubernetes.io/docs/concepts/storage/volumes/#using-subpath-with-expanded-environment-variables" rel="nofollow noreferrer">Using subPath with expanded environment variables</a></strong> is a new FEATURE(alpha) in v1.14</p>
<p>In this <a href="https://kubernetes.io/docs/concepts/overview/working-with-objects/field-selectors/#supported-fields" rel="noreferrer">doc</a> supported fields are not listed and I cannot find them properly. With some trial and experiments I noticed the following: </p> <p>This works nicely and finds some pods:</p> <pre><code>kubectl get pods --field-selector=spec.restartPolicy=Never </code></pre> <p>But this produces error:</p> <pre><code>kubectl get pods --field-selector=spec.serviceAccount=default No resources found. Error from server (BadRequest): Unable to find {"" "v1" "pods"} that match label selector "", field selector "spec.serviceAccount=default": field label not supported: spec.serviceAccount </code></pre> <p>So how is this decided? I know I can find with JSONPath but it is client-side filtering AFAIK. </p>
<p>You can select the <code>serviceAccount</code> using following query:</p> <pre><code>kubectl get pods --field-selector=spec.serviceAccountName="default" </code></pre> <p>The <code>--field-selector</code> currently selects only equality based values and in that too it has very limited support to select the pod based on fields. The following fields are supported by <code>--field-selector</code>:</p> <pre><code>metadata.name metadata.namespace spec.nodeName spec.restartPolicy spec.schedulerName spec.serviceAccountName status.phase status.podIP status.nominatedNodeName </code></pre> <p>As you already know, you need to rely on the jsonpath to select any other field other than above fields.</p> <p>You can visit following link to find out more:</p> <blockquote> <p><a href="https://github.com/kubernetes/kubernetes/blob/master/pkg/apis/core/v1/conversion.go#L160-L167]" rel="nofollow noreferrer">https://github.com/kubernetes/kubernetes/blob/master/pkg/apis/core/v1/conversion.go#L160-L167]</a><a href="https://github.com/kubernetes/kubernetes/blob/master/pkg/apis/core/v1/conversion.go#L160-L167" rel="nofollow noreferrer">1</a></p> </blockquote>
<p>There are 2 questions about Calico applying to k8s cluster.</p> <ol> <li><p>Calico creates etcd for own data, but I don't want to create another etcd because k8s already have it. Can I use k8s etcd for Calico?</p></li> <li><p>Calico prepares Typha for using Kubernetes API Datastore. Then, What does Typha exactly do? I read Typha's code, and assumed that Typha takes snapshots and deltas for adapting network policy and constantly broadcast them to all client which Typha connects to. But I'm not familiar with golang so I don't have confidence of my understanding.</p></li> </ol> <p>I'm absolutely new to Calico and k8s, so I'm sorry if I miss some document related to above questions.</p>
<ol> <li>From the <a href="https://docs.projectcalico.org/v1.5/getting-started/kubernetes/installation/" rel="nofollow noreferrer">calico docs on adding it to K8s</a>:</li> </ol> <blockquote> <p><strong>Requirements</strong></p> <p>An etcd cluster accessible by all nodes in the Kubernetes cluster</p> <ul> <li>Calico can share the etcd cluster used by Kubernetes, but it’s recommended that a separate cluster is set up.</li> </ul> </blockquote> <ol start="2"> <li>I don't know much about how Typha works, but maybe the <a href="https://docs.projectcalico.org/v3.5/reference/architecture/" rel="nofollow noreferrer">docs</a> and the <a href="https://github.com/projectcalico/typha" rel="nofollow noreferrer">github repo</a> have some more info on it.</li> </ol>
<p>I am trying to achieve 0 downtime during rolling update with EKS (AWS K8s service).</p> <p>I have one WebSocket server and I want to ensure during the rolling update of this server, existing connections will be kept until the WebSockets are closed after the work is done.</p> <p>I thought K8s rolling update feature would help me with this but it did not. I tried and it simply killed the pod while there were still connections to the WebSocket.</p> <p>If I understand the <a href="https://kubernetes.io/docs/concepts/workloads/pods/pod/#termination-of-pods" rel="noreferrer">document</a> correctly, then the pod termination goes like this:</p> <ol> <li>User signals pod deletion to K8s API</li> <li>K8s stops routing new traffic to this pod and sends the SIGTERM signal</li> <li>The application MUST handle this signal and start graceful termination of itself in a specified <code>grace-period</code> (default to 30s)</li> <li>After that, K8s sends a SIGKILL signal to force terminate the pod.</li> </ol> <p>If my above understanding is correct, clearly there is no way to tell K8s to:</p> <ol> <li>Don't interrupt current connections</li> <li>Let them run for as long as they need (they will eventually close but the period varies greatly)</li> <li>Once all connections are closed, terminate the pod</li> </ol> <p><strong>Question</strong>: Is there any ways at all to make sure K8s:</p> <ol> <li>Doesn't interrupt WebSocket connection</li> <li>Doesn't force the application to kill the connection in a specific <code>grace-period</code></li> <li>Detects when all WebSocket connections are closed and kill the pod</li> </ol> <p>If anyone can assist me that would be greatly appreciated. </p>
<p>For mission critical application, go for customised blue-green deployments.</p> <p>First deploy new version deployment with new selector and when all POD replicas are UP and ready to serve traffic, switch the service selector to point to new version deployment. </p> <p>After this send the kill switch to older version which gracefully handles and disconnect all clients. So all new reconnections are forwarded to new version which is already set to serve traffic.</p>
<p>I am trying to get a reverse proxy working on kubernetes using nginx and a .net core API. </p> <p>When I request <a href="http://localhost:9000/api/message" rel="nofollow noreferrer">http://localhost:9000/api/message</a> I want something like the following to happen:</p> <pre><code>[Request] --&gt; [nginx](localhost:9000) --&gt; [.net API](internal port 9001) </code></pre> <p>but what appears to be happening is:</p> <pre><code>[Request] --&gt; [nginx](localhost:9000)! Fails because /usr/share/nginx/api/message is not found. </code></pre> <p>Obviously nginx is failing to route the request to the upstream servers. This works correctly when I run the same config under docker-compose but is failing here in kubernetes (local in docker)</p> <p>I am using the following configmap for nginx:</p> <pre><code>error_log /dev/stdout info; events { worker_connections 2048; } http { access_log /dev/stdout; upstream web_tier { server webapi:9001; } server { listen 80; access_log /dev/stdout; location / { proxy_pass http://web_tier; proxy_redirect off; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Host $server_name; } location /nginx_status { stub_status on; access_log off; allow all; } } } </code></pre> <p>The load-balancer yaml is:</p> <pre><code>apiVersion: extensions/v1beta1 kind: Deployment metadata: name: load-balancer spec: replicas: 1 template: metadata: labels: app: load-balancer spec: containers: - args: - nginx - -g - daemon off; env: - name: NGINX_HOST value: example.com - name: NGINX_PORT value: "80" image: nginx:1.15.9 name: iac-load-balancer ports: - containerPort: 80 volumeMounts: - mountPath: /var/lib/nginx readOnly: true name: vol-config - mountPath: /tmp/share/nginx/html readOnly: true name: vol-html volumes: - name: vol-config configMap: name: load-balancer-configmap items: - key: nginx.conf path: nginx.conf - name: vol-html configMap: name: load-balancer-configmap items: - key: index.html path: index.html status: {} --- apiVersion: v1 kind: Service metadata: name: load-balancer spec: type: LoadBalancer ports: - name: http port: 9000 targetPort: 80 selector: app: load-balancer status: loadBalancer: {} </code></pre> <p>Finally the error messages are:</p> <pre><code>2019/04/10 18:47:26 [error] 7#7: *1 open() "/usr/share/nginx/html/api/message" failed (2: No such file or directory), client: 192.168.65.3, server: localhost, request: "GET /api/message HTTP/1.1", host: "localhost:9000", 192.168.65.3 - - [10/Apr/2019:18:47:26 +0000] "GET /api/message HTTP/1.1" 404 555 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.86 Safari/537.36" "-", </code></pre> <p>It seems like nginx is either not reading the config correctly for some reason, or it is failing to communicating with the webapi servers and is defaulting back to trying to serve static local content (nothing in the log indicates a comms issue though).</p> <p><strong>Edit 1:</strong> I should have included that /nginx_status is also not routing correctly and fails with the same "/usr/share/nginx/html/nginx_status" not found error.</p>
<p>Here what i understood is you are requesting a Api, which is giving 404.</p> <blockquote> <p><a href="http://localhost:9000/api/message" rel="nofollow noreferrer">http://localhost:9000/api/message</a></p> </blockquote> <p>I have solved this issue by creating backend service as nodeport, and i am trying to access the api from my Angular App.</p> <p>Here is my configure.conf file which get replaced by original nginx configuration file </p> <pre><code>server { listen 80; server_name localhost; location / { root /usr/share/nginx/html; index index.html index.htm; } } server { listen 5555; location / { proxy_pass http://login:5555; } } server { listen 5554; location / { proxy_pass http://dashboard:5554; } } </code></pre> <p>here i have route my external traffic coming on port 5554/5555 to the service [selector-Name]</p> <p>here login and dashboards are my services having Type as NodePort </p> <p>Here is my Docker file</p> <pre><code>from nginx:1.11-alpine copy configure.conf /etc/nginx/conf.d/default.conf copy dockerpoc /usr/share/nginx/html expose 80 expose 5555 expose 5554 cmd ["nginx","-g","daemon off;"] </code></pre> <p>Here i kept my frontend service's Type as LoadBalancer which will expose a public endpoint and,</p> <p>I am calling my backend Api from frontend as :</p> <blockquote> <p><a href="http://loadbalancer-endpoint:5555/login" rel="nofollow noreferrer">http://loadbalancer-endpoint:5555/login</a></p> </blockquote> <p>Hope this will help you.</p>
<p>I am using Ambassador as the API gateway and am trying to get the external auth to work. I have deployed the auth-service with the corresponding Ambassador annotations</p> <pre><code>... metadata: name: auth-service-svc annotations: getambassador.io/config: | --- apiVersion: ambassador/v1 kind: AuthService name: authentication proto: http path_prefix: "/api" auth_service: auth-service-svc:8080 spec: ports: - port: 8080 targetPort: 8080 name: http selector: app: auth-service type: ClusterIP </code></pre> <p>When I do a <code>curl</code> to initiate a Get request against <a href="http://[hostname]/api" rel="nofollow noreferrer">http://[hostname]/api</a>, I expect the auth-service to be called. However this doesn't seem to happen. When I look at the ambassador logs I see the following message:</p> <pre><code>[2019-04-12 15:10:42.977][75][debug][main] [source/server/connection_handler_impl.cc:257] [C20117] new connection [2019-04-12 15:10:42.977][75][debug][http] [source/common/http/conn_manager_impl.cc:243] [C20117] new stream [2019-04-12 15:10:42.977][75][debug][http] [source/common/http/conn_manager_impl.cc:580] [C20117][S12856858676043764009] request headers complete (end_stream=true): ':authority', '&lt;some-prefix&gt;.elb.amazonaws.com' ':path', '/api/' ':method', 'GET' 'user-agent', 'curl/7.61.0' 'accept', '*/*' [2019-04-12 15:10:42.977][75][debug][http] [source/common/http/conn_manager_impl.cc:1037] [C20117][S12856858676043764009] request end stream [2019-04-12 15:10:42.977][75][debug][router] [source/common/router/router.cc:277] [C20117][S12856858676043764009] no cluster match for URL '/api/' [2019-04-12 15:10:42.977][75][debug][http] [source/common/http/conn_manager_impl.cc:1278] [C20117][S12856858676043764009] encoding headers via codec (end_stream=true): ':status', '404' 'date', 'Fri, 12 Apr 2019 15:10:42 GMT' 'server', 'envoy' [2019-04-12 15:10:43.013][75][debug][connection] [source/common/network/connection_impl.cc:502] [C20117] remote close [2019-04-12 15:10:43.013][75][debug][connection] [source/common/network/connection_impl.cc:183] [C20117] closing socket: 0 </code></pre> <p>Here are the logs (truncated) when the auth-service is deleted and re-created. I have tried to show the logs that capture the update of the envoy config.</p> <pre><code>... 2019-04-12 15:20:59 diagd 0.53.1 [P43TAmbassadorEventWatcher] INFO: copying configuration from http://localhost:34525/api/snapshot/40 to /ambassador/snapshots/snapshot-tmp.yaml 2019-04-12 15:20:59 diagd 0.53.1 [P43TAmbassadorEventWatcher] INFO: Load balancer for tcp://auth-service-svc:8080 is None 2019-04-12 15:20:59 diagd 0.53.1 [P43TAmbassadorEventWatcher] INFO: Load balancer for tcp://127.0.0.1:8877 is None 2019-04-12 15:20:59 diagd 0.53.1 [P43TAmbassadorEventWatcher] INFO: Load balancer for tcp://127.0.0.1:8877 is None 2019-04-12 15:20:59 diagd 0.53.1 [P43TAmbassadorEventWatcher] INFO: Load balancer for tcp://127.0.0.1:8877 is None 2019-04-12 15:20:59 diagd 0.53.1 [P43TAmbassadorEventWatcher] INFO: extauth: server_uri http://api 2019-04-12 15:20:59 diagd 0.53.1 [P43TAmbassadorEventWatcher] INFO: listen_ports ['80'] 2019-04-12 15:20:59 diagd 0.53.1 [P43TAmbassadorEventWatcher] INFO: -global-: NOTICE: Ambassador 0.60 will default to listening on port 8080 for HTTP. You will need to change your configuration to continue using port 80. 2019-04-12 15:20:59 diagd 0.53.1 [P43TAmbassadorEventWatcher] INFO: successfully validated the resulting envoy configuration, continuing... .... [2019-04-12 15:20:59.782][65][debug][config] [source/server/listener_manager_impl.cc:56] name: envoy.http_connection_manager [2019-04-12 15:20:59.783][65][debug][config] [source/server/listener_manager_impl.cc:59] config: {"use_remote_address":true,"access_log":[{"config":{"path":"/dev/fd/1","format":"ACCESS [%START_TIME%] \"%REQ(:METHOD)% %REQ(X-ENVOY-ORIGINAL-PATH?:PATH)% %PROTOCOL%\" %RESPONSE_CODE% %RESPONSE_FLAGS% %BYTES_RECEIVED% %BYTES_SENT% %DURATION% %RESP(X-ENVOY-UPSTREAM-SERVICE-TIME)% \"%REQ(X-FORWARDED-FOR)%\" \"%REQ(USER-AGENT)%\" \"%REQ(X-REQUEST-ID)%\" \"%REQ(:AUTHORITY)%\" \"%UPSTREAM_HOST%\"\n"},"name":"envoy.file_access_log"}],"xff_num_trusted_hops":0,"normalize_path":true,"route_config":{"virtual_hosts":[{"name":"backend","routes":[{"route":{"priority":null,"prefix_rewrite":"/ambassador/v0/check_ready","timeout":"10.000s","weighted_clusters":{"clusters":[{"name":"cluster_127_0_0_1_8877","weight":100}]}},"match":{"prefix":"/ambassador/v0/check_ready","case_sensitive":true}},{"match":{"case_sensitive":true,"prefix":"/ambassador/v0/check_alive"},"route":{"priority":null,"prefix_rewrite":"/ambassador/v0/check_alive","timeout":"10.000s","weighted_clusters":{"clusters":[{"name":"cluster_127_0_0_1_8877","weight":100}]}}},{"match":{"case_sensitive":true,"prefix":"/ambassador/v0/"},"route":{"priority":null,"weighted_clusters":{"clusters":[{"weight":100,"name":"cluster_127_0_0_1_8877"}]},"timeout":"10.000s","prefix_rewrite":"/ambassador/v0/"}},{"match":{"case_sensitive":true,"prefix":"/leads/"},"route":{"timeout":"3.000s","prefix_rewrite":"/","weighted_clusters":{"clusters":[{"weight":100,"name":"cluster_lead_service_svc"}]},"priority":null}}],"domains":["*"]}]},"http_filters":[{"config":{"http_service":{"server_uri":{"timeout":"5.000s","uri":"http://api","cluster":"cluster_extauth_auth_service_svc_8080"},"authorization_request":{"allowed_headers":{"patterns":[{"exact":"x-forwarded-proto"},{"exact":"cookie"},{"exact":"user-agent"},{"exact":"proxy-authorization"},{"exact":"from"},{"exact":"authorization"},{"exact":"x-forwarded-for"},{"exact":"x-forwarded-host"}]}},"path_prefix":"/api","authorization_response":{"allowed_client_headers":{"patterns":[{"exact":"authorization"},{"exact":"set-cookie"},{"exact":"location"},{"exact":"www-authenticate"},{"exact":"proxy-authenticate"}]},"allowed_upstream_headers":{"patterns":[{"exact":"authorization"},{"exact":"set-cookie"},{"exact":"location"},{"exact":"www-authenticate"},{"exact":"proxy-authenticate"}]}}}},"name":"envoy.ext_authz"},{"name":"envoy.cors"},{"name":"envoy.router"}],"stat_prefix":"ingress_http"} 2019-04-12 15:20:59 diagd 0.53.1 [P43TAmbassadorEventWatcher] INFO: configuration updated from snapshot 40 2019-04-12 15:20:59 diagd 0.53.1 [P43TAmbassadorEventWatcher] INFO: Scout reports {"latest_version": "0.53.1", "application": "ambassador", "cached": true, "timestamp": 1555081685.663466} 2019-04-12 15:20:59 diagd 0.53.1 [P43TAmbassadorEventWatcher] INFO: Scout notices: [{"level": "DEBUG", "message": "Returning cached result"}] [2019-04-12 15:20:59.799][65][debug][config] [source/extensions/filters/network/http_connection_manager/config.cc:302] http filter #0 [2019-04-12 15:20:59.799][65][debug][config] [source/extensions/filters/network/http_connection_manager/config.cc:303] name: envoy.ext_authz [2019-04-12 15:20:59.800][65][debug][config] [source/extensions/filters/network/http_connection_manager/config.cc:307] config: {"http_service":{"authorization_response":{"allowed_upstream_headers":{"patterns":[{"exact":"authorization"},{"exact":"set-cookie"},{"exact":"location"},{"exact":"www-authenticate"},{"exact":"proxy-authenticate"}]},"allowed_client_headers":{"patterns":[{"exact":"authorization"},{"exact":"set-cookie"},{"exact":"location"},{"exact":"www-authenticate"},{"exact":"proxy-authenticate"}]}},"server_uri":{"timeout":"5.000s","uri":"http://api","cluster":"cluster_extauth_auth_service_svc_8080"},"authorization_request":{"allowed_headers":{"patterns":[{"exact":"x-forwarded-proto"},{"exact":"cookie"},{"exact":"user-agent"},{"exact":"proxy-authorization"},{"exact":"from"},{"exact":"authorization"},{"exact":"x-forwarded-for"},{"exact":"x-forwarded-host"}]}},"path_prefix":"/api"}} [2019-04-12 15:20:59.801][65][debug][config] [source/extensions/filters/network/http_connection_manager/config.cc:302] http filter #1 [2019-04-12 15:20:59.801][65][debug][config] [source/extensions/filters/network/http_connection_manager/config.cc:303] name: envoy.cors [2019-04-12 15:20:59.801][65][debug][config] [source/extensions/filters/network/http_connection_manager/config.cc:307] config: {} [2019-04-12 15:20:59.801][65][debug][config] [source/extensions/filters/network/http_connection_manager/config.cc:302] http filter #2 [2019-04-12 15:20:59.801][65][debug][config] [source/extensions/filters/network/http_connection_manager/config.cc:303] name: envoy.router [2019-04-12 15:20:59.801][65][debug][config] [source/extensions/filters/network/http_connection_manager/config.cc:307] config: {} [2019-04-12 15:20:59.804][65][debug][config] [source/server/listener_manager_impl.cc:627] add warming listener: name=ambassador-listener-80, hash=1783155174245818883, address=0.0.0.0:80 [2019-04-12 15:20:59.804][65][debug][init] [source/common/init/manager_impl.cc:45] init manager Listener ambassador-listener-80 contains no targets [2019-04-12 15:20:59.804][65][debug][init] [source/common/init/watcher_impl.cc:14] init manager Listener ambassador-listener-80 initialized, notifying ListenerImpl [2019-04-12 15:20:59.805][65][debug][config] [source/server/listener_manager_impl.cc:627] warm complete. updating active listener: name=ambassador-listener-80, hash=1783155174245818883, address=0.0.0.0:80 [2019-04-12 15:20:59.805][65][debug][config] [source/server/listener_manager_impl.cc:627] draining listener: name=ambassador-listener-80, hash=5292162044335998753, address=0.0.0.0:80 [2019-04-12 15:20:59.805][65][info][upstream] [source/server/lds_api.cc:74] lds: add/update listener 'ambassador-listener-80' [2019-04-12 15:20:59.806][65][debug][config] [source/common/config/grpc_mux_impl.cc:104] Resuming discovery requests for type.googleapis.com/envoy.api.v2.RouteConfiguration [2019-04-12 15:20:59.806][65][debug][config] [bazel-out/k8-dbg/bin/source/common/config/_virtual_includes/grpc_mux_subscription_lib/common/config/grpc_mux_subscription_impl.h:66] gRPC config for type.googleapis.com/envoy.api.v2.Listener accepted with 1 resources with version v40 [2019-04-12 15:20:59.806][65][debug][config] [source/common/config/grpc_mux_impl.cc:118] Received gRPC message for type.googleapis.com/envoy.api.v2.Cluster at version v40 [2019-04-12 15:20:59.806][65][debug][config] [source/common/config/grpc_mux_impl.cc:96] Pausing discovery requests for type.googleapis.com/envoy.api.v2.ClusterLoadAssignment [2019-04-12 15:20:59.811][65][info][upstream] [source/common/upstream/cluster_manager_impl.cc:483] add/update cluster cluster_extauth_auth_service_svc_8080 starting warming [2019-04-12 15:20:59.811][65][debug][config] [source/common/config/grpc_mux_impl.cc:96] Pausing discovery requests for type.googleapis.com/envoy.api.v2.Cluster [2019-04-12 15:20:59.811][65][debug][upstream] [source/common/network/dns_impl.cc:158] Setting DNS resolution timer for 5000 milliseconds [2019-04-12 15:20:59.811][65][debug][upstream] [source/common/upstream/cds_api_impl.cc:110] cds: add/update cluster 'cluster_extauth_auth_service_svc_8080' [2019-04-12 15:20:59.811][65][debug][config] [source/common/config/grpc_mux_impl.cc:104] Resuming discovery requests for type.googleapis.com/envoy.api.v2.ClusterLoadAssignment [2019-04-12 15:20:59.811][65][debug][config] [bazel-out/k8-dbg/bin/source/common/config/_virtual_includes/grpc_mux_subscription_lib/common/config/grpc_mux_subscription_impl.h:66] gRPC config for type.googleapis.com/envoy.api.v2.Cluster accepted with 3 resources with version v40 [2019-04-12 15:20:59.812][65][debug][upstream] [source/common/upstream/upstream_impl.cc:1358] DNS hosts have changed for auth-service-svc [2019-04-12 15:20:59.812][65][debug][upstream] [source/common/upstream/upstream_impl.cc:721] initializing secondary cluster cluster_extauth_auth_service_svc_8080 completed [2019-04-12 15:20:59.812][65][debug][init] [source/common/init/manager_impl.cc:45] init manager Cluster cluster_extauth_auth_service_svc_8080 contains no targets [2019-04-12 15:20:59.812][65][debug][init] [source/common/init/watcher_impl.cc:14] init manager Cluster cluster_extauth_auth_service_svc_8080 initialized, notifying ClusterImplBase [2019-04-12 15:20:59.812][65][info][upstream] [source/common/upstream/cluster_manager_impl.cc:496] warming cluster cluster_extauth_auth_service_svc_8080 complete [2019-04-12 15:20:59.812][75][debug][upstream] [source/common/upstream/cluster_manager_impl.cc:517] adding TLS cluster cluster_extauth_auth_service_svc_8080 [2019-04-12 15:20:59.812][76][debug][upstream] [source/common/upstream/cluster_manager_impl.cc:517] adding TLS cluster cluster_extauth_auth_service_svc_8080 [2019-04-12 15:20:59.812][65][debug][upstream] [source/common/upstream/cluster_manager_impl.cc:517] adding TLS cluster cluster_extauth_auth_service_svc_8080 [2019-04-12 15:20:59.812][75][debug][upstream] [source/common/upstream/cluster_manager_impl.cc:978] membership update for TLS cluster cluster_extauth_auth_service_svc_8080 added 1 removed 0 [2019-04-12 15:20:59.812][76][debug][upstream] [source/common/upstream/cluster_manager_impl.cc:978] membership update for TLS cluster cluster_extauth_auth_service_svc_8080 added 1 removed 0 [2019-04-12 15:20:59.812][65][debug][upstream] [source/common/upstream/cluster_manager_impl.cc:978] membership update for TLS cluster cluster_extauth_auth_service_svc_8080 added 1 removed 0 [2019-04-12 15:20:59.812][65][debug][config] [source/common/config/grpc_mux_impl.cc:104] Resuming discovery requests for type.googleapis.com/envoy.api.v2.Cluster .... </code></pre> <p>Any hints as to why the path is not being detected and routed to the external auth service?</p>
<p>The <code>path_prefix: "/api"</code> does <strong>not</strong> create a mapping for your auth-service, it only tells that /api will be appended to your requests, and that the auth-service needs that prefix. When you define an auth service in Ambassador all your requests will be redirected to the auth service. If you need to make a request to the auth service directly, create a mapping for it.</p> <p>Example: If you have a service with mapping:</p> <pre><code>apiVersion: ambassador/v1 kind: Mapping name: myapp-mapping prefix: /myapp/ service: myapp:8000 </code></pre> <p>When you do <code>curl $URL/myapp/</code> , the request will be redirected to auth-service at $URL/api/myapp. The auth-service needs to have an endpoint for <em>/api/myapp</em>. If it returns an HTTP status 200, then ambassador will send the original request to myapp. Otherwise, it will return the auth-service response to the client.<br> If you would like to use <code>curl $URL/api/myapp</code> then you could remove your prefix in your auth-service and change the prefix of myapp to <em>/api/myapp/</em></p> <p>Please read <a href="https://www.getambassador.io/user-guide/auth-tutorial/" rel="nofollow noreferrer">this tutorial</a> for more details.</p>
<p>I would like to dynamically provision 3 persistent volumes for my system, which are all based on a <code>storageClass</code> that I previously created. My v1 code does its job successfully. </p> <p>v1:</p> <pre><code>apiVersion: v1 kind: PersistentVolume metadata: name: volume0 labels: type: storage-one spec: storageClassName: storage-one accessModes: - ReadWriteMany capacity: storage: 2Gi hostPath: path: /somepath type: "DirectoryOrCreate" --- apiVersion: v1 kind: PersistentVolume metadata: name: volume1 labels: type: storage-one spec: storageClassName: storage-one accessModes: - ReadWriteMany capacity: storage: 2Gi hostPath: path: /somepath type: "DirectoryOrCreate" --- apiVersion: v1 kind: PersistentVolume metadata: name: volume2 labels: type: storage-one spec: storageClassName: storage-one accessModes: - ReadWriteMany capacity: storage: 2Gi hostPath: path: /somepath type: "DirectoryOrCreate" </code></pre> <p>I would like to refactor this code, possibly with a template that k8s can recognize, as the only variable here is the <code>metadata.name</code>. Is it possible?</p>
<p>Natively kubernetes does not recognize any templates. But you can use any templating engine before you pass this yaml to kubectl. </p> <p>Common practice is to use helm which uses gotpl inside. <a href="https://helm.sh/docs/chart_template_guide/" rel="nofollow noreferrer">https://helm.sh/docs/chart_template_guide/</a></p> <p>Your example will look like:</p> <pre><code>{{ range .Values.volume_names }} --- apiVersion: v1 kind: PersistentVolume metadata: name: {{ . }} labels: type: storage-one spec: storageClassName: storage-one accessModes: - ReadWriteMany capacity: storage: 2Gi hostPath: path: /somepath type: "DirectoryOrCreate" {{ end }} </code></pre> <p>And values.yaml:</p> <pre><code>volume_names: - volume_this - volume_that </code></pre> <p>Generally you can do <code>render_with_your_fav_engine_to_stdout | kubectl apply -f</code> using any engine.</p> <p>UPD: Generate based on given len (this one was weird):</p> <pre><code>{{ range $k, $v := until (atoi .Values.numVolumes) }} --- apiVersion: v1 kind: PersistentVolume metadata: name: volume-{{ $v }} labels: type: storage-one spec: storageClassName: storage-one accessModes: - ReadWriteMany capacity: storage: 2Gi hostPath: path: /somepath type: "DirectoryOrCreate" {{ end }} </code></pre> <p>And values.yaml:</p> <pre><code>numVolumes: "3" </code></pre>
<p>We currently have pods in a kubernetes cluster (AKS) that need to resolve two different domains. </p> <p>The first domain beeing the cluster domain default.svc.cluster.local and the second one beeing mydns.local </p> <p>how can this be achieved?</p>
<p>I found the solution myself. </p> <p>There are two ways to achieve the desired name resolution:</p> <ol> <li>If your AKS Cluster is within an Azure VNET you can set the DNS settings in the VNET to the custom DNS Server that is able to resolve your custom domain. If your Pods have no specified dns settings then the resolution will work this way:</li> </ol> <p>First the Pods try to resolve the DNS request within CoreDNS, if they can't then they take the DNS settings of the host and ask the DNS Server configured in the host. Since in azure the DNS settings of the VNET are applied to the Virtual Machines it will ask the correct DNS server.</p> <ol start="2"> <li><p>Modify the coreDNS settings in your AKS cluster with the following json :</p> <pre><code>apiVersion: v1 kind: ConfigMap metadata: name: coredns-custom namespace: kube-system data: yourdns.server: | yourdns.com:53 { errors cache 1 proxy . 10.1.0.40 } </code></pre></li> </ol> <p>Important to know is, that in AKS you can't overwrite the coredns ConfigMap. The Kubernetes master will always reset it to the default after a couple of seconds. If you want to edit the ConfigMap in AKS you have to name the configmap "coredns-custom".</p> <p><code>yourdns.server</code> is actually not the server. It is the <code>domain.server</code>. The DNS server IP is behind the proxy setting.</p>
<p>I am trying to set annotations on my Service object in Kubernetes, but for some reason (even tho the k8s master accepts my request) the annotations are not being set. Here is my YAML file:</p> <pre><code>--- apiVersion: v1 kind: Service metadata: name: myapp labels: app: myapp annotations: service.beta.kubernetes.io/aws-load-balancer-ssl-cert: 'arn:aws:acm:us-west-2:&lt;redacted&gt;:certificate/&lt;redacted&gt;' service.beta.kubernetes.io/aws-load-balancer-ssl-negotiation-policy: 'ELBSecurityPolicy-TLS-1-2-2017-01' service.beta.kubernetes.io/aws-load-balancer-backend-protocol: 'http' service.beta.kubernetes.io/aws-load-balancer-additional-resource-tags: 'app=myapp' service.beta.kubernetes.io/aws-load-balancer-access-log-enabled: true spec: type: LoadBalancer selector: app: myapp-web ports: - protocol: TCP port: 80 targetPort: 3000 </code></pre> <p>I can then apply the file without error:</p> <pre><code>[ben@ubuntu simplenexus.com]$ kc apply -f deploy/k8s/service.yaml service/myapp created </code></pre> <p>However querying the object returns with none of the annotations:</p> <pre><code>[ben@ubuntu simplenexus.com]$ kc get svc myapp -o yaml apiVersion: v1 kind: Service metadata: annotations: kubectl.kubernetes.io/last-applied-configuration: | {"apiVersion":"v1","kind":"Service","metadata":{"annotations":{},"labels":{"app":"myapp"},"name":"myapp","namespace":"default"},"spec":{"ports":[{"port":80,"protocol":"TCP","targetPort":3000}], "selector":{"app":"myapp-web"},"type":"LoadBalancer"}} creationTimestamp: "2019-04-11T16:27:45Z" labels: app: myapp name: myapp namespace: default resourceVersion: "2085328" selfLink: /api/v1/namespaces/default/services/myapp uid: &lt;redacted&gt; spec: clusterIP: &lt;redacted&gt; externalTrafficPolicy: Cluster ports: - nodePort: 32118 port: 80 protocol: TCP targetPort: 3000 selector: app: myapp-web sessionAffinity: None type: LoadBalancer status: loadBalancer: ingress: - hostname: &lt;redacted&gt;.us-west-2.elb.amazonaws.com </code></pre> <p>I can manually set annotations, and they stay:</p> <pre><code>[ben@ubuntu simplenexus.com]$ kc annotate svc myapp newannot=success service/myapp annotated [ben@ubuntu simplenexus.com]$ kc get svc myapp -o yaml apiVersion: v1 kind: Service metadata: annotations: kubectl.kubernetes.io/last-applied-configuration: | {"apiVersion":"v1","kind":"Service","metadata":{"annotations":{},"labels":{"app":"myapp"},"name":"myapp","namespace":"default"},"spec":{"ports":[{"port":80,"protocol":"TCP","targetPort":3000}], "selector":{"app":"myapp-web"},"type":"LoadBalancer"}} newannot: success creationTimestamp: "2019-04-11T16:27:45Z" labels: app: myapp name: myapp namespace: default resourceVersion: "2085328" selfLink: /api/v1/namespaces/default/services/myapp uid: &lt;redacted&gt; ... </code></pre> <p>Am I doing this wrong? What's the proper way to set annotations on a Kubernetes Service object in a YAML file?</p>
<p>It turns out you can't use boolean values in annotations, here's ongoing <a href="https://github.com/kubernetes/kubernetes/issues/59113" rel="nofollow noreferrer">bug report</a> for it. Annotation values must be strings, so you'll need to sanitize it by putting values in brackets <code>'...'</code>.</p> <p>I deployed your YAML and it worked with:</p> <pre><code> service.beta.kubernetes.io/aws-load-balancer-access-log-enabled: 'true' </code></pre>
<p>I'm experimenting Kops on AWS. My cluster is composed by 1 master node and 3 worker nodes. All works fine and in order to test a Master node failure i terminated the corresponding EC2 instance and of course the AutoScaling group handled that problem and created a new instance and it became the the new Master node. So is fine.</p> <p>My question is how the AutoScaling group did to configure the new EC2 instance to properly be configured as a Master Kubernetes node ? Is there any predefined AMI created when i setup KOPS ? Or is there any user data script that is launched each time a new instance is created ?</p> <p>Thanks.</p>
<p>This is because kops has the concept of <a href="https://github.com/kubernetes/kops/blob/master/docs/instance_groups.md" rel="nofollow noreferrer">instance groups</a>. On AWS they are directly mapped to AutoScalingGroup - which is a similar concept. You can check your instance groups by running <code>kops get ig</code> and also you can edit and descale your master and nodes to 0 and then relaunch them by <code>kops edit ig nodes/nameofthemaster</code>. The second part is kops <a href="https://github.com/kubernetes/kops/blob/master/docs/state.md" rel="nofollow noreferrer">State Store</a>. Which is a location where the cluster configuration is located. This maps to the most of the Kubernetes configuration, except some of the resources and for example deployments (so internal state) which are stored in <a href="https://kubernetes.io/docs/concepts/overview/components/#etcd" rel="nofollow noreferrer">etcd</a>. </p> <p>So in your case when you delete a master node, the AWS will see that the state of your AutoScalingGroup is 0 instead of 1 so it will recreate the EC2 machine.</p> <pre><code>Description:DescriptionLaunching a new EC2 instance: i-0e06f8fbb78aca2e6 Cause:CauseAt 2019-04-10T12:54:31Z an instance was started in response to a difference between desired and actual capacity, increasing the capacity from 0 to 1. </code></pre> <p>After that Kubernetes will take it's configuration from the S3 bucket and the internal state from etcd. Next question would be how does the etcd survive the deletion of the master. You can check it in your Volumes, as etcd has two separate volumes (just as etcd pods one for events and one main) After you delete the master, volumes go into <code>avalivable</code> state and after the new master EC2 instance is spawned this volumes will be mounted to the new master, and you will restore the internal state (not sure, but I think <a href="https://github.com/kubernetes/kops/tree/master/protokube#protokube" rel="nofollow noreferrer">protokube</a> is also somewhere in the picture). </p> <p>This is also the reason why you can restore your kops cluster from just s3 bucket as there is all the configuration that kops need to run. Except the internal state, which is in etcd for which you would need some separate backup. </p>
<p>I'm following a tutorial by <a href="https://medium.com/@diegomrtnzg/secure-your-kubernetes-services-by-using-https-connections-63fa102a90c2" rel="nofollow noreferrer">Diego Martínez</a>, outlining how to use an ingress controller with SSL on K8s. Everything works fine, with the exception of an RBAC error:</p> <p><code>It seems the cluster it is running with Authorization enabled (like RBAC) and there is no permissions for the ingress controller. Please check the configuration</code></p> <p>Does anyone know how I can grant RBAC permissions to this resource?</p> <p>I'm running on Google Cloud, and for reference, below is the ingress deployment spec</p> <p><a href="https://i.stack.imgur.com/N28J6.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/N28J6.png" alt="Ingress Deployment"></a></p>
<p>If you are deploying nginx-ingress, perhaps the <a href="https://github.com/helm/charts/tree/master/stable/nginx-ingress" rel="nofollow noreferrer">nginx-ingress Helm chart</a> is a simpler way to do it.</p> <p>You can follow <a href="https://kubernetes.github.io/ingress-nginx/deploy/" rel="nofollow noreferrer">the guide</a> on the nginx-ingress documentation installation on RBAC-enabled clusters.</p> <p>Specifically addressing your question regarding adding the RBAC permissions, you will need to add something like:</p> <pre><code>--- apiVersion: v1 kind: ServiceAccount metadata: name: nginx-ingress-serviceaccount namespace: ingress-nginx labels: app.kubernetes.io/name: ingress-nginx app.kubernetes.io/part-of: ingress-nginx --- apiVersion: rbac.authorization.k8s.io/v1beta1 kind: ClusterRole metadata: name: nginx-ingress-clusterrole labels: app.kubernetes.io/name: ingress-nginx app.kubernetes.io/part-of: ingress-nginx rules: - apiGroups: - &quot;&quot; resources: - configmaps - endpoints - nodes - pods - secrets verbs: - list - watch - apiGroups: - &quot;&quot; resources: - nodes verbs: - get - apiGroups: - &quot;&quot; resources: - services verbs: - get - list - watch - apiGroups: - &quot;extensions&quot; resources: - ingresses verbs: - get - list - watch - apiGroups: - &quot;&quot; resources: - events verbs: - create - patch - apiGroups: - &quot;extensions&quot; resources: - ingresses/status verbs: - update --- apiVersion: rbac.authorization.k8s.io/v1beta1 kind: Role metadata: name: nginx-ingress-role namespace: ingress-nginx labels: app.kubernetes.io/name: ingress-nginx app.kubernetes.io/part-of: ingress-nginx rules: - apiGroups: - &quot;&quot; resources: - configmaps - pods - secrets - namespaces verbs: - get - apiGroups: - &quot;&quot; resources: - configmaps resourceNames: # Defaults to &quot;&lt;election-id&gt;-&lt;ingress-class&gt;&quot; # Here: &quot;&lt;ingress-controller-leader&gt;-&lt;nginx&gt;&quot; # This has to be adapted if you change either parameter # when launching the nginx-ingress-controller. - &quot;ingress-controller-leader-nginx&quot; verbs: - get - update - apiGroups: - &quot;&quot; resources: - configmaps verbs: - create - apiGroups: - &quot;&quot; resources: - endpoints verbs: - get --- apiVersion: rbac.authorization.k8s.io/v1beta1 kind: RoleBinding metadata: name: nginx-ingress-role-nisa-binding namespace: ingress-nginx labels: app.kubernetes.io/name: ingress-nginx app.kubernetes.io/part-of: ingress-nginx roleRef: apiGroup: rbac.authorization.k8s.io kind: Role name: nginx-ingress-role subjects: - kind: ServiceAccount name: nginx-ingress-serviceaccount namespace: ingress-nginx --- apiVersion: rbac.authorization.k8s.io/v1beta1 kind: ClusterRoleBinding metadata: name: nginx-ingress-clusterrole-nisa-binding labels: app.kubernetes.io/name: ingress-nginx app.kubernetes.io/part-of: ingress-nginx roleRef: apiGroup: rbac.authorization.k8s.io kind: ClusterRole name: nginx-ingress-clusterrole subjects: - kind: ServiceAccount name: nginx-ingress-serviceaccount namespace: ingress-nginx </code></pre>
<p>I've been working with a bunch of k8s clusters for a while, using kubectl from the command line to examine information. I don't actually call kubectl directly, I wrap it in multiple scripting layers. I also don't use contexts, as it's much easier for me to specify different clusters in a different way. The resulting kubectl command line has explicit --server, --namespace, and --token parameters (and one other flag to disable tls verify).</p> <p>This all works fine. I have no trouble with this.</p> <p>However, I'm now trying to use telepresence, which doesn't give me a choice (yet) of not using contexts to configure this. So, I now have to figure out how to use contexts.</p> <p>I ran the following (approximate) command:</p> <pre><code>kubectl config set-context mycontext --server=https://host:port --namespace=abc-def-ghi --insecure-skip-tls-verify=true --token=mytoken </code></pre> <p>And it said: "Context "mycontext " modified."</p> <p>I then ran "kubectl config view -o json" and got this:</p> <pre><code>{ "kind": "Config", "apiVersion": "v1", "preferences": {}, "clusters": [], "users": [], "contexts": [ { "name": "mycontext", "context": { "cluster": "", "user": "", "namespace": "abc-def-ghi" } } ], "current-context": "mycontext" } </code></pre> <p>That doesn't look right to me.</p> <p>I then ran something like this:</p> <pre><code>telepresence --verbose --swap-deployment mydeployment --expose 8080 --run java -jar target/my.jar -Xdebug -Xrunjdwp:transport=dt_socket,address=5000,server=y,suspend=n </code></pre> <p>And it said this:</p> <pre><code>T: Error: Namespace 'abc-def-ghi' does not exist </code></pre> <p><strong>Update</strong>:</p> <p>And I can confirm that this isn't a problem with telepresence. If I just run "kubectl get pods", it fails, saying "The connection to the server localhost:8080 was refused". That tells me it obviously can't connect to the k8s server. The key is my "set-context" command. It's obviously not working, and I don't understand what I'm missing.</p>
<p>You don't have any clusters or credentials defined in your configuration. First, you need to define a cluster:</p> <pre><code>$ kubectl config set-cluster development --server=https://1.2.3.4 --certificate-authority=fake-ca-file </code></pre> <p>Then something like this for the user:</p> <pre><code>$ kubectl config set-credentials developer --client-certificate=fake-cert-file --client-key=fake-key-seefile </code></pre> <p>Then you define your context based on your cluster, user and namespace:</p> <pre><code>$ kubectl config set-context dev-frontend --cluster=development --namespace=frontend --user=developer </code></pre> <p>More information <a href="https://kubernetes.io/docs/tasks/access-application-cluster/configure-access-multiple-clusters/" rel="nofollow noreferrer">here</a></p> <p>Your config should look something like this:</p> <pre><code>$ kubectl config view -o json { &quot;kind&quot;: &quot;Config&quot;, &quot;apiVersion&quot;: &quot;v1&quot;, &quot;preferences&quot;: {}, &quot;clusters&quot;: [ { &quot;name&quot;: &quot;development&quot;, &quot;cluster&quot;: { &quot;server&quot;: &quot;https://1.2.3.4&quot;, &quot;certificate-authority-data&quot;: &quot;DATA+OMITTED&quot; } } ], &quot;users&quot;: [ { &quot;name&quot;: &quot;developer&quot;, &quot;user&quot;: { &quot;client-certificate&quot;: &quot;fake-cert-file&quot;, &quot;client-key&quot;: &quot;fake-key-seefile&quot; } } ], &quot;contexts&quot;: [ { &quot;name&quot;: &quot;dev-frontend&quot;, &quot;context&quot;: { &quot;cluster&quot;: &quot;development&quot;, &quot;user&quot;: &quot;developer&quot;, &quot;namespace&quot;: &quot;frontend&quot; } } ], &quot;current-context&quot;: &quot;dev-frontend&quot; } </code></pre>
<p>I created a cluster on Google Kubernetes Engine. The nodes get deleted/created very often (at least once a day). Even though new instances are created to replace them, and pods are moved to these new nodes, I would like to understand why the nodes disappear.</p> <p>I checked the settings used to create the cluster and the node pool:</p> <ul> <li>"Automatic node upgrade" is Disabled on the node pool.</li> <li>"Pre-emptible nodes" is Disabled. </li> <li>"Automatic node repair" is Enabled, but I doesn't look like there was a node repair, since I don't see anything in <code>gcloud container operations list</code> at the time when my nodes were deleted.</li> </ul> <p>I can see that the current nodes were all (re-)created at 21:00, while the cluster was created at 08:35 :</p> <pre><code>➜ ~ gcloud container clusters describe my-cluster --format=json { "createTime": "2019-04-11T08:35:39+00:00", ... "nodePools": [ { ... "management": { "autoRepair": true }, "name": "default-pool", } ], "status": "RUNNING", ... } </code></pre> <p>How can I trace the reason why the nodes were deleted ?</p>
<p>I tried to reproduce your problem by creating a cluster, manually stopping the kubelet on a node (by running <code>systemctl stop kubelet</code>) to trigger repair and watching the node recover. In my case, I do see an operation for the auto node repair, but I can also see in the GCE operations log that the VM was deleted and recreated (by the GKE robot account). </p> <p>If you run <code>gcloud compute operations list</code> (or check the <a href="https://pantheon.corp.google.com/compute/operations" rel="nofollow noreferrer">cloud console page</a> for operations) you should see what caused the VM to be deleted and recreated. </p>
<p>I have 1TB of images stored in GCS (data is splitted into 3 classes). I want to train custom Tensor Flow model on this data in Kubeflow. Currently, I have pipeline components for training and persisting the model but I don't know how to correctly feed this data into the classifier.</p> <p>It seems to me like downloading this data from GCS (gsutil cp / something other) every time I run (possibly with fail) the pipeline is not a proper way to do this. </p> <p>How to use large volumes of data in Kubeflow pipelines without downloading them every time? How to express access to this data using Kubeflow DSL?</p>
<p>Additionally, if your data <em>is</em> in GCS, then TensorFlow supports the ability to access data in (and write to) GCS. The <a href="https://www.tensorflow.org/guide/performance/datasets" rel="nofollow noreferrer">tf.data api</a> lets you set up a performant data input pipeline.</p>
<p>I have deployed Grafana using Helm chart with subpath /grafana. Now trying to access using service nodeport, like this <a href="http://192.168.16.15:30837/grafana/" rel="nofollow noreferrer">http://192.168.16.15:30837/grafana/</a></p> <p>But Grafana has failed to load its application files. How can I make this work with nodeport.</p> <p><strong>log message.</strong></p> <pre><code>lvl=info msg="HTTP Server Listen" logger=http.server address=0.0.0.0:3000 protocol=http subUrl=/grafana socket= ·· t=2018-12-03T02:35:44+0000 lvl=info msg="Request Completed" logger=context userId=0 orgId=0 uname= method=GET path=/grafana/ status=404 t=2018-12-03T02:35:44+0000 lvl=info msg="Request Completed" logger=context userId=0 orgId=0 uname= method=GETpath=/grafana/public/build/app.d1f313cb0bbe86ea2│······· d5f.js status=404 </code></pre> <p><strong>Config file</strong></p> <pre><code>$ cat /etc/grafana/grafana.ini [analytics] check_for_updates = true [grafana_net] url = https://grafana.net [log] mode = console [paths] data = /var/lib/grafana/data logs = /var/log/grafana plugins = /var/lib/grafana/plugins provisioning = /etc/grafana/provisioning [server] root_url = http://localhost:3000/grafana/ </code></pre> <p>Also tired root url with this value, didn't work also.</p> <pre><code> server: root_url: http://192.168.16.15:30837/grafana </code></pre> <p><strong>Browser message.</strong></p> <p><a href="https://i.stack.imgur.com/YbOo5.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/YbOo5.png" alt="enter image description here"></a> </p> <p>Thanks SR </p> <p>adding values.yaml file</p> <pre><code>rbac: create: true pspEnabled: true serviceAccount: create: true name: replicas: 1 deploymentStrategy: RollingUpdate readinessProbe: httpGet: path: /api/health port: 3000 livenessProbe: httpGet: path: /api/health port: 3000 initialDelaySeconds: 60 timeoutSeconds: 30 failureThreshold: 10 image: repository: grafana/grafana tag: 5.3.4 pullPolicy: IfNotPresent ## Optionally specify an array of imagePullSecrets. ## Secrets must be manually created in the namespace. ## ref: https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/ ## # pullSecrets: # - myRegistrKeySecretName securityContext: runAsUser: 472 fsGroup: 472 ## Assign a PriorityClassName to pods if set # priorityClassName: downloadDashboardsImage: repository: appropriate/curl tag: latest pullPolicy: IfNotPresent ## Pod Annotations # podAnnotations: {} ## Deployment annotations # annotations: {} ## Expose the grafana service to be accessed from outside the cluster (LoadBalancer service). ## or access it from within the cluster (ClusterIP service). Set the service type and the port to serve it. ## ref: http://kubernetes.io/docs/user-guide/services/ ## service: type: NodePort port: 80 annotations: {} labels: {} ingress: enabled: false annotations: {} # kubernetes.io/ingress.class: nginx # kubernetes.io/tls-acme: "true" labels: {} path: / hosts: - chart-example.local tls: [] # - secretName: chart-example-tls # hosts: # - chart-example.local resources: {} # limits: # cpu: 100m # memory: 128Mi # requests: # cpu: 100m # memory: 128Mi ## Node labels for pod assignment ## ref: https://kubernetes.io/docs/user-guide/node-selection/ # nodeSelector: {} ## Tolerations for pod assignment ## ref: https://kubernetes.io/docs/concepts/configuration/taint-and-toleration/ ## tolerations: [] ## Affinity for pod assignment ## ref: https://kubernetes.io/docs/concepts/configuration/assign-pod-node/#affinity-and-anti-affinity ## affinity: {} ## Enable persistence using Persistent Volume Claims ## ref: http://kubernetes.io/docs/user-guide/persistent-volumes/ ## persistence: enabled: false # storageClassName: default # accessModes: # - ReadWriteOnce # size: 10Gi # annotations: {} # subPath: "" # existingClaim: adminUser: admin # adminPassword: strongpassword ## Use an alternate scheduler, e.g. "stork". ## ref: https://kubernetes.io/docs/tasks/administer-cluster/configure-multiple-schedulers/ ## # schedulerName: ## Extra environment variables that will be pass onto deployment pods env: {} ## The name of a secret in the same kubernetes namespace which contain values to be added to the environment ## This can be useful for auth tokens, etc envFromSecret: "" ## Additional grafana server secret mounts # Defines additional mounts with secrets. Secrets must be manually created in the namespace. extraSecretMounts: [] # - name: secret-files # mountPath: /etc/secrets # secretName: grafana-secret-files # readOnly: true ## Pass the plugins you want installed as a list. ## plugins: [] # - digrich-bubblechart-panel # - grafana-clock-panel ## Configure grafana datasources ## ref: http://docs.grafana.org/administration/provisioning/#datasources ## datasources: {} # datasources.yaml: # apiVersion: 1 # datasources: # - name: Prometheus # type: prometheus # url: http://prometheus-prometheus-server # access: proxy # isDefault: true ## Configure grafana dashboard providers ## ref: http://docs.grafana.org/administration/provisioning/#dashboards ## ## `path` must be /var/lib/grafana/dashboards/&lt;provider_name&gt; ## dashboardProviders: {} # dashboardproviders.yaml: # apiVersion: 1 # providers: # - name: 'default' # orgId: 1 # folder: '' # type: file # disableDeletion: false # editable: true # options: # path: /var/lib/grafana/dashboards/default ## Configure grafana dashboard to import ## NOTE: To use dashboards you must also enable/configure dashboardProviders ## ref: https://grafana.com/dashboards ## ## dashboards per provider, use provider name as key. ## dashboards: {} # default: # some-dashboard: # json: | # $RAW_JSON # prometheus-stats: # gnetId: 2 # revision: 2 # datasource: Prometheus # local-dashboard: # url: https://example.com/repository/test.json ## Reference to external ConfigMap per provider. Use provider name as key and ConfiMap name as value. ## A provider dashboards must be defined either by external ConfigMaps or in values.yaml, not in both. ## ConfigMap data example: ## ## data: ## example-dashboard.json: | ## RAW_JSON ## dashboardsConfigMaps: {} # default: "" ## Grafana's primary configuration ## NOTE: values in map will be converted to ini format ## ref: http://docs.grafana.org/installation/configuration/ ## grafana.ini: server: root_url: http://192.168.16.15:30837/grafana paths: data: /var/lib/grafana/data logs: /var/log/grafana plugins: /var/lib/grafana/plugins provisioning: /etc/grafana/provisioning analytics: check_for_updates: true log: mode: console grafana_net: url: https://grafana.net ## LDAP Authentication can be enabled with the following values on grafana.ini ## NOTE: Grafana will fail to start if the value for ldap.toml is invalid # auth.ldap: # enabled: true # allow_sign_up: true # config_file: /etc/grafana/ldap.toml ## Grafana's LDAP configuration ## Templated by the template in _helpers.tpl ## NOTE: To enable the grafana.ini must be configured with auth.ldap.enabled ## ref: http://docs.grafana.org/installation/configuration/#auth-ldap ## ref: http://docs.grafana.org/installation/ldap/#configuration ldap: # `existingSecret` is a reference to an existing secret containing the ldap configuration # for Grafana in a key `ldap-toml`. existingSecret: "" # `config` is the content of `ldap.toml` that will be stored in the created secret config: "" # config: |- # verbose_logging = true # [[servers]] # host = "my-ldap-server" # port = 636 # use_ssl = true # start_tls = false # ssl_skip_verify = false # bind_dn = "uid=%s,ou=users,dc=myorg,dc=com" ## Grafana's SMTP configuration ## NOTE: To enable, grafana.ini must be configured with smtp.enabled ## ref: http://docs.grafana.org/installation/configuration/#smtp smtp: # `existingSecret` is a reference to an existing secret containing the smtp configuration # for Grafana in keys `user` and `password`. existingSecret: "" ## Sidecars that collect the configmaps with specified label and stores the included files them into the respective folders ## Requires at least Grafana 5 to work and can't be used together with parameters dashboardProviders, datasources and dashboards sidecar: image: kiwigrid/k8s-sidecar:0.0.6 imagePullPolicy: IfNotPresent resources: # limits: # cpu: 100m # memory: 100Mi # requests: # cpu: 50m # memory: 50Mi dashboards: enabled: false # label that the configmaps with dashboards are marked with label: grafana_dashboard # folder in the pod that should hold the collected dashboards folder: /tmp/dashboards # If specified, the sidecar will search for dashboard config-maps inside this namespace. # Otherwise the namespace in which the sidecar is running will be used. # It's also possible to specify ALL to search in all namespaces searchNamespace: null datasources: enabled: false # label that the configmaps with datasources are marked with label: grafana_datasource # If specified, the sidecar will search for datasource config-maps inside this namespace. # Otherwise the namespace in which the sidecar is running will be used. # It's also possible to specify ALL to search in all namespaces searchNamespace: null </code></pre>
<p>I dont know specifically how to solve it for when exposing grafana using NodePort, but my experience below might help point you to a solution, where i have used Istio. You can also replicate the same using a regular nginx kubernetes ingress as well.</p> <p>I had a similar issue with exposing grafana under a subpath in kubernetes. I was trying to expose the services via an Istio VirtualService. My Istio config is below</p> <pre><code>apiVersion: networking.istio.io/v1alpha3 kind: VirtualService metadata: name: prometheus-vs spec: hosts: - "my.cluster.fqdn" gateways: - prometheus-gateway http: - match: - uri: prefix: "/monitoring/grafana" route: - destination: port: number: 80 host: prometheus-operator-grafana </code></pre> <p>And this is the snippet from my values.yml</p> <pre><code> grafana.ini: paths: data: /var/lib/grafana/data logs: /var/log/grafana plugins: /var/lib/grafana/plugins provisioning: /etc/grafana/provisioning analytics: check_for_updates: true log: mode: console grafana_net: url: https://grafana.net server: domain: my.cluster.fqdn root_url: "http://my.cluster.fqdn/monitoring/grafana" </code></pre> <p><strong>I stumbled upon <a href="https://github.com/istio/istio/issues/585" rel="nofollow noreferrer">https://github.com/istio/istio/issues/585</a>, which in summary mentions that we need to rewrite the path, before grafana sees it. It also shows an example of an Ingress config, which does a rewrite</strong> </p> <p>In my case i modified my Istio Virtual Service to </p> <pre><code>kind: VirtualService metadata: name: prometheus-vs spec: hosts: - "my.cluster.fqdn" gateways: - prometheus-gateway http: - match: - uri: prefix: "/monitoring/grafana/" rewrite: uri: / route: - destination: port: number: 80 host: prometheus-operator-grafana </code></pre> <p>and that made it work!</p>
<p>We re trying to eliminate Datadog agents from our infrastructure. I am trying to find a solution to forward the containers standard output logs to be visualised on datadog but without the agents and without changing the dockerfiles because there are hundreds of them.</p> <p>I was thinking about trying to centralize the logs with rsyslog but I dont know if its a good idea. Any suggestions ?</p>
<p><a href="https://docs.datadoghq.com/integrations/#cat-log-collection" rel="nofollow noreferrer">This doc will show you a comprehensive list</a> of all integrations that involve log collection. Some of these include other common log shippers, which can also be used to forward logs to Datadog. Among these you'd find...</p> <ul> <li><a href="https://docs.datadoghq.com/integrations/fluentd/#log-collection" rel="nofollow noreferrer">Fluentd</a></li> <li><a href="https://docs.datadoghq.com/integrations/logstash/#log-collection" rel="nofollow noreferrer">Logstash</a></li> <li><a href="https://docs.datadoghq.com/integrations/rsyslog/?tab=datadogussite" rel="nofollow noreferrer">Rsyslog</a> (for linux)</li> <li><a href="https://docs.datadoghq.com/integrations/syslog_ng/?tab=datadogussite" rel="nofollow noreferrer">Syslog-ng</a> (for linux, windows)</li> <li><a href="https://docs.datadoghq.com/integrations/nxlog/?tab=datadogussite" rel="nofollow noreferrer">nxlog</a> (for windows)</li> </ul> <p>That said, you <a href="https://docs.datadoghq.com/agent/faq/the-datadog-agent-for-logs-or-traces-only/?tab=logs" rel="nofollow noreferrer">can still just use the Datadog agent to collect logs only</a> (they want you to collect everything with their agent, that's why they warn you against collecting just their logs).</p> <p>If you want to collect logs from docker containers, the Datadog agent is an easy way to do that, and it has the benefit of adding lots of relevant docker-metadata as tags to your logs. (<a href="https://docs.datadoghq.com/logs/log_collection/docker/?tab=containerinstallation" rel="nofollow noreferrer">Docker log collection instructions here</a>.)</p> <p>If you don't want to do that, I'd look at Fluentd first on the list above -- it has a good reputation for containerized log collection, promotes JSON log formatting (for easier processing), and scales reasonably well. </p>
<p><strong>step 1</strong> <code>sudo $(aws ecr get-login --no-include-email --region xx-xxxx-x)</code></p> <p><strong>step 2</strong> <code>curl -LSs https://github.com/fermayo/ecr-k8s-secret/raw/master/gen-secret.sh | bash -</code></p> <p><strong>step 3</strong> <code>kubectl describe secret aws-ecr-credentials</code></p> <pre><code>Name: aws-ecr-credentials Namespace: default Labels: &lt;none&gt; Annotations: &lt;none&gt; Type: kubernetes.io/dockerconfigjson Data .dockerconfigjson: 32 bytes </code></pre> <p><strong>step 4</strong> <code>kubectl describe pod x</code></p> <blockquote> <p>Warning Failed 5s kubelet, ip-10-46-250-151 Failed to pull image "my-account.dkr.ecr.us-east-1.amazonaws.com/my-image:latest": rpc error: code = Unknown desc = Error response from daemon: Get <a href="https://my-account.dkr.ecr.us-east-1.amazonaws.com/my-image/latest" rel="noreferrer">https://my-account.dkr.ecr.us-east-1.amazonaws.com/my-image/latest</a>: no basic auth credentials</p> </blockquote> <p>Why can't the pod pull down the image?</p>
<p>Created a script that pulls the token from AWS-ECR</p> <pre class="lang-sh prettyprint-override"><code>ACCOUNT=xxxxxxxxxxxx REGION=xx-xxxx-x SECRET_NAME=${REGION}-ecr-registry EMAIL=email@email.com # # TOKEN=`aws ecr --region=$REGION get-authorization-token --output text \ --query authorizationData[].authorizationToken | base64 -d | cut -d: -f2` # # Create or replace registry secret # kubectl delete secret --ignore-not-found $SECRET_NAME kubectl create secret docker-registry $SECRET_NAME \ --docker-server=https://${ACCOUNT}.dkr.ecr.${REGION}.amazonaws.com \ --docker-username=AWS \ --docker-password="${TOKEN}" \ --docker-email="${EMAIL}" </code></pre> <p>and created a Linux cronjob to run this every 10 hours</p>
<p>I have already added a Kubernetes cluster to my project in Gitlab. The cluster is hosted on AWS. This configuration works fine and I am able to deploy my apps. I want to add another Kubernetes cluster that is also hosted on AWS but in a different region to the same project. So far I am unable to find a way to add another cluster to the same project. Gitlab doesn't give me the option to add another cluster. Is it possible? And if it is possible how should I do it ?</p>
<p>Yes, it's possible, but only in Gitlab Enterprise Edition. <a href="https://docs.gitlab.com/ee/user/project/clusters/#multiple-kubernetes-clusters-premium" rel="nofollow noreferrer">Support for multiple Kubernetes clusters</a> was introduced in <a href="https://about.gitlab.com/pricing/self-managed/feature-comparison/" rel="nofollow noreferrer">Gitlab Premium/Ultimate</a> 10.3. </p> <blockquote> <p>With GitLab Premium, you can associate more than one Kubernetes clusters to your project. That way you can have different clusters for different environments, like dev, staging, production, etc.</p> <p>Simply add another cluster, like you did the first time, and make sure to set an environment scope that will differentiate the new cluster with the rest.</p> </blockquote>
<p>I am using Google Kubernetes Engine and have the Google HTTPS Load Balancer as my ingress.</p> <p>Right now the load balancer uses Let's Encrypt certificates. However, is there a simple way to ensure that the certificates are automatically renewed prior to their 90 day expiry?</p>
<p>You can now use "Google-managed SSL certificates" which is currently in beta: <a href="https://cloud.google.com/load-balancing/docs/ssl-certificates#managed-certs" rel="nofollow noreferrer">https://cloud.google.com/load-balancing/docs/ssl-certificates#managed-certs</a></p>
<p>We have been testing out the Google Healthcare API specifically with HL7 and as I've run through the tutorials I've hit a roadblock. I should mention that I have a fair bit of experience with Kubernetes and AWS, but not so much Google Cloud.</p> <p>This step here is what is giving me trouble:</p> <p><a href="https://cloud.google.com/healthcare/docs/how-tos/mllp-adapter#creating_a_compute_engine_vm_and_sending_messages" rel="nofollow noreferrer">https://cloud.google.com/healthcare/docs/how-tos/mllp-adapter#creating_a_compute_engine_vm_and_sending_messages</a></p> <p>When I attempt to send the message from the VM I do not see a response, and the logs in the pod show me the following error:</p> <pre><code>I0411 17:27:33.756432 1 healthapiclient.go:163] Dialing connection to https://healthcare.googleapis.com:443/v1beta1 I0411 17:27:58.809932 1 mllpreceiver.go:107] Accepted connection from 10.128.0.5:58698 I0411 17:27:58.810140 1 healthapiclient.go:182] Sending message of size 319. E0411 17:27:58.880369 1 mllpreceiver.go:118] handleMessage: Send: request failed: 400 { "error": { "code": 400, "message": "location ID invalid, expected us-central1", "status": "INVALID_ARGUMENT" } } I0411 17:27:58.880691 1 mllpreceiver.go:119] Closed connection from 10.128.0.5:58698 </code></pre> <p>This error is perplexing because the GKE cluster and the VM are in the same region/zone. Has anyone experienced a similar issue with the MLLP adapter and GKE?</p>
<p>It seems like the location id parameter in the path for the HL7v2 store (in yaml, <code>hl7_v2_location_id</code>) might be missing or incorrect; the error looks like it's being raised from the MLLP adapter's request to Cloud Healthcare API, rather than anything particular to GKE. </p>
<p>I have Cloudflare DNS for manage my domain. I created an A-record *.play.mydomain.com in Cloudflare.</p> <p>In Kubernetes (GKE) I created Issuer </p> <pre><code>apiVersion: certmanager.k8s.io/v1alpha1 kind: Issuer metadata: name: letsencrypt-prod-wildcard namespace: default spec: acme: server: https://acme-staging-v02.api.letsencrypt.org/directory #server: https://acme-v02.api.letsencrypt.org/directory email: myemain@gmail.com # Name of a secret used to store the ACME account private key privateKeySecretRef: name: letsencrypt-prod-wildcard # ACME DNS-01 provider configurations dns01: challenges providers: - name: cf-dns cloudflare: email: myimail@gmail.com # A secretKeyRef to a cloudflare api key apiKeySecretRef: name: cloudflare-api-key key: api-key.txt </code></pre> <p>And I created secrets for cloudflare (cloudflare-api-key)</p> <p>Also I created wildcard-certificate:</p> <pre><code>apiVersion: certmanager.k8s.io/v1alpha1 kind: Certificate metadata: name: wildcard-mydomain-com namespace: default spec: secretName: wildcard-mydomain-com issuerRef: #name: letsencrypt-staging-wildcard name: letsencrypt-prod-wildcard commonName: '*.play.mydomain.com' dnsNames: - play.mydomain.com acme: config: - dns01: provider: cf-dns domains: - '*.play.mydomain.com' - play.mydomain.com </code></pre> <p>Certificate generated successfully. </p> <pre><code>Status: Conditions: Last Transition Time: 2019-04-13T00:49:00Z Message: Certificate is up to date and has not expired Reason: Ready Status: True Type: Ready Not After: 2019-07-11T23:48:57Z Events: Type Reason Age From Message ---- ------ ---- ---- ------- Normal Generated 4m5s cert-manager Generated new private key Normal GenerateSelfSigned 4m5s cert-manager Generated temporary self signed certificate Normal OrderCreated 4m5s cert-manager Created Order resource "wildcard-mydomain-com-880037411" Normal OrderComplete 84s cert-manager Order "wildcard-mydomain-com-880037411" completed successfully Normal CertIssued 84s cert-manager Certificate issued successfully </code></pre> <p>But in logs cert-manager I see an error:</p> <pre><code>2019-04-13 04:49:00.078 GET orders controller: Re-queuing item "default/wildcard-mydomain-com-880037411" due to error processing: challenges.certmanager.k8s.io "wildcard-mydomain-com-880037411-1" not found </code></pre> <p>Also I have an ingress:</p> <pre><code>apiVersion: extensions/v1beta1 kind: Ingress metadata: name: ingress-mydomain-com annotations: kubernetes.io/ingress.class: nginx certmanager.k8s.io/issuer: letsencrypt-prod-wildcard certmanager.k8s.io/acme-challenge-type: "dns01" kubernetes.io/tls-acme: "true" spec: tls: - secretName: letsencrypt-prod-secret-playground hosts: - '*.play.mydomain.com' rules: - host: '*.play.mydomain.com' http: paths: - backend: serviceName: playground servicePort: 83 </code></pre> <p>And an error in logs (after run ingress):</p> <pre><code>2019-04-13 04:51:17.225 GET orders controller: Re-queuing item "default/letsencrypt-prod-secret-playground-2579012660" due to error processing: Error constructing Challenge resource for Authorization: ACME server does not allow selected challenge type or no provider is configured for domain "play.mydomain.com" </code></pre> <p>How I can use wildcard certificates Let's Encrypt with cert-manager, nginx ingress, cloudflare in kubernetes?</p> <p>I'd like to have ingress and launch many subdomains ([randomstring].play.mydomain.com). </p>
<p>It looks mostly correct a couple of issues I see</p> <ol> <li><p><code>challenges</code> keyword seems out of place in the <code>Issuer</code>. Maybe it was on purpose to explain(?)</p> <pre><code># ACME DNS-01 provider configurations dns01: providers: - name: cf-dns cloudflare: email: myimail@gmail.com # A secretKeyRef to a cloudflare api key apiKeySecretRef: name: cloudflare-api-key key: api-key.txt </code></pre></li> <li><p>Missing <code>kind: Issuer</code> line within the <code>issuerRef</code> in your <code>Certificate</code> definition and <code>dnsNames</code> shows <code>play.mydomain.com</code> instead of <code>*.play.mydomain.com</code> (which could be the problem)</p> <pre><code>apiVersion: certmanager.k8s.io/v1alpha1 kind: Certificate metadata: name: wildcard-mydomain-com namespace: default spec: secretName: wildcard-mydomain-com issuerRef: name: letsencrypt-prod-wildcard kind: Issuer commonName: '*.play.mydomain.com' dnsNames: - *.play.mydomain.com &lt;== here acme: config: - dns01: provider: cf-dns domains: - '*.play.mydomain.com' - play.mydomain.com </code></pre></li> </ol>
<p>Is there a way with kubectl to find out which clusterroles or roles are bound to the service account?</p>
<p>You could do something like:</p> <pre><code>kubectl get rolebindings,clusterrolebindings \ --all-namespaces \ -o custom-columns='KIND:kind,NAMESPACE:metadata.namespace,NAME:metadata.name,SERVICE_ACCOUNTS:subjects[?(@.kind=="ServiceAccount")].name' | grep "&lt;SERVICE_ACCOUNT_NAME&gt;" </code></pre> <p>Replace the grep with then name of the service account you are looking for.</p>
<p>I want to setup Elasticsearch on Kubernetes Cluster using Helm. I can setup Elasticsearch on Kubernetes Cluster without persistence. I am using below helm chart. </p> <pre><code>helm install --name elasticsearch incubator/elasticsearch \ --set master.persistence.enabled=false \ --set data.persistence.enabled=false \ --set image.tag=6.4.2 \ --namespace logging </code></pre> <p>However, i am not able to use it with Persistence. Moreover i am confused as i am using neither cloud based storage(aws,gce) nor nfs. I am using Local VM storage. I added disk in my VM environment formated it under ext4. And now i am trying to use it as a persistent disk for my elasticsearch Deployment. </p> <p>I tried lots of ways, not working much. For any data if you need i would be helpful to provide. But kindly get a solution which will work.</p> <p>I just need help..</p>
<p>I don't believe this chart will support local storage. </p> <p>Looking at the volumeClaimTemplate <a href="https://github.com/helm/charts/blob/4bde54c86c3d3c1be56e428d810b93431b122e2d/incubator/elasticsearch/templates/master-statefulset.yaml#L182" rel="nofollow noreferrer">such as on the master-statefulset.yaml</a> shows that it's missing key parameters for a local volume setup (such as path, nodeAffinity, volumeBindingMode) described <a href="https://kubernetes.io/docs/concepts/storage/volumes/#local" rel="nofollow noreferrer">here</a>. If you are using a cloud deployment, just use a cloud volume claim. If you have deployed a cluster on a on-prem or just onto your computer, then you should fork the chart and adjust the volume claims to meet the requirements for local storage.</p> <p>Either way on your future posts you should include relevant logs. With kubernetes errors it's helpful to see from all parts of the stack such as: kubernetes control plane logs, object events (like the output from describing the volume claim), helm logs, elasticsearch pod logs failing to discover a volume, etc etc. </p>
<p>We are using knative to serve a nodejs app (with express) that would execute workflows and return back the results of execution. The app would have to execute workflows which could take minutes (if not hours) to finish executing. </p> <p>After invoking the app, execution stops after a certain time (approximately 14min) with the status: <code>upstream request timeout</code></p> <p>We modified the timeout accordingly for express and it seemed to have a slight effect, but not as much as needed. We used the following guide as baseline <a href="https://github.com/knative/docs/tree/master/docs/serving/samples/hello-world/helloworld-nodejs" rel="nofollow noreferrer">https://github.com/knative/docs/tree/master/docs/serving/samples/hello-world/helloworld-nodejs</a></p> <p>Is there a config value that can be modified that would increase the execution of the app itself (perhaps a timeout value)?</p>
<p><strong>UPDATED (25/6/19):</strong></p> <p>As per <a href="https://github.com/knative/serving/pull/4196" rel="nofollow noreferrer">https://github.com/knative/serving/pull/4196</a>, in Knative v0.7, you can now specify <code>MaxRevisionTimeoutSeconds</code> which can be any integer. <code>timeoutSeconds</code> must be less than or equal to <code>MaxRevisionTimeoutSeconds</code>. <code>timeoutSeconds</code> defaults to <code>300</code>.</p> <p><strong><em>OLD</strong>: You can change <code>timeoutSeconds</code> (which I believe defaults to 300 seconds):</em></p> <pre><code>apiVersion: serving.knative.dev/v1alpha1 kind: Service metadata: name: my-app namespace: default spec: runLatest: configuration: revisionTemplate: spec: timeoutSeconds: 300 ... </code></pre>
<p>I am trying to deploy a private docker registry on Kubernetes using the official Docker image for the registry. However, I am getting some warnings on the deployment and also I am not able to access it in the pod.</p> <p>The output from the registry container:</p> <pre><code>time="2019-04-12T18:40:21Z" level=warning msg="Ignoring unrecognized environment variable REGISTRY_PORT" time="2019-04-12T18:40:21Z" level=warning msg="Ignoring unrecognized environment variable REGISTRY_PORT_5000_TCP" time="2019-04-12T18:40:21Z" level=warning msg="Ignoring unrecognized environment variable REGISTRY_PORT_5000_TCP_ADDR" time="2019-04-12T18:40:21Z" level=warning msg="Ignoring unrecognized environment variable REGISTRY_PORT_5000_TCP_PORT" time="2019-04-12T18:40:21Z" level=warning msg="Ignoring unrecognized environment variable REGISTRY_PORT_5000_TCP_PROTO" time="2019-04-12T18:40:21Z" level=warning msg="Ignoring unrecognized environment variable REGISTRY_SERVICE_HOST" time="2019-04-12T18:40:21Z" level=warning msg="Ignoring unrecognized environment variable REGISTRY_SERVICE_PORT" time="2019-04-12T18:40:21.145278902Z" level=warning msg="No HTTP secret provided - generated random secret. This may cause problems with uploads if multiple registries are behind a load-balancer. To provide a shared secret, fill in http.secret in the configuration file or set the REGISTRY_HTTP_SECRET environment variable." go.version=go1.11.2 instance.id=988660e4-d4b9-4d21-a42e-c60c82d00a73 service=registry version=v2.7.1 time="2019-04-12T18:40:21.145343563Z" level=info msg="redis not configured" go.version=go1.11.2 instance.id=988660e4-d4b9-4d21-a42e-c60c82d00a73 service=registry version=v2.7.1 time="2019-04-12T18:40:21.149771291Z" level=info msg="Starting upload purge in 2m0s" go.version=go1.11.2 instance.id=988660e4-d4b9-4d21-a42e-c60c82d00a73 service=registry version=v2.7.1 time="2019-04-12T18:40:21.163063574Z" level=info msg="using inmemory blob descriptor cache" go.version=go1.11.2 instance.id=988660e4-d4b9-4d21-a42e-c60c82d00a73 service=registry version=v2.7.1 time="2019-04-12T18:40:21.163689856Z" level=info msg="listening on [::]:5000" go.version=go1.11.2 instance.id=988660e4-d4b9-4d21-a42e-c60c82d00a73 service=registry version=v2.7.1 </code></pre> <p>The yaml files for the deployment on Kubernetes:</p> <pre><code>104 apiVersion: extensions/v1beta1 105 kind: Deployment 106 metadata: 107 name: registry 108 namespace: docker 109 spec: 110 replicas: 1 111 template: 112 metadata: 113 labels: 114 name: registry 115 spec: 116 containers: 117 - resources: 118 name: registry 119 image: registry:2 120 ports: 121 - containerPort: 5000 122 volumeMounts: 123 - mountPath: /var/lib/registry 124 name: images 140 volumes: 141 - name: images 142 hostPath: 143 path: /mnt/nfs/docker-local-registry/images 150 nodeSelector: 151 name: master 152 --- 153 apiVersion: v1 154 kind: Service 155 metadata: 156 name: registry 157 namespace: docker 158 spec: 159 ports: 160 - port: 5000 161 targetPort: 5000 162 selector: 163 name: registry </code></pre> <p>Even if I ignore those warnings, accessing the registry in pod level with <code>registry.docker:5000/image_name</code> and <code>registry.docker.svc.cluster.local/image_name</code> won't work because the host cannot be resolved. I don't want the registry exposed. All that I want is to be able pods to pull the images from there.</p>
<p>Not sure, I understand your use case completely, but if you want to start a pod that is based on an image served from the internal registry, it is important to understand that not the pod but the dockerd on the cluster node is pulling the image. The internal DNS names like *svc.cluster.local cannot be resolved there. At least in many K8s environments this is the case. Some people were discussing this here: <a href="https://github.com/knative/serving/issues/1996" rel="nofollow noreferrer">https://github.com/knative/serving/issues/1996</a> It might help, if you post which Kubernetes provider (GKE, EKS etc.) you are using. The solution is to configure the cluster nodes to resolve these names, or to expose your registry externally using an ingress.</p>
<p>I have node on google kubernetes engine using persistent volume. Is possible edit files on this volume from gcloud, or google cloud shell? For example edit config and recreate node? Or it is only posiible from running pod using kubectl exec?</p>
<p>The volume would be a block device, so I’d expect it’d not be possible to edit it outside of the pod it’s attached to. So yes, expecting into the pod would do it, but you could also just use <code>kubectl cp</code> to copy files (and directories!) directly from your local machine onto the volume, mounted to the pod. </p> <p>Here’s the relevant doc:</p> <p><a href="https://kubernetes.io/docs/reference/generated/kubectl/kubectl-commands#cp" rel="nofollow noreferrer">https://kubernetes.io/docs/reference/generated/kubectl/kubectl-commands#cp</a></p>
<p>I have a kubernetes cluster on bare metal with NodePort Service and 2 HAProxies balances traffic to these nodes. when I send a request to one of these nodes, it balances traffic to other nodes in cluster. is it possible to change this behavior? I don't want to re-balance traffic.</p> <p><strong>Update:</strong> we can use externalTrafficPolicy: Local </p> <pre><code>spec: selector: app: nginx type: NodePort externalTrafficPolicy: Local </code></pre>
<p>Nodeport traffic will be intercepted by kube-proxy and then it will redirect the traffic to the node which contains the Pod in a random manner. It's advisable to use Loadbalancer service instead of nodePort. This applies if you are using userspace and iptables modes</p> <p>You may use <a href="https://kubernetes.io/blog/2018/07/09/ipvs-based-in-cluster-load-balancing-deep-dive/" rel="nofollow noreferrer">IPVS</a> to change the behavior </p>
<p>I've developed a gRPC service that is deployed on a Kubernetes cluster, and I'm using grpc-web from nodejs clients to connect to it. This means I need a proxy in front of the service. Everything works perfectly with <a href="https://gist.github.com/diericx/9001115a3ecf084493b520b6c17655d7" rel="nofollow noreferrer">this envoy configuration</a> without SSL, but now I need to secure the connections to get it ready for production. </p> <p><strong>Here are the steps I've gone through</strong> </p> <p>1) Generated the keys, entering my domain <code>simulation.terrarium.ai</code> when asked using <a href="https://gist.github.com/fntlnz/cf14feb5a46b2eda428e000157447309" rel="nofollow noreferrer">this tutorial</a></p> <p>2) Edit the Dockerfile to add the keys</p> <pre><code>FROM envoyproxy/envoy:latest COPY envoy-proxy-tls.yaml /etc/envoy.yaml EXPOSE 9091 ADD ./certs/simulation.terrarium.ai.crt /etc/simulation.terrarium.ai.crt ADD ./certs/simulation.terrarium.ai.key /etc/simulation.terrarium.ai.key ADD ./certs/rootCA.crt /etc/rootCA.crt WORKDIR /etc/envoy CMD /usr/local/bin/envoy -c /etc/envoy.yaml </code></pre> <p>3) Updated the envoy config to use tls on the port</p> <p><a href="https://gist.github.com/diericx/cc0398c0a3bb143523960221f9a3058f" rel="nofollow noreferrer">It's much easier to read this config file with highlighting so here is a gist of it.</a></p> <p><strong>What's Happening</strong><br> I make calls to my service like this</p> <pre><code>var simService = new SimulationServiceClient(ServerAddress, null, null); var request = new CreateSpectatorRequest(); request.setApi(API_VERSION); request.setId(this.clientId); var metadata = {}; var stream = simService.createSpectator(request, metadata); stream.on("data", this.onData); stream.on("status", this.onStatus); stream.on("end", this.onEnd); </code></pre> <p>At this point I have my grpc service and the envoy proxy running in a kubernetes cluster, the same way I did before adding TLS. When I try to connect from my browser I get this error:</p> <pre><code>https://simulation.terrarium.ai:9091/v1.SimulationService/SubscribeSpectatorToRegion net::ERR_CERT_AUTHORITY_INVALID </code></pre> <p>I'm having a really hard time debugging this as I'm not sure exactly where the error could be occurring. Any help would be appreciated!</p>
<p>I'm using GKE and just found this link that shows <a href="https://cloud.google.com/kubernetes-engine/docs/how-to/managed-certs" rel="nofollow noreferrer">how to use a Google Managed SSL Certificate</a>. </p> <p>It works perfectly for me! Sorry I couldn't solve this issue exactly but this is a way easier alternative as they also handle automation for the certificates.</p>
<p><strong>The issue:</strong></p> <p>Locally, I use Skaffold (Kubernetes) to hot reload both the client side and server side of my code. When I shut it down, it deletes my server pod, including my /migrations/ folder and thus gets out of sync with my database alembic_version. On production, I'm not deleting my server pod, but I am rebuilding the docker image when I deploy which results in my /migrations/ folder being replaced. </p> <p><strong>The question</strong></p> <p>How do I handle these migrations so my database doesn't get out of sync?</p> <hr> <p><strong>application setup</strong></p> <p>Flask/Python API and use Flask Migrate. For those unfamiliar, what it does is create a migrations folder with version files like <code>5a7b1a44a69a_.py</code>. Inside of that file are <code>def upgrade()</code> and <code>downgrade()</code> to manipulate the db. It also records the revision and down_revision references for the alembic_version table in my postgres pod.</p> <p><strong>Kubernetes and Docker setup</strong></p> <p>I have a server pod and postgres pod. I login to the shell of the server pod to run the migrate commands. It creates the version files inside of the docker container and updates the db.</p> <p>To show a step-by-step example of the problem:</p> <ol> <li>sh into server-deployment pod and run db init.</li> <li>Migrations folder is created.</li> <li>perform migration on server-deployment which creates migration file and updates the db.</li> <li>postgres pod db gets alembic_version entered and an update.</li> <li>use skaffold delete or ctrl-c skaffold.</li> <li>server-deployment pod gets deleted, but postgres doesn't. Migrations folder goes away.</li> <li>Start back up skaffold and sh into server-deployment pod and try to run db migrate. Asks you to do an db init.</li> <li>If you try to downgrade from here, it doesn't do anything. Now server pod and postgres pod are out of sync in terms of alembic_version.</li> </ol> <p><strong>Final Notes</strong></p> <p>What I used to do pre-docker/kubernetes was run it locally and I would commit that migrations version file to my repo. It was synced across all environments so everyone's repo was on the same alembic_version. I've considered created a separate, always-on "migrations-deployment" pod that is another instance of flask so that it never loses the /migrations/ folder. However, that seems like a really poor solution.</p> <hr> <p>Hoping for best practices or ideas!</p>
<p>I figured out a way to handle this. I'm not going to set it as the correct answer until someone else confirms if this is a good approach.</p> <p>Basically, what I did was create a Persistent Volume Claim. Inside the server-deployment I hook up the migrations/ folder to that Persistent Volume. That way, whenever the pod gets deleted, the migrations/ folder remains and gets persisted across pod restarts. </p> <p>It would look something like this inside the server deployment.</p> <pre><code> containers: .......... volumeMounts: - name: migrationstuff mountPath: 'MyServerApplicationDirectory/migrations' volumes: - name: migrationstuff persistentVolumeClaim: claimName: migrate-pvc </code></pre> <p>The PVC would look like this:</p> <pre><code>apiVersion: v1 kind: PersistentVolumeClaim metadata: name: migrate-pvc spec: accessModes: - ReadWriteOnce resources: requests: storage: 1Gi </code></pre> <p>For those who decide to take this approach with flask migrate, there's a tricky "chicken or the egg" issue. When you run flask db init, it creates the migrations/ folder with some stuff in it. However, if there's a PVC creating the empty migrations/ folder, flask migrate already thinks the folder exists. You can't delete the folder either with rmdir because it's got a working process on it. However, you need to get the contents of the flask migrate init command into the empty migrations/ folder.....</p> <p>The trick I found was:</p> <pre><code>python flask db init --directory migration mv migration/* migrations/ </code></pre> <p>This intialized all the files you need into a new "migration" folder. You then copy it all into the migrations/ folder to persist from then on. Flask migrate automatically looks for that folder if you leave out the --directory flag. </p> <p>Then delete the migration folder <code>rmdir migration</code>(or just wait until your pod restarts in which case it'll disappear anyways).</p> <p>You now have a proper migrations/ folder with everything in it. When you close your flask pod and restarted, the PVC injects that filled up migrations/ folder back into the pod. I can now upgrade/downgrade. Just have to be careful not to delete the pvc!</p>
<p>I have a deployment up and running. Here is its export:</p> <pre><code>apiVersion: v1items: - apiVersion: extensions/v1beta1 kind: Deployment metadata: annotations: deployment.kubernetes.io/revision: "2" kubectl.kubernetes.io/last-applied-configuration: | {"apiVersion":"extensions/v1beta1","kind":"Deployment","metadata":{"annotations":{"deployment.kubernetes.io/revision":"1"},"creationTimestamp":"2019-04-14T15:32:12Z","generation":1,"name":"frontend","namespace":"default","resourceVersion":"3138","selfLink":"/apis/extensions/v1beta1/namespaces/default/deployments/frontend","uid":"796046e1-5eca-11e9-a16c-0242ac110033"},"spec":{"minReadySeconds":20,"progressDeadlineSeconds":600,"replicas":4,"revisionHistoryLimit":10,"selector":{"matchLabels":{"name":"webapp"}},"strategy":{"rollingUpdate":{"maxSurge":"25%","maxUnavailable":"25%"},"type":"RollingUpdate"},"template":{"metadata":{"creationTimestamp":null,"labels":{"name":"webapp"}},"spec":{"containers":[{"image":"kodekloud/webapp-color:v2","imagePullPolicy":"IfNotPresent","name":"simple-webapp","ports":[{"containerPort":8080,"protocol":"TCP"}],"resources":{},"terminationMessagePath":"/dev/termination-log","terminationMessagePolicy":"File"}],"dnsPolicy":"ClusterFirst","restartPolicy":"Always","schedulerName":"default-scheduler","securityContext":{},"terminationGracePeriodSeconds":30}}},"status":{"availableReplicas":4,"conditions":[{"lastTransitionTime":"2019-04-14T15:33:00Z","lastUpdateTime":"2019-04-14T15:33:00Z","message":"Deployment has minimum availability.","reason":"MinimumReplicasAvailable","status":"True","type":"Available"},{"lastTransitionTime":"2019-04-14T15:32:12Z","lastUpdateTime":"2019-04-14T15:33:00Z","message":"ReplicaSet \"frontend-7965b86db7\" has successfully progressed.","reason":"NewReplicaSetAvailable","status":"True","type":"Progressing"}],"observedGeneration":1,"readyReplicas":4,"replicas":4,"updatedReplicas":4}} creationTimestamp: 2019-04-14T15:32:12Z generation: 2 labels: name: webapp name: frontend namespace: default resourceVersion: "3653" selfLink: /apis/extensions/v1beta1/namespaces/default/deployments/frontend uid: 796046e1-5eca-11e9-a16c-0242ac110033 spec: minReadySeconds: 20 progressDeadlineSeconds: 600 replicas: 4 revisionHistoryLimit: 10 selector: matchLabels: name: webapp strategy: rollingUpdate: maxSurge: 25% maxUnavailable: 25% type: RollingUpdate template: metadata: creationTimestamp: null labels: name: webapp spec: containers: - image: kodekloud/webapp-color:v2 imagePullPolicy: IfNotPresent name: simple-webapp ports: - containerPort: 8080 protocol: TCP resources: {} terminationMessagePath: /dev/termination-log terminationMessagePolicy: File dnsPolicy: ClusterFirst restartPolicy: Always schedulerName: default-scheduler securityContext: {} terminationGracePeriodSeconds: 30 status: availableReplicas: 4 conditions: - lastTransitionTime: 2019-04-14T15:33:00Z lastUpdateTime: 2019-04-14T15:33:00Z message: Deployment has minimum availability. reason: MinimumReplicasAvailable status: "True" type: Available - lastTransitionTime: 2019-04-14T15:32:12Z lastUpdateTime: 2019-04-14T15:38:01Z message: ReplicaSet "frontend-65998dcfd8" has successfully progressed. reason: NewReplicaSetAvailable status: "True" type: Progressing observedGeneration: 2 readyReplicas: 4 replicas: 4 updatedReplicas: 4 kind: List metadata: resourceVersion: " </code></pre> <p>I am editing the <code>metadata.strategy.type</code> from <code>RollingUpdate</code> to <code>Recreate</code>.</p> <p>However, running <code>kubectl apply -f frontend.yml</code> yields the following error:</p> <p>Why is that?</p> <pre><code>Error from server (Conflict): error when applying patch: {"metadata":{"annotations":{"deployment.kubernetes.io/revision":"1","kubectl.kubernetes.io/last-applied-configuration":"{\"apiVersion\":\"extensions/v1beta1\",\"kind\":\"Deployme nt\",\"metadata\":{\"annotations\":{\"deployment.kubernetes.io/revision\":\"1\"},\"creationTimestamp\":\"2019-04-14T15:32:12Z\",\"generation\":1,\"name\":\"frontend\",\"namespace \":\"default\",\"resourceVersion\":\"3138\",\"selfLink\":\"/apis/extensions/v1beta1/namespaces/default/deployments/frontend\",\"uid\":\"796046e1-5eca-11e9-a16c-0242ac110033\"},\" spec\":{\"minReadySeconds\":20,\"progressDeadlineSeconds\":600,\"replicas\":4,\"revisionHistoryLimit\":10,\"selector\":{\"matchLabels\":{\"name\":\"webapp\"}},\"strategy\":{\"rol lingUpdate\":{\"maxSurge\":\"25%\",\"maxUnavailable\":\"25%\"},\"type\":\"Recreate\"},\"template\":{\"metadata\":{\"creationTimestamp\":null,\"labels\":{\"name\":\"webapp\"}},\"s pec\":{\"containers\":[{\"image\":\"kodekloud/webapp-color:v2\",\"imagePullPolicy\":\"IfNotPresent\",\"name\":\"simple-webapp\",\"ports\":[{\"containerPort\":8080,\"protocol\":\" TCP\"}],\"resources\":{},\"terminationMessagePath\":\"/dev/termination-log\",\"terminationMessagePolicy\":\"File\"}],\"dnsPolicy\":\"ClusterFirst\",\"restartPolicy\":\"Always\",\ "schedulerName\":\"default-scheduler\",\"securityContext\":{},\"terminationGracePeriodSeconds\":30}}},\"status\":{\"availableReplicas\":4,\"conditions\":[{\"lastTransitionTime\": \"2019-04-14T15:33:00Z\",\"lastUpdateTime\":\"2019-04-14T15:33:00Z\",\"message\":\"Deployment has minimum availability.\",\"reason\":\"MinimumReplicasAvailable\",\"status\":\"Tru e\",\"type\":\"Available\"},{\"lastTransitionTime\":\"2019-04-14T15:32:12Z\",\"lastUpdateTime\":\"2019-04-14T15:33:00Z\",\"message\":\"ReplicaSet \\\"frontend-7965b86db7\\\" has successfully progressed.\",\"reason\":\"NewReplicaSetAvailable\",\"status\":\"True\",\"type\":\"Progressing\"}],\"observedGeneration\":1,\"readyReplicas\":4,\"replicas\":4,\"upda tedReplicas\":4}}\n"},"generation":1,"resourceVersion":"3138"},"spec":{"strategy":{"$retainKeys":["rollingUpdate","type"],"type":"Recreate"}},"status":{"$setElementOrder/conditio ns":[{"type":"Available"},{"type":"Progressing"}],"conditions":[{"lastUpdateTime":"2019-04-14T15:33:00Z","message":"ReplicaSet \"frontend-7965b86db7\" has successfully progressed .","type":"Progressing"}],"observedGeneration":1}} to: Resource: "extensions/v1beta1, Resource=deployments", GroupVersionKind: "extensions/v1beta1, Kind=Deployment" Name: "frontend", Namespace: "default" Object: &amp;{map["kind":"Deployment" "apiVersion":"extensions/v1beta1" "metadata":map["annotations":map["kubectl.kubernetes.io/last-applied-configuration":"{\"apiVersion\":\"extensi ons/v1beta1\",\"kind\":\"Deployment\",\"metadata\":{\"annotations\":{\"deployment.kubernetes.io/revision\":\"1\"},\"creationTimestamp\":\"2019-04-14T15:32:12Z\",\"generation\":1, \"name\":\"frontend\",\"namespace\":\"default\",\"resourceVersion\":\"3138\",\"selfLink\":\"/apis/extensions/v1beta1/namespaces/default/deployments/frontend\",\"uid\":\"796046e1- 5eca-11e9-a16c-0242ac110033\"},\"spec\":{\"minReadySeconds\":20,\"progressDeadlineSeconds\":600,\"replicas\":4,\"revisionHistoryLimit\":10,\"selector\":{\"matchLabels\":{\"name\" :\"webapp\"}},\"strategy\":{\"rollingUpdate\":{\"maxSurge\":\"25%\",\"maxUnavailable\":\"25%\"},\"type\":\"RollingUpdate\"},\"template\":{\"metadata\":{\"creationTimestamp\":null ,\"labels\":{\"name\":\"webapp\"}},\"spec\":{\"containers\":[{\"image\":\"kodekloud/webapp-color:v2\",\"imagePullPolicy\":\"IfNotPresent\",\"name\":\"simple-webapp\",\"ports\":[{ \"containerPort\":8080,\"protocol\":\"TCP\"}],\"resources\":{},\"terminationMessagePath\":\"/dev/termination-log\",\"terminationMessagePolicy\":\"File\"}],\"dnsPolicy\":\"Cluster First\",\"restartPolicy\":\"Always\",\"schedulerName\":\"default-scheduler\",\"securityContext\":{},\"terminationGracePeriodSeconds\":30}}},\"status\":{\"availableReplicas\":4,\" conditions\":[{\"lastTransitionTime\":\"2019-04-14T15:33:00Z\",\"lastUpdateTime\":\"2019-04-14T15:33:00Z\",\"message\":\"Deployment has minimum availability.\",\"reason\":\"Minim umReplicasAvailable\",\"status\":\"True\",\"type\":\"Available\"},{\"lastTransitionTime\":\"2019-04-14T15:32:12Z\",\"lastUpdateTime\":\"2019-04-14T15:33:00Z\",\"message\":\"Repli caSet \\\"frontend-7965b86db7\\\" has successfully progressed.\",\"reason\":\"NewReplicaSetAvailable\",\"status\":\"True\",\"type\":\"Progressing\"}],\"observedGeneration\":1,\"readyReplicas\":4,\"replicas\":4,\"updatedReplicas\":4}}\n" "deployment.kubernetes.io/revision":"2"] "name":"frontend" "namespace":"default" "selfLink":"/apis/extensions/v1beta1/namespaces/default/deployments/frontend" "resourceVersion":"3653" "labels":map["name":"webapp"] "uid":"796046e1-5eca-11e9-a16c-0242ac110033" "generation":'\x02' "creationTimestamp":"2019-04-14T15:32:12Z"] "spec":map["selector":map["matchLabels":map["name":"webapp"]] "template":map["metadata":map["creationTimestamp":&lt;nil&gt; "labels":map["name":"webapp"]] "spec":map["dnsPolicy":"ClusterFirst" "securityContext":map[] "schedulerName":"default-scheduler" "containers":[map["terminationMessagePolicy":"File" "imagePullPolicy":"IfNotPresent" "name":"simple-webapp" "image":"kodekloud/webapp-color:v2" "ports":[map["containerPort":'\u1f90' "protocol":"TCP"]] "resources":map[] "terminationMessagePath":"/dev/termination-log"]] "restartPolicy":"Always" "terminationGracePeriodSeconds":'\x1e']] "strategy":map["type":"RollingUpdate" "rollingUpdate":map["maxSurge":"25%" "maxUnavailable":"25%"]] "minReadySeconds":'\x14' "revisionHistoryLimit":'\n' "progressDeadlineSeconds":'\u0258' "replicas":'\x04'] "status":map["observedGeneration":'\x02' "replicas":'\x04' "updatedReplicas":'\x04' "readyReplicas":'\x04' "availableReplicas":'\x04' "conditions":[map["type":"Available" "status":"True" "lastUpdateTime":"2019-04-14T15:33:00Z" "lastTransitionTime":"2019-04-14T15:33:00Z" "reason":"MinimumReplicasAvailable" "message":"Deployment has minimum availability."] map["lastUpdateTime":"2019-04-14T15:38:01Z" "lastTransitionTime":"2019-04-14T15:32:12Z" "reason":"NewReplicaSetAvailable" "message":"ReplicaSet \"frontend-65998dcfd8\" has successfully progressed." "type":"Progressing" "status":"True"]]]]} for: "frontend.yml": Operation cannot be fulfilled on deployments.extensions "frontend": the object has been modified; please apply your changes to the latest version and try again </code></pre>
<p>This is <a href="https://github.com/terraform-providers/terraform-provider-kubernetes/issues/260" rel="nofollow noreferrer">a known issue</a> with the Kubernetes Terraform Provider. It has been present since at least version 0.11.7.</p> <p>The issue has been fixed with the latest version, as a result of <a href="https://github.com/terraform-providers/terraform-provider-kubernetes/pull/372" rel="nofollow noreferrer">this merge request</a>.</p>
<p>I'm trying to upgrade a helm chart,</p> <p>I get the error function "pod" not defined which make sense because I really have no such function.</p> <p>The "pod" is coming from a json file which I convert into a configmap and helm is reading this value as a function and not as a straight string which is part of the json file.</p> <p>This is a snippet of my configmap:</p> <pre><code># Generated from 'pods' from https://raw.githubusercontent.com/coreos/prometheus-operator/master/contrib/kube-prometheus/manifests/grafana-dashboardDefinitions.yaml # Do not change in-place! In order to change this file first read following link: # https://github.com/helm/charts/tree/master/stable/prometheus-operator/hack {{- if and .Values.grafana.enabled .Values.grafana.defaultDashboardsEnabled }} apiVersion: v1 kind: ConfigMap metadata: name: {{ printf "%s-%s" (include "prometheus-operator.fullname" $) "services-health" | trunc 63 | trimSuffix "-" }} labels: {{- if $.Values.grafana.sidecar.dashboards.label }} {{ $.Values.grafana.sidecar.dashboards.label }}: "1" {{- end }} app: {{ template "prometheus-operator.name" $ }}-grafana {{ include "prometheus-operator.labels" $ | indent 4 }} data: services-health.json: |- { "annotations": { "list": [ { "builtIn": 1, "datasource": "-- Grafana --", "enable": true, "hide": true, "iconColor": "rgba(0, 211, 255, 1)", "name": "Annotations &amp; Alerts", "type": "dashboard" } ] }, "targets": [ { "expr": "{__name__=~\"kube_pod_container_status_ready\", container=\"aggregation\",kubernetes_namespace=\"default\",chart=\"\"}", "format": "time_series", "instant": false, "intervalFactor": 2, "legendFormat": "{{pod}}", "refId": "A" } } {{- end }} </code></pre> <p>The error I get is coming from this line: <strong>"legendFormat": "{{pod}}",</strong></p> <p>And this is the error I get:</p> <blockquote> <p>helm upgrade --dry-run prometheus-operator-chart /home/ubuntu/infra-devops/helm/vector-chart/prometheus-operator-chart/ Error: UPGRADE FAILED: parse error in "prometheus-operator/templates/grafana/dashboards/services-health.yaml": template: prometheus-operator/templates/grafana/dashboards/services-health.yaml:1213: function "pod" not defined</p> </blockquote> <p>I tried to escape it but nothing worked. Anyone get idea about how I can work around this issue?</p>
<p>Escaping gotpl placeholders is possible using <a href="https://github.com/helm/helm/issues/2798#issuecomment-467319526" rel="noreferrer">backticks</a>. For example, in your scenario, instead of using <code>{{ pod }}</code> you could write <code>{{` {{ pod }} `}}</code>.</p>
<p>I believe my question is pretty straightforward. I'm doing my prerequisites to install Kubernetes cluster on bare metal.</p> <p>Let's say I have:</p> <p><strong>master</strong> - hostname for Docker DB container which is fixed on first node</p> <p><strong>slave</strong> - hostname for Docker DB container which is fixed on second node</p> <p>Can I communicate with <strong>master</strong> from any container (app, etc.) in a cluster regardless it's running on the same node or not?</p> <p>Is this a default behaviour? Or anything additional should be done?</p> <p>I assume that I need to setup <code>hostname</code> parameter in YAML or JSON file so Kubernetes is aware what the hostname is.</p> <p>Probably this is not the factor, but I plan to use Kubespray installation method so it gets Calico networking for k8s.</p> <p>Many thanks</p>
<p>Yes,</p> <p>You can access and communication from any container in a <code>namespace</code> via hostname.</p> <p>Here is an example about Kubernetes <code>Service</code> configure:</p> <pre><code>--- apiVersion: v1 kind: Service metadata: name: master labels: name: master namespace: smart-office spec: ports: - port: 5672 name: master targetPort: 5672 selector: name: master </code></pre> <p><code>Deployment</code> configure:</p> <pre><code>--- apiVersion: extensions/v1beta1 kind: Deployment metadata: name: master labels: name: master namespace: smart-office spec: replicas: 1 template: metadata: labels: name: master annotations: prometheus.io/scrape: "false" spec: containers: - name: master image: rabbitmq:3.6.8-management ports: - containerPort: 5672 name: master nodeSelector: beta.kubernetes.io/os: linux </code></pre> <p>And from other services, for e.g your <code>slaver</code> <code>.env</code> will be:</p> <pre><code>AMQP_HOST=master &lt;---- The hostname AMQP_PORT=5672 AMQP_USERNAME=guest AMQP_PASSWORD=guest AMQP_HEARTBEAT=60 </code></pre> <p>It's will work inside Cluster even if you not publish External IP.</p> <p>Hope this can help you.</p>
<p>I want to completely purge Minikube so that I could start over as if I installed it for the first time to avoid some configuration clashes. Mailnly to have initial IP 192.168.99.100, unfortunatelly it increases on next <code>minikube start</code> to 192.168.99.101, etc. I've run to delete Minikube:</p> <p><code> minikube delete rm -rf ~/.minikube rm -rf ~/.kube </code></p> <p>I'm running minikube version: v0.31.0 on Ubuntu 18.04 with driver VirtualBox 5.2.18</p>
<p>I found this problem on the Mac with VirtualBox as well. I tried removing the Host Network Manager, but it did not work for me. However, I did find another solution.</p> <p>After issuing <code>minikube delete</code>, I removed the following file:</p> <p><code>/Users/{username}/Library/VirtualBox/HostInterfaceNetworking-vboxnet0-Dhcpd.leases</code></p> <p>Starting minikube again reset the address to .100.</p> <p><strong>File contents:</strong></p> <pre><code>&lt;?xml version="1.0"?&gt; &lt;Leases version="1.0"&gt; &lt;Lease mac="08:00:27:66:6a:19" id="01080027666a19" network="0.0.0.0" state="expired"&gt; &lt;Address value="192.168.99.102"/&gt; &lt;Time issued="1555277299" expiration="1200"/&gt; &lt;/Lease&gt; &lt;Lease mac="08:00:27:08:03:a3" id="010800270803a3" network="0.0.0.0" state="expired"&gt; &lt;Address value="192.168.99.101"/&gt; &lt;Time issued="1555276993" expiration="1200"/&gt; &lt;/Lease&gt; &lt;Lease mac="08:00:27:32:ed:f8" id="0108002732edf8" network="0.0.0.0" state="expired"&gt; &lt;Address value="192.168.99.100"/&gt; &lt;Time issued="1555276537" expiration="1200"/&gt; &lt;/Lease&gt; &lt;/Leases&gt; </code></pre>
<p>What do I have to put into a container to get the agent to run? Just libjprofilerti.so on its own doesn't work, I get</p> <pre><code>Could not find agent.jar. The agentpath parameter must point to libjprofilerti.so in an unmodified JProfiler installation. </code></pre> <p>which sounds like obvious nonsense to me - surely I can't have to install over 137.5 MB of files, 99% of which will be irrelevant, in each container in which I want to profile something?</p> <p>-agentpath:/path/to/libjprofilerti.so=nowait</p>
<p>An approach is to use <a href="https://kubernetes.io/docs/concepts/workloads/pods/init-containers/" rel="nofollow noreferrer">Init Container</a>. </p> <p>The idea is to have an image for JProfiler separate from the application's image. Use the JProfiler image for an Init Container; the Init Container copies the JProfiler installation to a volume shared between that Init Container and the other Containers that will be started in the Pod. This way, the JVM can reference at startup time the JProfiler agent from the shared volume.</p> <p>It goes something like this (more details are in this <a href="https://apisimulator.io/connect-jprofiler-to-jvm-kubernetes-pod/" rel="nofollow noreferrer">blog article</a>):</p> <ul> <li>Define a new volume:</li> </ul> <pre><code>volumes: - name: jprofiler emptyDir: {} </code></pre> <ul> <li>Add an Init Container:</li> </ul> <pre><code>initContainers: - name: jprofiler-init image: &lt;JPROFILER_IMAGE:TAG&gt; command: ["/bin/sh", "-c", "cp -R /jprofiler/ /tmp/"] volumeMounts: - name: jprofiler mountPath: "/tmp/jprofiler" </code></pre> <p>Replace <code>/jprofiler/</code> above with the correct path to the installation directory in the JProfiler's image. Notice that the copy command will create <code>/tmp/jprofiler</code> directory under which the JProfiler installation will go - that is used as mount path.</p> <ul> <li>Define volume mount:</li> </ul> <pre><code>volumeMounts: - name: jprofiler mountPath: /jprofiler </code></pre> <ul> <li>Add to the JVM startup arguments JProfiler as an agent:</li> </ul> <pre><code>-agentpath:/jprofiler/bin/linux-x64/libjprofilerti.so=port=8849 </code></pre> <p>Notice that there isn't a "nowait" argument. That will cause the JVM to block at startup and wait for a JProfiler GUI to connect. The reason is that with this configuration the profiling agent will receive its profiling settings from the JProfiler GUI.</p> <p>Change the application deployment to start with only one replica. Alternatively, start with zero replicas and scale to one when ready to start profiling.</p> <p>To connect from the JProfiler's GUI to the remote JVM:</p> <ul> <li>Find out the name of the pod (e.g. <code>kubectl -n &lt;namespace&gt; get pods</code>) and set up port forwarding to it:</li> </ul> <pre><code>kubectl -n &lt;namespace&gt; &lt;pod-name&gt; port-forward 8849:8849 </code></pre> <ul> <li>Start JProfiler up locally and point it to 127.0.0.1, port 8849.</li> </ul> <p>Change the local port 8849 (the number to the left of <code>:</code>) if it isn't available; then, point JProfiler to that different port.</p>
<p>I'm running vault and consul as pods in kubernetes, while I'm checking <code>consul catalog service</code> it shows <code>consul</code> alone.</p> <p>How can I register <code>vault as a service</code>? </p> <p>I'd tried with the following link, but it didn't work. <a href="https://learn.hashicorp.com/consul/getting-started/services" rel="nofollow noreferrer">https://learn.hashicorp.com/consul/getting-started/services</a></p>
<p>For registering vault as a service you will have to do the following steps</p> <ol> <li>Create a file and write this <code>{"service": {"name": "vault", "tags": ["vault-tag"], "port": 8200}}</code> into it. Name it as <code>vault.json</code></li> <li>Now, enter this command <code>consul services register vault.json</code></li> <li>You can now see that vault is registered as a service <a href="https://i.stack.imgur.com/wa3Us.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/wa3Us.png" alt="vault registeration and checking the consul catalog service"></a></li> </ol>
<p>I am setting up kubernetes 1.14 HA on AWS.</p> <p>I am using Stacked etcd topology with 3 master and 5 worker nodes. I am able to run <code>kubeadm init</code> command on first master node, and run <code>kubeadm join</code> command on the 2nd master node. I see both are successful and able to list using <code>kubectl get nodes</code> command.</p> <p>However, the same <code>kubeadm join</code> command fails on 3rd master node, the command fails. </p> <pre><code>[mark-control-plane] Marking the node ip-10-169-50-168 as control-plane by adding the label "node-role.kubernetes.io/master=''" [mark-control-plane] Marking the node ip-10-169-50-168 as control-plane by adding the taints [node-role.kubernetes.io/master:NoSchedule] [kubelet-check] Initial timeout of 40s passed. error execution phase control-plane-join/mark-control-plane: error applying control-plane label and taints: timed out waiting for the condition </code></pre> <pre><code>NAME STATUS ROLES AGE VERSION ip-XX-XX-XX-XX Ready master 74m v1.14.0 ip-XX-XX-XX-XX Ready master 70m v1.14.0 </code></pre> <p>When I check the docker logs, I see the etcd on 3rd node was able to join the cluster and later the connection is rejected. Below are the logs.</p> <pre><code>2019-04-10 17:44:59.409307 I | etcdserver/membership: added member 8ee1c831d170ef7f [https://XX.XX.XX.XX:2380] to cluster bedd10c18e149ae2 2019-04-10 17:44:59.409447 N | etcdserver/membership: set the initial cluster version to 3.3 2019-04-10 17:44:59.409506 I | etcdserver/api: enabled capabilities for version 3.3 2019-04-10 17:44:59.414195 I | rafthttp: established a TCP streaming connection with peer aa2e639fdfb57216 (stream Message reader) 2019-04-10 17:44:59.426797 I | etcdserver/membership: added member aa2e639fdfb57216 [https://XX.XX.XX.XX:2380] to cluster bedd10c18e149ae2 2019-04-10 17:44:59.428027 I | etcdserver/membership: added member 4d402309132b25d3 [https://XX.XX.XX.XX:2380] to cluster bedd10c18e149ae2 2019-04-10 17:44:59.436291 I | etcdserver: 4d402309132b25d3 initialzed peer connection; fast-forwarding 8 ticks (election ticks 10) with 2 active peer(s) 2019-04-10 17:44:59.448880 I | etcdserver: published {Name:ip-10-169-50-178 ClientURLs:[https://XX.XX.XX.XX:2379]} to cluster bedd10c18e149ae2 2019-04-10 17:44:59.448959 I | embed: ready to serve client requests 2019-04-10 17:44:59.449247 I | embed: ready to serve client requests 2019-04-10 17:44:59.450469 I | embed: serving client requests on XX.XX.XX.XX:2379 2019-04-10 17:44:59.450817 I | embed: serving client requests on 127.0.0.1:2379 2019-04-10 17:45:01.533145 I | embed: rejected connection from "127.0.0.1:46992" (error "EOF", ServerName "") 2019-04-10 17:45:03.146800 I | embed: rejected connection from "XX.XX.XX.XX:48888" (error "remote error: tls: bad certificate", ServerName "") 2019-04-10 17:45:03.788293 I | raft: 4d402309132b25d3 [logterm: 8, index: 892, vote: 0] ignored MsgVote from 8ee1c831d170ef7f [logterm: 8, index: 892] at term 8: lease is not expired (remaining ticks: 10) 2019-04-10 17:45:04.312725 W | wal: sync duration of 1.985619012s, expected less than 1s 2019-04-10 17:45:05.588410 I | raft: 4d402309132b25d3 [logterm: 8, index: 892, vote: 0] ignored MsgVote from 8ee1c831d170ef7f [logterm: 8, index: 892] at term 8: lease is not expired (remaining ticks: 3) 2019-04-10 17:45:05.589745 I | raft: 4d402309132b25d3 [term: 8] received a MsgApp message with higher term from 8ee1c831d170ef7f [term: 10] 2019-04-10 17:45:05.589762 I | raft: 4d402309132b25d3 became follower at term 10 2019-04-10 17:45:05.589781 I | raft: raft.node: 4d402309132b25d3 changed leader from aa2e639fdfb57216 to 8ee1c831d170ef7f at term 10 proto: no coders for int proto: no encoder for ValueSize int [GetProperties] 2019-04-10 17:50:43.108887 I | mvcc: store.index: compact 978 2019-04-10 17:50:43.110211 I | mvcc: finished scheduled compaction at 978 (took 960.176µs) </code></pre> <p>Could you share some pointers, to resolve the issue?</p>
<p>I was able to resolve the issue. I had to pass <code>apiServer</code>.<code>authorization-mode</code> as <code>Node,RBAC</code>.</p>
<p>I'm trying to create a servicemonitor that will instruct prometheus to scrape the metrics from my spring-boot service, but can't find the right way to do that. </p> <p>I have a simple micro service with prometheus enabled, <a href="https://github.com/sloppycoder/profile-svc" rel="nofollow noreferrer">see github for source</a></p> <p>I can run it locally, or deployed into openshift. In both cases I can see the metrics output from http://:/actuator/prometheus endpoint.</p> <p>Since <a href="https://github.com/openshift/installer" rel="nofollow noreferrer">Openshift 4.0 Developer Preview</a> comes with prometheus and <a href="https://github.com/coreos/prometheus-operator" rel="nofollow noreferrer">prometheus operator</a>, I want to simply create a servicemontior object which will trigger the operator to create prometheus configuration that will scrape by pod metrics endpoint, but I can't seem to get it to work, despite trying various tutorials.</p> <p>here is my servicemonitor.yaml</p> <pre><code>apiVersion: monitoring.coreos.com/v1 kind: ServiceMonitor metadata: name: profile-svc-monitor namespace: openshift-monitoring labels: app: profile-svc spec: selector: matchLabels: deploymentconfig: profile-svc namespaceSelector: matchNames: - my-project endpoints: - port: http scheme: http path: '/actuator/prometheus' interval: 15s honorLabels: false </code></pre> <p>After creating the object the prometheus console shows the rules for scraping has been created, but i can't see any pods. Under menu "Status" -> "Targets", it shows</p> <p>openshift-monitoring/profile-svc-monitor/0 (0/0 up)</p> <p>Can anyone shed some light on this?</p>
<p>Your <code>namespaceSelector</code> should be at the same level as <code>selector</code>.</p>
<p>I'm looking for a solution for Kubernetes storage where I can use my UnRaid server as storage for my Kubernetes cluster. Has anyone done anything like this?</p> <p>Any help would be much appreciated.</p> <p>Thanks, Jamie</p>
<p>Probably the only way is to use it an <a href="https://kubernetes.io/docs/concepts/storage/volumes/#nfs" rel="nofollow noreferrer">NFS Volume</a>. This <a href="http://www.adfrad.com/2016/09/connecting-esxi-6-to-unraid-nfs-share.html" rel="nofollow noreferrer">link</a> gives you an idea on how to mount an Unraid NFS share. </p> <p>Then you can follow the <a href="https://github.com/kubernetes/examples/tree/master/staging/volumes/nfs" rel="nofollow noreferrer">Kubernetes example</a> on how to use an NFS Volume in a Pod.</p> <p>Basically, your Unraid server will have an IP address and then you can mount the volume/path using that IP address on your Pod. <a href="https://matthewpalmer.net/kubernetes-app-developer/articles/kubernetes-volumes-example-nfs-persistent-volume.html" rel="nofollow noreferrer">For example</a>:</p> <pre><code>kind: Pod apiVersion: v1 metadata: name: pod-using-nfs spec: # Add the server as an NFS volume for the pod volumes: - name: nfs-volume nfs: # URL for the NFS server server: 10.108.211.244 # Change this! path: / # In this container, we'll mount the NFS volume # and write the date to a file inside it. containers: - name: app image: alpine # Mount the NFS volume in the container volumeMounts: - name: nfs-volume mountPath: /var/nfs # Write to a file inside our NFS command: ["/bin/sh"] args: ["-c", "while true; do date &gt;&gt; /var/nfs/dates.txt; sleep 5; done"] </code></pre> <p>You can also use a <a href="https://kubernetes.io/docs/concepts/storage/persistent-volumes/#persistentvolumeclaims" rel="nofollow noreferrer">PVC</a> if you'd like. <a href="https://medium.com/platformer-blog/nfs-persistent-volumes-with-kubernetes-a-case-study-ce1ed6e2c266" rel="nofollow noreferrer">For example</a>:</p> <pre><code>apiVersion: v1 kind: PersistentVolume metadata: name: nfs spec: capacity: storage: 10Gi accessModes: - ReadWriteMany nfs: server: 10.108.211.244 # Change this! path: "/" --- kind: PersistentVolumeClaim apiVersion: v1 metadata: name: nfs spec: accessModes: - ReadWriteMany storageClassName: "" resources: requests: storage: 10G </code></pre> <p>Then use it in your Deployment or Pod definition:</p> <pre><code>apiVersion: extensions/v1beta1 kind: Deployment metadata: name: nfs-busybox spec: replicas: 1 selector: matchLabels: name: nfs-busybox template: metadata: labels: name: nfs-busybox spec: containers: - image: busybox imagePullPolicy: Always name: busybox volumeMounts: # name must match the volume name below - name: my-pvc-nfs mountPath: "/mnt" volumes: - name: my-pvc-nfs persistentVolumeClaim: claimName: nfs </code></pre>
<p>I have a web server and celery beat worker that I am running on kubernetes. In deployment, I call this command - </p> <p><code>helm upgrade X ./X --set xImageTag=$TAG,nginxImageTag=$TAG --install</code></p> <p>The pods are being restarted. If there is a running celery task - it is stopped in the middle and lost forever. Is there a graceful way to prevent that from happening?</p> <p>I am thinking about: using the pod PreStop hook OR creating something that will prevent the task from stopping.</p> <p>I want the task to continue running even when deploying new code and calling</p> <p><code>helm upgrade ..... --install</code>.</p> <p>I'm sure someone already had that problem, but I couldn't find anything online. Thanks!</p>
<p>We solved it by having the celery task programatically create a k8s job. Now the process of the celery task is executed in a k8s job, which won't be deleted in helm install. The celery task will create a k8s job, and die. The code for creating a k8s job programatically is here: blog.pythian.com/how-to-create-kubernetes-jobs-with-python . </p>
<p>I'm trying to figure out how to create a simple API key protected proxy with Ambassador on k8s, yet can't seem to find any docs on this. </p> <p>Specifically, I just want to set it up so it can take a request with API-KEY header, authenticate it, and if API-KEY is valid for some client, pass it onto my backend. </p>
<p>I suggest you do the following:</p> <ol> <li><p>Create an Authentication Application: for each protected endpoint, this app will be responsible for validating the Api Key.</p></li> <li><p>Configuring Ambassador to redirect requests to this service: you just need to annotate your authentication app service definition. Example:</p></li> </ol> <pre><code> --- apiVersion: v1 kind: Service metadata: name: auth-app annotations: getambassador.io/config: | --- apiVersion: ambassador/v1 kind: AuthService name: authentication auth_service: "auth-app:8080" allowed_request_headers: - "API-KEY" spec: type: ClusterIP selector: app: auth-app ports: - port: 8080 name: auth-app targetPort: auth-app </code></pre> <ol start="3"> <li>Configure an endpoint in <em>auth-app</em> corresponding to the endpoint of the app you want to authenticate. Suppose you have an app with a Mapping like this:</li> </ol> <pre><code> apiVersion: ambassador/v1 kind: Mapping name: myapp-mapping prefix: /myapp/ service: myapp:8000 </code></pre> <p>Then you need to have an endpoint "<em>/myapp/</em>" in <em>auth-app</em>. You will read your <em>API-KEY</em> header there. If the key is valid, return a HTTP 200 (OK). Ambassador will then send the original message to <em>myapp</em>. If <em>auth-app</em> returns any other thing besides a HTTP 200, Ambassador will return that response to the client.</p> <ol start="4"> <li>Bypass the authentication in needed apps. For example you might need a login app, responsible for providing an API Key to the clients. You can bypass authentication for these apps using <strong>bypass_auth: true</strong> in the mapping:</li> </ol> <pre><code> apiVersion: ambassador/v1 kind: Mapping name: login-mapping prefix: /login/ service: login-app:8080 bypass_auth: true </code></pre> <p><a href="https://www.getambassador.io/reference/services/auth-service/" rel="nofollow noreferrer">Check this</a> if you want to know more about authentication in Ambassador</p> <p>EDIT: <a href="https://stackoverflow.com/a/33281233/8971507">According to this answer</a> it is a good practice if you use as header <code>Authorization: Bearer {base64-API-KEY}</code>. In Ambassador the <em>Authorization</em> header is allowed by default, so you don't need to pass it in the <em>allowed_request_headers</em> field.</p>
<p>I have node on google kubernetes engine using persistent volume. Is possible edit files on this volume from gcloud, or google cloud shell? For example edit config and recreate node? Or it is only posiible from running pod using kubectl exec?</p>
<p>i think you can have a look to gsutil command it allows you to interact with your buckets . <a href="https://cloud.google.com/storage/docs/quickstart-gsutil" rel="nofollow noreferrer">Guide to Gsutil</a> </p>
<p>I just upgraded the RAM from 16GB to 32GB for all VM nodes of existing cluster.</p> <p>But <code>kubectl get nodes</code> still shows 16GB per node memory, how to make kubernetes re-read the sepcs?</p>
<p>Restart Kubelet does the trick but its not practial in case of larger clusters.</p> <pre><code>$ kubectl get nodes node-02 -o yaml | grep mem memory: 16145384Ki memory: 16247784Ki message: kubelet has sufficient memory available </code></pre> <p>After restart:</p> <pre><code>$ kubectl get nodes node-02 -o yaml | grep mem memory: 32922600Ki memory: 33025000Ki message: kubelet has sufficient memory available </code></pre>
<p>I am running a kubernetes cluter with 6 nodes (cluser-master &amp; kubernetes slave0-4) on "Bionic Beaver"ubuntu and I'm using Weave To install kubernetes I followed <a href="https://vitux.com/install-and-deploy-kubernetes-on-ubuntu/" rel="nofollow noreferrer">https://vitux.com/install-and-deploy-kubernetes-on-ubuntu/</a> and installed weave after installing whatever was reccommended here after clean removing it(it doesn't show up in my pods anymore)</p> <p><code>kubectl get pods --all-namespaces</code> returns:</p> <pre><code>NAMESPACE NAME READY STATUS RESTARTS AGE kube-system coredns-fb8b8dccf-g8psp 0/1 ContainerCreating 0 77m kube-system coredns-fb8b8dccf-pbfr7 0/1 ContainerCreating 0 77m kube-system etcd-cluster-master 1/1 Running 5 77m kube-system kube-apiserver-cluster-master 1/1 Running 5 77m kube-system kube-controller-manager-cluster-master 1/1 Running 5 77m kube-system kube-proxy-72s98 1/1 Running 5 73m kube-system kube-proxy-cqmdm 1/1 Running 3 63m kube-system kube-proxy-hgnpj 1/1 Running 0 69m kube-system kube-proxy-nhjdc 1/1 Running 5 72m kube-system kube-proxy-sqvdd 1/1 Running 5 77m kube-system kube-proxy-vmg9k 1/1 Running 0 70m kube-system kube-scheduler-cluster-master 1/1 Running 5 76m kube-system kubernetes-dashboard-5f7b999d65-p7clv 0/1 ContainerCreating 0 61m kube-system weave-net-2brvt 2/2 Running 0 69m kube-system weave-net-5wlks 2/2 Running 16 72m kube-system weave-net-65qmd 2/2 Running 16 73m kube-system weave-net-9x8cz 2/2 Running 9 63m kube-system weave-net-r2nhz 2/2 Running 15 75m kube-system weave-net-stq8x 2/2 Running 0 70m </code></pre> <p>and if I go with <code>kubectl describe $(kube dashboard pod name) --namespace=kube-system</code> it returns:</p> <pre><code>NAME READY STATUS RESTARTS AGE kubernetes-dashboard-5f7b999d65-p7clv 0/1 ContainerCreating 0 64m rock64@cluster-master:~$ rock64@cluster-master:~$ kubectl describe pods kubernetes-dashboard-5f7b999d65-p7clv --namespace=kube-system Name: kubernetes-dashboard-5f7b999d65-p7clv Namespace: kube-system Priority: 0 PriorityClassName: &lt;none&gt; Node: kubernetes-slave1/10.0.0.215 Start Time: Sun, 14 Apr 2019 10:20:42 +0000 Labels: k8s-app=kubernetes-dashboard pod-template-hash=5f7b999d65 Annotations: &lt;none&gt; Status: Pending IP: Controlled By: ReplicaSet/kubernetes-dashboard-5f7b999d65 Containers: kubernetes-dashboard: Container ID: Image: k8s.gcr.io/kubernetes-dashboard-amd64:v1.10.1 Image ID: Port: 8443/TCP Host Port: 0/TCP Args: --auto-generate-certificates State: Waiting Reason: ContainerCreating Ready: False Restart Count: 0 Liveness: http-get https://:8443/ delay=30s timeout=30s period=10s #success=1 #failure=3 Environment: &lt;none&gt; Mounts: /certs from kubernetes-dashboard-certs (rw) /tmp from tmp-volume (rw) /var/run/secrets/kubernetes.io/serviceaccount from kubernetes-dashboard-token-znrkr (ro) Conditions: Type Status Initialized True Ready False ContainersReady False PodScheduled True Volumes: kubernetes-dashboard-certs: Type: Secret (a volume populated by a Secret) SecretName: kubernetes-dashboard-certs Optional: false tmp-volume: Type: EmptyDir (a temporary directory that shares a pod's lifetime) Medium: SizeLimit: &lt;unset&gt; kubernetes-dashboard-token-znrkr: Type: Secret (a volume populated by a Secret) SecretName: kubernetes-dashboard-token-znrkr Optional: false QoS Class: BestEffort Node-Selectors: &lt;none&gt; Tolerations: node-role.kubernetes.io/master:NoSchedule node.kubernetes.io/not-ready:NoExecute for 300s node.kubernetes.io/unreachable:NoExecute for 300s Events: Type Reason Age From Message ---- ------ ---- ---- ------- Normal Scheduled 64m default-scheduler Successfully assigned kube-system/kubernetes-dashboard-5f7b999d65-p7clv to kubernetes-slave1 Warning FailedCreatePodSandBox 64m kubelet, kubernetes-slave1 Failed create pod sandbox: rpc error: code = Unknown desc = [failed to set up sandbox container "4e6d9873f49a02e86cef79e338ce97162291897b2aaad1ddb99c5e066ed42178" network for pod "kubernetes-dashboard-5f7b999d65-p7clv": NetworkPlugin cni failed to set up pod "kubernetes-dashboard-5f7b999d65-p7clv_kube-system" network: failed to find plugin "loopback" in path [/opt/cni/bin], failed to clean up sandbox container "4e6d9873f49a02e86cef79e338ce97162291897b2aaad1ddb99c5e066ed42178" network for pod "kubernetes-dashboard-5f7b999d65-p7clv": NetworkPlugin cni failed to teardown pod "kubernetes-dashboard-5f7b999d65-p7clv_kube-system" network: failed to find plugin "portmap" in path [/opt/cni/bin]] Normal SandboxChanged 59m (x25 over 64m) kubelet, kubernetes-slave1 Pod sandbox changed, it will be killed and re-created. Normal SandboxChanged 49m (x18 over 53m) kubelet, kubernetes-slave1 Pod sandbox changed, it will be killed and re-created. Normal SandboxChanged 46m (x13 over 48m) kubelet, kubernetes-slave1 Pod sandbox changed, it will be killed and re-created. Normal SandboxChanged 24m (x94 over 44m) kubelet, kubernetes-slave1 Pod sandbox changed, it will be killed and re-created. Normal SandboxChanged 4m12s (x26 over 9m52s) kubelet, kubernetes-slave1 Pod sandbox changed, it will be killed and re-created.``` </code></pre>
<blockquote> <p><code>failed to find plugin "loopback" in path [/opt/cni/bin]</code></p> </blockquote> <p>As the helpful message is trying to explain to you, it appears you have a botched CNI installation. Anytime you see <code>FailedCreatePodSandBox</code> or <code>SandboxChanged</code>, it's always(?) related to a CNI failure.</p> <p>The very short version is to grab <a href="https://github.com/containernetworking/plugins/releases/tag/v0.7.5" rel="nofollow noreferrer">the latest CNI plugins</a> package, unpack it into <code>/opt/cni/bin</code>, ensure they are executable, and restart ... uh, likely the machine, but certainly the offending Pod and most likely <code>kubelet</code>, too.</p> <p>p.s. You will have a much nicer time here on SO by <a href="https://stackoverflow.com/search?q=pod+sandboxchanged">conducing a little searching</a>, as this is a <strong>very common</strong> question</p>
<p>The following problem occurs on a Kubernetes cluster with 1 master and 3 nodes and also on a single-machine Kubernetes.</p> <p>I set up the Kubernetes with flexvolume smb support (<a href="https://github.com/Azure/kubernetes-volume-drivers/tree/master/flexvolume/smb" rel="nofollow noreferrer">https://github.com/Azure/kubernetes-volume-drivers/tree/master/flexvolume/smb</a>). When I apply a new pod with flexvolume the Node mounts the smb share as expected. But the Pod points his share to some docker directory on the Node.</p> <p>My installation:</p> <ul> <li>latest CentOS 7</li> <li>latest Kubernetes v1.14.0<br> (<a href="https://kubernetes.io/docs/setup/independent/create-cluster-kubeadm/" rel="nofollow noreferrer">https://kubernetes.io/docs/setup/independent/create-cluster-kubeadm/</a>)</li> <li>disabled SELinux and disabled firewall</li> <li>Docker 1.13.1</li> <li>jq and cifs-utils</li> <li><a href="https://raw.githubusercontent.com/Azure/kubernetes-volume-drivers/master/flexvolume/smb/deployment/smb-flexvol-installer/smb" rel="nofollow noreferrer">https://raw.githubusercontent.com/Azure/kubernetes-volume-drivers/master/flexvolume/smb/deployment/smb-flexvol-installer/smb</a> installed to /usr/libexec/kubernetes/kubelet-plugins/volume/exec/microsoft.com~smb and executable</li> </ul> <h2>Create Pod with</h2> <p>smb-secret.yaml</p> <pre><code>apiVersion: v1 kind: Secret metadata: name: smb-secret type: microsoft.com/smb data: username: YVVzZXI= password: YVBhc3N3b3Jk </code></pre> <p>nginx-flex-smb.yaml</p> <pre><code>apiVersion: v1 kind: Pod metadata: name: nginx-flex-smb spec: containers: - name: nginx-flex-smb image: nginx volumeMounts: - name: test mountPath: /data volumes: - name: test flexVolume: driver: "microsoft.com/smb" secretRef: name: smb-secret options: source: "//&lt;host.with.smb.share&gt;/kubetest" mountoptions: "vers=3.0,dir_mode=0777,file_mode=0777" </code></pre> <h2>What happens</h2> <ul> <li>Mount point on Node is created on <code>/var/lib/kubelet/pods/bef26895-5ac7-11e9-a668-00155db9c92e/volumes/microsoft.com~smb</code>.</li> <li><code>mount</code> returns <code>//&lt;host.with.smb.share&gt;/kubetest on /var/lib/kubelet/pods/bef26895-5ac7-11e9-a668-00155db9c92e/volumes/microsoft.com~smb/test type cifs (rw,relatime,vers=3.0,cache=strict,username=aUser,domain=,uid=0,noforceuid,gid=0,noforcegid,addr=172.27.72.43,file_mode=0777,dir_mode=0777,soft,nounix,serverino,mapposix,rsize=1048576,wsize=1048576,echo_interval=60,actimeo=1)</code></li> <li>read and write works as expected on host and on the Node itself</li> <li>on Pod <ul> <li><code>mount</code>for /data points to <code>tmpfs on /data type tmpfs (rw,nosuid,nodev,seclabel,size=898680k,nr_inodes=224670,mode=755)</code></li> <li>but the content of the directory /data comes from <code>/run/docker/libcontainerd/8039742ae2a573292cd9f4ef7709bf7583efd0a262b9dc434deaf5e1e20b4002/</code> on the node.</li> </ul></li> </ul> <p>I tried to install the Pod with a PersistedVolumeClaime and get the same problem. Searching for this problem got me no solutions.</p> <p>Our other pods uses GlusterFS and heketi which works fine.</p> <p>Is there maybe a configuration failure? Something missing?</p> <p><strong>EDIT: Solution</strong><br> I upgraded Docker to the latest validated Version 18.06 and everything works well now.</p>
<p>I upgraded Docker to the latest validated Version 18.06 and everything works well now.</p> <p>To install it follow the instructions on <a href="https://docs.docker.com/install/linux/docker-ce/centos/" rel="nofollow noreferrer">Get Docker CE for CentOS</a>.</p>
<p>Practicing with Kubernetes.</p> <p>Is it possible to create a <code>YAML</code> deployment object and its configuration through <code>Bash</code> only? </p> <p>I have tried this:</p> <pre><code>kubectl create -f deployment.yaml </code></pre> <p>to create a yaml so i could edit later. However it just displays </p> <pre><code>error: the path "deployment.yaml" does not exist </code></pre>
<p>All the answers so far advocate actually deploying to the cluster, then retrieving the running deployment. </p> <p>Using the <code>--dry-run</code> you can get the YAML format of the object without actually deploying anything. For example:</p> <pre><code>kubectl create deployment nginx --image=nginx --dry-run -o yaml </code></pre> <p>Will output the deployment YAML to stdout:</p> <pre><code>apiVersion: apps/v1 kind: Deployment metadata: creationTimestamp: null labels: app: nginx name: nginx spec: replicas: 1 selector: matchLabels: app: nginx strategy: {} template: metadata: creationTimestamp: null labels: app: nginx spec: containers: - image: nginx name: nginx resources: {} status: {} </code></pre>
<p>How to sort the pods with respect to it's IP or it's Node IP.</p> <p>I tried this command and I have around 20 pods running on my 3 node cluster.</p> <pre><code>kubectl get pods --all-namespaces --sort-by={'.spec.ip'} </code></pre> <blockquote> <p>error: ip is not found</p> </blockquote> <p>this is the error I am getting</p>
<p>You're using the wrong command to sort. The correct command will be:</p> <pre><code>kubectl get pods --all-namespaces --sort-by={.status.podIP} </code></pre> <p>This will sort your pods according to the podIP.</p>
<p>I have been creating an amazon AMI with kubernetes installed on it to use as a worker node in EKS, I install the kubelet binary from the amazon-eks s3 bucket.</p> <p>After upgrading from k8s version 1.10.11 to 1.11.5 I noticed a difference in the x509 certificate that is generated when installing kubelet.</p> <p>If I jump onto one of the worker nodes with 1.10.11 installed and run this command <code>openssl s_client -connect localhost:10250 2&gt;/dev/null | openssl x509 -noout -text</code> I get the following output for <code>X509v3 Subject Alternative Name</code>:</p> <pre><code>DNS:ip-&lt;my-ip&gt;.eu-central-1.compute.internal, DNS:ip-&lt;my-ip&gt;, IP Address:&lt;my-ip&gt; </code></pre> <p>whereas, if I run the same command on a worker node with 1.11.5 installed I get the following output for <code>X509v3 Subject Alternative Name</code>:</p> <pre><code>DNS:ip-&lt;my-ip&gt; </code></pre> <p>The only change between the two nodes is the version of kubernetes installed.</p> <p>Am I missing anything that is now required as of version 1.11.x to set the additional Subject Alternative Names as seemed to be previously done in v1.10.x? I require the IP address to be set in the certificate in the format <code>IP Address:&lt;my-ip&gt;</code> which I was getting for free in version 1.10.</p> <p>FYI I am running kubelet with the following args:</p> <pre><code>ExecStart=/usr/bin/kubelet \ --address=0.0.0.0 \ --authentication-token-webhook \ --authorization-mode=Webhook \ --allow-privileged=true \ --cloud-provider=aws \ --cluster-dns=DNS_CLUSTER_IP \ --cluster-domain=cluster.local \ --cni-bin-dir=/opt/cni/bin \ --cni-conf-dir=/etc/cni/net.d \ --container-runtime=docker \ --max-pods=MAX_PODS \ --node-ip=INTERNAL_IP \ --network-plugin=cni \ --pod-infra-container-image=602401143452.dkr.ecr.REGION.amazonaws.com/eks/pause-amd64:3.1 \ --cgroup-driver=cgroupfs \ --register-node=true \ --kubeconfig=/var/lib/kubelet/kubeconfig \ --feature-gates=RotateKubeletServerCertificate=true \ --anonymous-auth=false \ --client-ca-file=CLIENT_CA_FILE \ --node-labels=env=NODE_LABEL </code></pre>
<p>As far as handling the certificates there are not Kubernetes specific differences between <code>1.10.11</code> and <code>1.11.5</code>. It might be related to specific <a href="https://docs.aws.amazon.com/eks/latest/userguide/eks-optimized-ami.html" rel="nofollow noreferrer">EKS AMI</a> for the nodes that you are using (make sure they are matching)</p> <p>If not you can manually <a href="https://kubernetes.io/docs/concepts/cluster-administration/certificates/" rel="nofollow noreferrer">create</a> the certificates for the kubelet using the same CA as the one in your Kubernetes master. For example:</p> <p><strong><em>easyrsa</em></strong></p> <pre><code>./easyrsa --subject-alt-name="IP:${MASTER_IP},"\ "IP:-&lt;my-ip&gt;,"\ "DNS:ip-&lt;my-ip&gt;.eu-central-1.compute.internal,"\ "DNS:ip-&lt;my-ip&gt;,"\ --days=10000 \ build-server-full server nopass </code></pre> <p><strong><em>openssl</em></strong></p> <p>Config (csr.conf):</p> <pre><code>[ req ] default_bits = 2048 prompt = no default_md = sha256 req_extensions = req_ext distinguished_name = dn [ dn ] C = &lt;country&gt; ST = &lt;state&gt; L = &lt;city&gt; O = &lt;organization&gt; OU = &lt;organization unit&gt; CN = &lt;my-ip&gt; [ req_ext ] subjectAltName = @alt_names [ alt_names ] DNS.1 = ip-&lt;my-ip&gt;.eu-central-1.compute.internal DNS.2 = ip-&lt;my-ip&gt; IP.1 = &lt;my-ip&gt; [ v3_ext ] authorityKeyIdentifier=keyid,issuer:always basicConstraints=CA:FALSE keyUsage=keyEncipherment,dataEncipherment extendedKeyUsage=serverAuth,clientAuth subjectAltName=@alt_names </code></pre> <p>Create CSR:</p> <pre><code>$ openssl req -new -key server.key -out server.csr -config csr.conf </code></pre> <p>Create certificate:</p> <pre><code>$ openssl x509 -req -in server.csr -CA cluster-ca.crt -CAkey cluster-ca.key \ -CAcreateserial -out server.crt -days 10000 \ -extensions v3_ext -extfile csr.conf </code></pre> <p><strong><em>cfssl</em></strong></p> <p>In a similar fashion you can use <a href="https://github.com/cloudflare/cfssl" rel="nofollow noreferrer">cfssl</a>, described <a href="https://kubernetes.io/docs/concepts/cluster-administration/certificates/#cfssl" rel="nofollow noreferrer">here</a>.</p>
<p>I am using Ubuntu bionic (18.04) with latest version of kubeadm on Ubuntu's repositories (1.13.4) and calico 3.6, following their documentation for "Installing with the Kubernetes API datastore—50 nodes or less" (<a href="https://docs.projectcalico.org/v3.6/getting-started/kubernetes/installation/calico" rel="nofollow noreferrer">https://docs.projectcalico.org/v3.6/getting-started/kubernetes/installation/calico</a>).</p> <p>It was started with:</p> <pre><code>sudo kubeadm init --pod-network-cidr=192.168.0.0/16 </code></pre> <p>But when I apply calico.yaml my node gets stuck with the condition:</p> <blockquote> <p>Conditions: Type Status LastHeartbeatTime<br> LastTransitionTime Reason Message ---- ------ ----------------- ------------------ ------ ------- MemoryPressure False Mon, 15 Apr 2019 20:24:43 -0300 Mon, 15 Apr 2019 20:21:20 -0300 KubeletHasSufficientMemory kubelet has sufficient memory available DiskPressure False Mon, 15 Apr 2019 20:24:43 -0300 Mon, 15 Apr 2019 20:21:20 -0300<br> KubeletHasNoDiskPressure kubelet has no disk pressure<br> PIDPressure False Mon, 15 Apr 2019 20:24:43 -0300 Mon, 15 Apr 2019 20:21:20 -0300 KubeletHasSufficientPID kubelet has sufficient PID available Ready False Mon, 15 Apr 2019 20:24:43 -0300 Mon, 15 Apr 2019 20:21:20 -0300 KubeletNotReady<br> runtime network not ready: NetworkReady=false reason:NetworkPluginNotReady message:docker: network plugin is not ready: cni config uninitialized</p> </blockquote> <p>When I see the system pods (<code>kubectl get pods -n kube-system</code>) I get:</p> <pre><code>NAME READY STATUS RESTARTS AGE calico-kube-controllers-55df754b5d-zsttg 0/1 Pending 0 34s calico-node-5n6p2 0/1 Init:0/2 0 35s coredns-86c58d9df4-jw7wk 0/1 Pending 0 99s coredns-86c58d9df4-sztxw 0/1 Pending 0 99s etcd-cherokee 1/1 Running 0 36s kube-apiserver-cherokee 1/1 Running 0 46s kube-controller-manager-cherokee 1/1 Running 0 59s kube-proxy-22xwj 1/1 Running 0 99s kube-scheduler-cherokee 1/1 Running 0 44s </code></pre> <p>May this be a bug or there is something missing?</p>
<p>Try removing the taint on the master node, <code>kubectl taint nodes --all node-role.kubernetes.io/master-</code>.</p> <p>Reference here, <a href="https://kubernetes.io/docs/setup/independent/create-cluster-kubeadm/#control-plane-node-isolation" rel="nofollow noreferrer">https://kubernetes.io/docs/setup/independent/create-cluster-kubeadm/#control-plane-node-isolation</a></p>
<p>I am setting up Kubernetes cluster on Azure (using AKS) to host Elasticsearch, Kibana, custom api, UI, nginx, etc.</p> <p>As I don't want separate public IP per service, I need a way to setup a common load balancer/Ingress and then just add the port numbers to there and setup routing.</p> <p>I tried using the approach mentioned in this stackoverflow question - <a href="https://stackoverflow.com/questions/45147664/how-to-expose-multiple-port-using-a-load-balancer-services-in-kubernetes">How to expose multiple port using a load balancer services in kubernetes</a> but didn't work out. </p> <p>As there are technology clients connecting to my cluster, I need to have service per technology. </p> <p>Basically I need to expose 9200, 5601, 80 - all on same IP but on accessing the IP with port, user must be re-directed to appropriate technology service.</p> <p>Below is sample configuration for what am looking for.</p> <pre><code>apiVersion: extensions/v1beta1 kind: Ingress metadata: name: myingress spec: rules: - host: myurl.domain.com http: paths: - path: / backend: serviceName: elasticsearch servicePort: 9200 - path: / backend: serviceName: kibana servicePort: 5602 </code></pre> <p>Any thoughts?</p>
<p>With your issue, the ingress is what you want. You can create all your services as you want. And expose the ports for your service. Then create the ingress with a public IP and create the ingress route that routes the access from the ingress to your backend services. </p> <p>Take a look at the example in <a href="https://learn.microsoft.com/en-us/azure/aks/ingress-basic" rel="nofollow noreferrer">Create an ingress controller in Azure Kubernetes Service (AKS)</a>. It will show you what the steps need to be done. And if you have more questions please let me know.</p>
<p>So I did a tutorial based on tensorflow-servings and Kubernetes. All steps are working fine except the docker image pushing to the cluster.</p> <p>this is the tutorial that i have tried. <a href="https://www.tensorflow.org/tfx/serving/serving_kubernetes" rel="nofollow noreferrer">https://www.tensorflow.org/tfx/serving/serving_kubernetes</a></p> <p>And when I'm trying to push the docker image it gives an error like this,</p> <p><a href="https://i.stack.imgur.com/rARLF.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/rARLF.png" alt="enter image description here"></a></p> <p>I have tried to create the cluster with scopes also. But the result is same as above.</p> <p>The command I use to create a cluster with scopes:</p> <p><code>gcloud container clusters create resnet-serving-cluster --num-nodes 5 --scopes=storage-rw</code></p> <p>So what is the wrong with this? Have I done something wrong???</p>
<p>Ok found the answer. My project ID and registry name are not equal. I re-tag the docker image with new registry name providing my project id and push it. It works.</p>
<p>I deployed grafana using helm and now it is running in pod. I can access it if I proxy port 3000 to my laptop. Im trying to point a domain <code>grafana.something.com</code> to that pod so I can access it externally. I have a domain in route53 that I can attach to a loadbalancer (Application Load Balancer, Network Load Balancer, Classic Load Balancer). That load balancer can forward traffic from port 80 to port 80 to a group of nodes (Let's leave port 443 for later). I'm really struggling with setting this up. Im sure there is something missing but I don't know what.</p> <p>Basic diagram would look like this I imagine.</p> <p>Internet<br> ↓↓<br> Domain in route53 (grafana.something.com) <br> ↓↓<br> Loadbalancer 80 to 80 (Application Load Balancer, Network Load Balancer, Classic Load Balancer) I guess that LB would forward traffic to port 80 to the below Ingress Controllers (Created when Grafana was deployed using Helm) <br> ↓↓<br> Group of EKS worker nodes<br> ↓↓<br> Ingress resource ?????<br> ↓↓<br> Ingress Controllers - Created when Grafana was deployed using Helm in namespace test.</p> <p><code>kubectl get svc grafana -n test</code></p> <p><code>grafana Type:ClusterIP ClusterIP:10.x.x.x Port:80/TCP</code></p> <pre><code>apiVersion: v1 kind: Service metadata: creationTimestamp: labels: app: grafana chart: grafana- heritage: Tiller release: grafana-release name: grafana namespace: test resourceVersion: "xxxx" selfLink: uid: spec: clusterIP: 10.x.x.x ports: - name: http port: 80 protocol: TCP targetPort: 3000 selector: app: grafana sessionAffinity: None type: ClusterIP status: loadBalancer: {} </code></pre> <p>↓↓<br> Pod Grafana is listening on port 3000. I can access it successfully after proxying to my laptop port 3000.</p>
<p>Given that it seems you don't have an <a href="https://kubernetes.io/docs/concepts/services-networking/ingress-controllers/" rel="noreferrer">Ingress Controller</a> installed, if you have the aws cloud-provider configured in your K8S cluster you can follow <a href="https://kubernetes.github.io/ingress-nginx/deploy/#using-helm" rel="noreferrer">this guide</a> to install the Nginx Ingress controller using Helm.</p> <p>By the end of the guide you should have a load balancer created for your ingress controller, point your Route53 record to it and create an Ingress that uses your grafana service. Example:</p> <pre><code>apiVersion: extensions/v1beta1 kind: Ingress metadata: annotations: kubernetes.io/ingress.class: nginx nginx.ingress.kubernetes.io/app-root: / nginx.ingress.kubernetes.io/enable-access-log: "true" name: grafana-ingress namespace: test spec: rules: - host: grafana.something.com http: paths: - backend: serviceName: grafana servicePort: 80 path: / </code></pre> <p>The final traffic path would be:</p> <pre><code>Route53 -&gt; ELB -&gt; Ingress -&gt; Service -&gt; Pods </code></pre>
<p>I was assigned the task of making a dynamic load of settings for the Angular application from the JSON file on the server during the application start. The peculiarity is that the application uses server rendering with Universal. I tried to do this for the browser using this method. <a href="https://juristr.com/blog/2018/01/ng-app-runtime-config" rel="nofollow noreferrer">https://juristr.com/blog/2018/01/ng-app-runtime-config</a> But it works only for the browser app rendering. How to do it for server-side rendering?</p>
<p>The most likely culprit here is that you're loading json file from relative path but Universal does not currently support relative urls but only absolute.</p> <p>So you can provide absolute path to your json file:</p> <p><strong>server.ts</strong></p> <pre><code>app.engine('html', (_, options, callback) =&gt; { const protocol = options.req.protocol; const host = options.req.get('host'); const engine = ngExpressEngine({ bootstrap: AppServerModuleNgFactory, providers: [ provideModuleMap(LAZY_MODULE_MAP), { provide: 'APP_BASE_URL', useFactory: () =&gt; `${protocol}://${host}`, deps: [] }, ] }); engine(_, options, callback); }); </code></pre> <p><strong>your.service.ts</strong></p> <pre><code>@Injectable() export class ConfigProvider { config: Config; constructor( private http: HttpClient, @Inject(PLATFORM_ID) private platformId: {}, @Inject('APP_BASE_URL') @Optional() private readonly baseUrl: string ) { if (isPlatformBrowser(platformId)) { this.baseUrl = document.location.origin; } } loadConfig() { return this.http.get&lt;Config&gt;( `${this.baseUrl}/assets/plugins-config.json` ); } } </code></pre> <p>For more details see <a href="https://github.com/alexzuza/angular-plugin-architecture/blob/23ab862d96f2fe65942a8cd78ac605ff0f699f56/src/app/services/plugins-config.provider.ts#L32" rel="noreferrer">example of project</a> that also uses APP_INITIALIZER to load config </p>
<p>I created a Jenkins persistent app using this template <a href="https://github.com/openshift/origin/blob/master/examples/jenkins/jenkins-persistent-template.json" rel="nofollow noreferrer">here</a>. Now when a pod gets created and I want to access pod as a root user. But when I do <code>oc rsh jenkins-mypod</code>, it opens the pod as a <code>default</code> user. I want to open the pod as the <code>root</code> user. How can I do that?. I created this app under the <code>developer</code> account.</p>
<p>This is an opened issue in kubernetes <a href="https://github.com/kubernetes/kubernetes/issues/30656" rel="nofollow noreferrer">https://github.com/kubernetes/kubernetes/issues/30656</a> so I don't think it's possible in openshift either.</p>
<p>I dit a new install of kubectl and after i get the message:</p> <blockquote> <p>Warnings: - kubernetes-cli - kubernetes-cli v1.13.3 already installed. Use --force to reinstall, specify a version to install, or try upgrade.</p> </blockquote> <p>But when I ask <em>kubectl version</em> I get this information:</p> <blockquote> <p>C:\Users\myname> kubectl version </p> <p>Client Version: version.Info{Major:"1", Minor:"10", GitVersion:"v1.10.11", GitCommit:"637c7e288581ee40ab4ca210618a89a555b6e7e9", GitTreeState:"clean", BuildDate:"2018-11-26T14:38:32Z", GoVersion:"go1.9.3", Compiler:"gc", Platform:"windows/amd64"} Server Version: version.Info{Major:"1", Minor:"11", GitVersion:"v1.11.5", GitCommit:"753b2dbc622f5cc417845f0ff8a77f539a4213ea", GitTreeState:"clean", BuildDate:"2018-11-26T14:31:35Z", GoVersion:"go1.10.3", Compiler:"gc", Platform:"linux/amd64"}</p> </blockquote> <p><strong>Why I don't find the version number 1.13 in the version information's?</strong></p>
<p>In my case, I had this issue because I have both Docker <em>and</em> the Kubernetes CLI installed; at time of writing, Docker currently ships with version v1.10 of kubectl, whereas the Kubernetes CLI ships with v1.14</p> <p>The simple solution was just to re-order my environment variables so that the Docker version of kubectl was <em>after</em> the Kubernetes CLI version</p>
<p>As discovered <a href="https://kubernetes.io/blog/2018/07/09/ipvs-based-in-cluster-load-balancing-deep-dive/" rel="nofollow noreferrer">here</a>, there is a new kind of kube service that are IPVS and have many algorithms for load balancing.</p> <p>The only problem is I didn't find where those algorithms are specified.</p> <p>My understanding:</p> <ol> <li><code>rr</code>: <strong>round-robin</strong> <em>-&gt; call backend pod one after another in a loop</em></li> <li><code>lc</code>: <strong>least connection</strong> <em>-&gt; group all pod with the lowest number of connection, and send message to it. Which kind of connection? only the ones from this service ?</em></li> <li><code>dh</code>: <strong>destination hashing</strong> <em>-&gt; ?something based on url?</em></li> <li><code>sh:</code> <strong>source hashing</strong> <em>-&gt; ?something based on url?</em></li> <li><code>sed</code>: <strong>shortest expected delay</strong> <em>-&gt; either the backend with less ping or some logic on the time a backend took to respond in the past</em></li> <li><code>nq</code>: <strong>never queue</strong> <em>-&gt; same as least connection? but refusing messages at some points ?</em></li> </ol> <hr /> <p>If anyone has the documentation link (not provided in the <a href="https://kubernetes.io/docs/concepts/services-networking/service/" rel="nofollow noreferrer">official page</a> and still saying IPVS is beta whereas it is stable sync 1.11) or the real algorithm behind all of them, please help.</p> <p>I tried: Google search with the terms + lookup in the official documentation.</p>
<p>They are defined in the code <a href="https://github.com/kubernetes/kubernetes/blob/master/pkg/proxy/apis/config/types.go#L193" rel="noreferrer">https://github.com/kubernetes/kubernetes/blob/master/pkg/proxy/apis/config/types.go#L193</a></p> <ul> <li><code>rr</code> <strong>round robin</strong> : distributes jobs equally amongst the available real servers</li> <li><code>lc</code> <strong>least connection</strong> : assigns more jobs to real servers with fewer active jobs</li> <li><code>sh</code> <strong>source hashing</strong> : assigns jobs to servers through looking up a statically assigned hash table by their source IP addresses</li> <li><code>dh</code> <strong>destination hashing</strong> : assigns jobs to servers through looking up a statically assigned hash table by their destination IP addresses</li> <li><code>sed</code> <strong>shortest expected delay</strong> : assigns an incoming job to the server with the shortest expected delay. The expected delay that the job will experience is (Ci + 1) / Ui if sent to the ith server, in which Ci is the number of jobs on the ith server and Ui is the fixed service rate (weight) of the ith server.</li> <li><code>nq</code> <strong>never queue</strong> : assigns an incoming job to an idle server if there is, instead of waiting for a fast one; if all the servers are busy, it adopts the ShortestExpectedDelay policy to assign the job.</li> </ul> <p>All those come from IPVS official documentation : <a href="http://www.linuxvirtualserver.org/docs/scheduling.html" rel="noreferrer">http://www.linuxvirtualserver.org/docs/scheduling.html</a></p> <p>Regards</p>
<p>I'm having some trouble installing an Ingress Controller in my on-prem cluster (created with Kubespray, running MetalLB to create LoadBalancer.).</p> <p>I tried using nginx, traefik and kong but all got the same results.</p> <p>I'm installing my the nginx helm chart using the following values.yaml:</p> <pre><code>controller: kind: DaemonSet nodeSelector: node-role.kubernetes.io/master: "" image: tag: 0.23.0 rbac: create: true </code></pre> <p>With command:</p> <pre class="lang-sh prettyprint-override"><code>helm install --name nginx stable/nginx-ingress --values values.yaml --namespace ingress-nginx </code></pre> <p>When I deploy the ingress controller in the cluster, a service is created (e.g. nginx-ingress-controller for nginx). This service is of the type LoadBalancer and gets an external IP.</p> <p>When this external IP is assigned, the node that's linked to this external IP is lost (status Not Ready). However, when I check this node, it's still running, it's just cut off from the other nodes, it can't even ping them (No route found). When I remove the service (not the rest of the nginx helm chart), everything works and the Ingress works. I also tried installing nginx/traefik/kong without a LoadBalancer using NodePorts or External IPs on the service, but I get the same result. </p> <p>Does anyone recognize this behaviour? Why does the ingress still work, even when I remove the nginx-ingress-controller service?</p>
<p>After a long search, we finally found a working solution for this problem.</p> <p>As mentioned by @A_Suh, the pool of IPs that metallb uses, should contain IPs that are currently not used by one of the nodes in the cluster. By adding a new IP range that's also configured in the DHCP server, metallb can use ARP to link one of the IPs to one of the nodes. </p> <p>For example in my 5 node cluster (kube11-15): When metallb gets the range 10.4.5.200/31 and allocates 10.4.5.200 for my nginx-ingress-controller, 10.4.5.200 is linked to kube12. On ARP requests for 10.4.5.200, all 5 nodes respond with kube12 and trafic will be routed to this node.</p>
<p>I have a <strong><em>NodeJS</em></strong> app deployed as docker container and I am using <strong><em>Kubernetes</em></strong> for orchestration. The <em>load balancing</em> is done by Kubernetes by default.</p> <p>I want to implement caching for the app. </p> <p>My Question is: Is it possible to configure the Kubernetes load balancer Proxy to handle the caching also ?</p> <p>PS: If not then please suggest what is the Best Practice to handle caching in Kubernetes-Docker environment.</p> <p>Thanks</p>
<p>Proxy is not used for caching web pages, a cache server (Redis\Memcached) is used for caching web content. Proxy's job is to re-route requests and LoadBalancer has algorithms that it follows for traffic routing i.e. RoundRobin etc.</p> <p>For this, you have to add a cache server in your application stack in the form of deployment with persistence storage (depending upon your needs).</p>
<p>I have a <code>Prometheus</code> monitoring running on <code>Kubernetes</code> cluster. I want to receive SMS notification when my alerts firing. How should i set my number for receive SMS in <code>Alertmanager</code>?</p>
<p>Couple options coming from official docs: <a href="https://prometheus.io/docs/alerting/configuration/" rel="nofollow noreferrer">https://prometheus.io/docs/alerting/configuration/</a></p> <p>Option 1. If you have PagerDuty / VictorOps subscription use <a href="https://prometheus.io/docs/alerting/configuration/#pagerduty_config" rel="nofollow noreferrer">https://prometheus.io/docs/alerting/configuration/#pagerduty_config</a> receiver, and setup SMS rule inside the service. </p> <p>Option 2. Use a webhook receiver <a href="https://prometheus.io/docs/alerting/configuration/#webhook_config" rel="nofollow noreferrer">https://prometheus.io/docs/alerting/configuration/#webhook_config</a> Set it to send notification to AWS SNS <a href="https://docs.aws.amazon.com/sns/latest/dg/sns-http-https-endpoint-as-subscriber.html" rel="nofollow noreferrer">https://docs.aws.amazon.com/sns/latest/dg/sns-http-https-endpoint-as-subscriber.html</a>, then use AWS SNS to send an SMS. Or use any other webhook based SMS sender.</p>
<p>I'm trying run a cron job with Kubernetes. The job executes a program that performs some computation based on the job's scheduled start time. How can my program get access to this value during its execution?</p>
<p>Option 1 (easiest): Put the same value to job container environment variable. I assume you install with helm or similar mechanism, so it should be easy to reuse <code>schedule</code> variable in 2 places.</p> <p>Option 2: Use a combination of a <code>Role</code>, <code>RoleBinding</code> and <code>ServiceAccount</code>, then use <code>kubectl</code> / <code>language k8s client</code> to retrieve cronjob (you will need to know its name if there's multiple in a namespace) and get schedule from its parameters.</p> <p>Option 3: <a href="https://kubernetes.io/docs/tasks/inject-data-application/environment-variable-expose-pod-information/" rel="nofollow noreferrer">https://kubernetes.io/docs/tasks/inject-data-application/environment-variable-expose-pod-information/</a> This is a variation of 1 but using the resourceFieldRef. Not sure you can refer a cronjob resource tho :(</p>
<p>I have 2 line code in Dockerfile like below:</p> <pre><code>ENTRYPOINT ["/dockerstartup/dockerstartup.sh"] CMD ["--wait"] </code></pre> <p>Below is my code converted in Kubernetes yaml:</p> <pre><code>command: ["/dockerstartup/dockerstartup.sh"] args: ["--wait"] </code></pre> <p>Is it correct? Suggestion please.</p>
<p>As per <a href="https://kubernetes.io/docs/tasks/inject-data-application/define-command-argument-container/#define-a-command-and-arguments-when-you-create-a-pod" rel="nofollow noreferrer">Define a Command and Arguments for a Container</a> docs:</p> <blockquote> <p>The command and arguments that you define in the configuration file override the default command and arguments provided by the container image.</p> </blockquote> <p><a href="https://kubernetes.io/docs/tasks/inject-data-application/define-command-argument-container/#notes" rel="nofollow noreferrer">This</a> table summarizes the field names used by Docker and Kubernetes:</p> <pre><code>| Docker field name | K8s field name | |------------------:|:--------------:| | ENTRYPOINT | command | | CMD | args | </code></pre> <p><strong>So, for your example you should use the following:</strong> </p> <p><strong>Docker:</strong></p> <pre><code>ENTRYPOINT ["/dockerstartup/dockerstartup.sh"] CMD ["--wait"] </code></pre> <p><strong>Kubernetes:</strong></p> <pre><code>command: ["/dockerstartup/vnc_startup.sh"] args: ["--wait"] </code></pre>
<p>I am trying to use Kubernetes cluster with Kubernetes Helm chart for defining the Kubernetes services and deployment. I installed Helm client on one machine by using the following command,</p> <pre><code>sudo snap install helm --classic </code></pre> <p>And I accessed the Kubernetes cluster master node and trying to run <code>helm init</code> command. But when I am running I am getting the error,</p> <pre><code>helm: command not found </code></pre> <p>And when I am checking Kubernetes cluster installation, kubectl commands are properly running. </p> <p>For the "command not found", how can I solve my Kubernetes Helm Tiller initialization issue? </p>
<p>You need to run <code>helm init</code> on the same machine where you installed the helm client. That will install tiller on the Kubernetes cluster you have configured on your kubeconfig.</p> <p>There are two parts of Helm, the Client (what is called <code>helm</code>) and the server (called <code>tiller</code>).</p> <p><code>Tiller</code> runs (most of the times) on your Kubernetes cluster and manages the releases (the <code>charts</code> you deploy).</p> <p><code>Helm</code> runs on your local machine, CI/CD or where you want.</p> <p>Helm is also used for deploying <code>tiller</code> into your K8S cluster. This happens when you execute <code>helm init</code> and by default it'll create a kubernetes deployment called <code>tiller-deploy</code> on the <code>kube-system</code> namespace. This <code>tiller</code> deployment is what the <code>helm</code> client will use as a server.</p> <p>Helm discovers automatically where to install <code>tiller</code> by checking your kubeconfig (<code>~/.kube/config</code>) file and by default it will use the selected context there.</p> <p>You always use the <code>helm</code> cli from your local machine or CI/CD you don't use it from your Kubernetes master(s).</p> <p>Edit: This was true for Helm v2, now with Helm v3 tiller no longer exists, the deployment of the chart is done by the <code>helm</code> client itself and <code>helm init</code> is no longer necessary.</p> <p><a href="https://helm.sh/blog/helm-3-released/" rel="noreferrer">https://helm.sh/blog/helm-3-released/</a></p>
<p>I use Python kubernetes-client, and want to wait if the job is done:</p> <pre class="lang-py prettyprint-override"><code>api_instance.create_namespaced_job("default", body, pretty=True) </code></pre> <p>This call just makes a submit job, it will return the response even though the job is still running. How can I wait for the job to finish?</p>
<p>I found the solution. You can recognize the job is complete by watching the jobs and observing the events:</p> <pre class="lang-py prettyprint-override"><code>from kubernetes import client, config, watch config.load_kube_config() api_client = client.BatchV1Api() print("INFO: Waiting for event to come up...") w = watch.Watch() for event in w.stream(api_client.list_job_for_all_namespaces): o = event['object'] print(o) if (o.status.... = "Complete"): .... </code></pre>
<p>I am using this helm chart to configure rabbitmq on k8s cluster: <a href="https://github.com/helm/charts/tree/master/stable/rabbitmq" rel="nofollow noreferrer">https://github.com/helm/charts/tree/master/stable/rabbitmq</a></p> <p>How can I make cluster accessible thru public endpoint? Currently, I have a cluster with below configurations. I am able to access the management portal by given hostname (publicly endpoint, which is fine). But, when I checked inside the management portal cluster can be accessible by internal IP and/or hostname which is: <code>rabbit@rabbitmq-0.rabbitmq-headless.default.svc.cluster.local</code> and <code>rabbit@&lt;private_ip&gt;</code>. I want to make cluster public so all other services which are outside of VNET can connect to it.</p> <pre><code>helm install stable/rabbitmq --name rabbitmq \ --set rabbitmq.username=xxx \ --set rabbitmq.password=xxx \ --set rabbitmq.erlangCookie=secretcookie \ --set rbacEnabled=true \ --set ingress.enabled=true \ --set ingress.hostName=rabbitmq.xxx.com \ --set ingress.annotations."kubernetes\.io/ingress\.class"="nginx" \ --set resources.limits.memory="256Mi" \ --set resources.limits.cpu="100m" </code></pre>
<p>I was not tried with Helm but I was build and deploy to Kubernetes directly from <code>.yaml</code> configure file. So I only followed the <a href="https://github.com/helm/charts/blob/master/stable/rabbitmq/templates/svc.yaml" rel="nofollow noreferrer">Template of Helm</a></p> <p>For publish you RabbitMQ service out of cluster</p> <p>1, You need to have an external IP:</p> <p>If you using Google Cloud, run these commands:</p> <pre><code>gcloud compute addresses create rabbitmq-service-ip --region asia-southeast1 gcloud compute addresses describe rabbitmq-service-ip --region asia-southeast1 &gt;address: 35.240.xxx.xxx </code></pre> <p>Change <code>rabbitmq-service-ip</code> to the name you want, and change the <code>region</code> to your own.</p> <p>2, Configure <code>Helm</code> parameter</p> <p><code>service.type=LoadBalancer</code></p> <p><code>service.loadBalancerSourceRanges=35.240.xxx.xxx/32</code> # IP address you got from <code>gcloud</code></p> <p><code>service.port=5672</code></p> <p>3, Deploy and try to telnet to your RabbitMQ service</p> <pre><code>telnet 35.240.xxx.xxx 5672 Trying 35.240.xxx.xxx... Connected to 149.185.xxx.xxx.bc.googleusercontent.com. Escape character is '^]'. </code></pre> <p>Gotcha! It's worked</p> <p>FYI:</p> <p>Here is base template if you want to create <code>.yaml</code> and deploy without Helm</p> <p><code>service.yaml</code></p> <pre><code>--- apiVersion: v1 kind: Service metadata: name: rabbitmq labels: name: rabbitmq namespace: smart-office spec: type: LoadBalancer loadBalancerIP: 35.xxx.xxx.xx ports: # the port that this service should serve on - port: 5672 name: rabbitmq targetPort: 5672 nodePort: 32672 selector: name: rabbitmq </code></pre> <p><code>deployment.yaml</code></p> <pre><code>--- apiVersion: extensions/v1beta1 kind: Deployment metadata: name: rabbitmq labels: name: rabbitmq namespace: smart-office spec: replicas: 1 template: metadata: labels: name: rabbitmq annotations: prometheus.io/scrape: "false" spec: containers: - name: rabbitmq image: rabbitmq:3.6.8-management ports: - containerPort: 5672 name: rabbitmq securityContext: capabilities: drop: - all add: - CHOWN - SETGID - SETUID - DAC_OVERRIDE readOnlyRootFilesystem: true - name: rabbitmq-exporter image: kbudde/rabbitmq-exporter ports: - containerPort: 9090 name: exporter nodeSelector: beta.kubernetes.io/os: linux </code></pre> <p>Hope this help!</p>
<p>We are trying to monitor K8S with Grafana and Prometheus Operator. Most of the metrics are working as expected and I was able to see the dashboard with the right value, our system contain 10 nodes with overall 500 pods. Now when I restarted Prometheus all the data was <strong>deleted</strong>. I want it to be stored for two week.</p> <p>My question is, How can I define to Prometheus volume to keep the data for two weeks or 100GB DB.</p> <p>I found the following (we use <a href="https://github.com/coreos/prometheus-operator" rel="nofollow noreferrer">Prometheus</a> operator):</p> <p><a href="https://github.com/coreos/prometheus-operator/blob/master/Documentation/user-guides/storage.md" rel="nofollow noreferrer">https://github.com/coreos/prometheus-operator/blob/master/Documentation/user-guides/storage.md</a></p> <h3>This is the config of the Prometheus Operator</h3> <pre><code>apiVersion: apps/v1beta2 kind: Deployment metadata: labels: k8s-app: prometheus-operator name: prometheus-operator namespace: monitoring spec: replicas: 1 selector: matchLabels: k8s-app: prometheus-operator template: metadata: labels: k8s-app: prometheus-operator spec: containers: - args: - --kubelet-service=kube-system/kubelet - --logtostderr=true - --config-reloader-image=quay.io/coreos/configmap-reload:v0.0.1 - --prometheus-config-reloader=quay.io/coreos/prometheus-config-reloader:v0.29.0 image: quay.io/coreos/prometheus-operator:v0.29.0 name: prometheus-operator ports: - containerPort: 8080 name: http </code></pre> <h3>This is the config of the Prometheus</h3> <pre><code> apiVersion: monitoring.coreos.com/v1 kind: Prometheus metadata: name: prometheus namespace: monitoring labels: prometheus: prometheus spec: replica: 2 serviceAccountName: prometheus serviceMonitorNamespaceSelector: {} serviceMonitorSelector: matchLabels: role: observeable tolerations: - key: &quot;WorkGroup&quot; operator: &quot;Equal&quot; value: &quot;operator&quot; effect: &quot;NoSchedule&quot; - key: &quot;WorkGroup&quot; operator: &quot;Equal&quot; value: &quot;operator&quot; effect: &quot;NoExecute&quot; resources: limits: cpu: 8000m memory: 24000Mi requests: cpu: 6000m memory: 6000Mi storage: volumeClaimTemplate: spec: selector: matchLabels: app: prometheus resources: requests: storage: 100Gi </code></pre> <p><a href="https://github.com/coreos/prometheus-operator/blob/master/Documentation/user-guides/storage.md" rel="nofollow noreferrer">https://github.com/coreos/prometheus-operator/blob/master/Documentation/user-guides/storage.md</a></p> <p>We have file system (nfs), and the above storage config doesn't works, my questions are:</p> <ol> <li>What I miss here is how to config the <code>volume</code>, <code>server</code> , <code>path</code> in the following its under the <code>nfs</code> section? Where should I find this <code>/path/to/prom/db</code>? How can I refer to it? Should I create it somehow, or just provide the path?</li> </ol> <p>We have NFS configured in our system.</p> <ol start="2"> <li>How to combine it to Prometheus?</li> </ol> <p>As I don't have deep knowledge in <code>pvc</code> and <code>pv</code>, I've created the following (not sure regard those values, what is my server and what path should I provide)...</p> <pre class="lang-yaml prettyprint-override"><code>server: myServer path: &quot;/path/to/prom/db&quot; </code></pre> <p>What should I put there and how I make <strong>my Prometheus</strong> (i.e. the config I have provided in the question) to use it?</p> <pre class="lang-yaml prettyprint-override"><code>apiVersion: v1 kind: PersistentVolume metadata: name: prometheus namespace: monitoring labels: app: prometheus prometheus: prometheus spec: capacity: storage: 100Gi accessModes: - ReadWriteOnce # required nfs: server: myServer path: &quot;/path/to/prom/db&quot; </code></pre> <p>If there any other persistence volume other than <code>nfs</code> which I can use for my use-case? Please advice how.</p>
<p>I started working with the operator chart recently ,</p> <p>And managed to add persistency without defining pv and pvc.</p> <p>On the new chart configuration adding persistency is much easier than you describe just edit the file /helm/vector-chart/prometheus-operator-chart/<strong>values.yaml</strong> under prometheus.prometheusSpec:</p> <pre><code>storageSpec: volumeClaimTemplate: spec: storageClassName: prometheus accessModes: ["ReadWriteOnce"] resources: requests: storage: 10Gi selector: {} </code></pre> <p>And add this /helm/vector-chart/prometheus-operator-chart/templates/prometheus/<strong>storageClass.yaml</strong>:</p> <pre><code>kind: StorageClass apiVersion: storage.k8s.io/v1 metadata: name: prometheus provisioner: kubernetes.io/aws-ebs reclaimPolicy: Retain parameters: type: gp2 zones: "ap-southeast-2a, ap-southeast-2b, ap-southeast-2c" encrypted: "true" </code></pre> <p>This will automatically create you both <strong>pv</strong> and a <strong>pvc</strong> which will create an ebs in aws which will store all your data inside.</p>
<p>We have a fairly large kubernetes deployment on GKE, and we wanted to make our life a little easier by enabling auto-upgrades. The <a href="https://cloud.google.com/kubernetes-engine/docs/how-to/node-auto-upgrades" rel="nofollow noreferrer">documentation on the topic</a> tells you how to enable it, but not how it actually <strong>works</strong>.</p> <p>We enabled the feature on a test cluster, but no nodes were ever upgraded (although the UI kept nagging us that "upgrades are available").</p> <p>The docs say it would be updated to the "latest stable" version and that it occurs "at regular intervals at the discretion of the GKE team" - both of which is not terribly helpful.</p> <p>The UI always says: "Next auto-upgrade: Not scheduled"</p> <p>Has someone used this feature in production and can shed some light on what it'll actually do?</p> <h1>What I did:</h1> <ul> <li>I enabled the feature on the <em>nodepools</em> (<strong>not</strong> the cluster itself)</li> <li>I set up a maintenance window</li> <li>Cluster version was <code>1.11.7-gke.3</code></li> <li>Nodepools had version <code>1.11.5-gke.X</code></li> <li>The newest available version was <code>1.11.7-gke.6</code></li> </ul> <h1>What I expected:</h1> <ul> <li>The nodepool would be updated to either <code>1.11.7-gke.3</code> (the default cluster version) or <code>1.11.7-gke.6</code> (the most recent version)</li> <li>The update would happen in the next maintenance window</li> <li>The update would otherwise work like a "manual" update</li> </ul> <h1>What actually happened:</h1> <ul> <li>Nothing</li> <li>The nodepools remained on <code>1.11.5-gke.X</code> for more than a week</li> </ul> <h1>My question</h1> <ul> <li>Is the nodepool version supposed to update?</li> <li>If so, at what time?</li> <li>If so, to what version?</li> </ul>
<p>I'll finally answer this myself. The auto-upgrade <em>does</em> work, though it took several days to a week until the version was upgraded.</p> <p>There is no indication of the planned upgrade date, or any feedback other than the version updating.</p> <p>It will upgrade to the current master version of the cluster.</p> <p><strong>Addition:</strong> It still doesn't work reliably, and still no way to debug if it doesn't. One information I got was that the mechanism does not work if you initially provided a specific version for the node pool. As it is not possible to deduce the inner workings of the autoupdates, we had to resort to manually checking the status again.</p>
<p>I'm setting up SCDF on kubernetes and i want to run scheduled task's but i am receiving NullPointerException, has anybody experienced such problem?</p> <p>I am using:</p> <ul> <li>Server: springcloud/spring-cloud-dataflow-server:2.0.2.RELEASE</li> <li>Skipper: springcloud/spring-cloud-skipper-server:2.0.1.RELEASE</li> <li>MySQL: mysql:5.6</li> <li>Kafka: wurstmeister/kafka:2.11-0.11.0.3</li> </ul> <p>I am able to run task manually using curl or UI.</p> <p>Task definition is timestamp: uri=docker:springcloudtask/timestamp-task:2.1.0.RC1</p> <p>I have connected to pod and tried to create scheduler using REST API (same result with UI):</p> <pre><code>curl -vL 'http://localhost:80/tasks/schedules' -i -X POST -d 'scheduleName=myschedule&amp;taskDefinitionName=test&amp;properties=scheduler.cron.expression%3D00+22+17+%3F+*' </code></pre> <p>And received response:</p> <pre><code>* Trying 127.0.0.1... * TCP_NODELAY set * Connected to localhost (127.0.0.1) port 80 (#0) &gt; POST /tasks/schedules HTTP/1.1 &gt; Host: localhost &gt; User-Agent: curl/7.58.0 &gt; Accept: */* &gt; Content-Length: 101 &gt; Content-Type: application/x-www-form-urlencoded &gt; * upload completely sent off: 101 out of 101 bytes &lt; HTTP/1.1 500 HTTP/1.1 500 &lt; Content-Type: application/json;charset=UTF-8 Content-Type: application/json;charset=UTF-8 &lt; Transfer-Encoding: chunked Transfer-Encoding: chunked &lt; Date: Tue, 16 Apr 2019 09:45:21 GMT Date: Tue, 16 Apr 2019 09:45:21 GMT &lt; Connection: close Connection: close &lt; * Closing connection 0 [{"logref":"NullPointerException","message":"NullPointerException"}] </code></pre> <p>Server shows error log:</p> <pre><code>2019-04-16 09:45:21.856 DEBUG 1 --- [p-nio-80-exec-9] o.hibernate.internal.util.EntityPrinter : org.springframework.cloud.dataflow.core.AppRegistration{objectVersion=0, name=timestamp, id=159, type=task, uri=docker:springcloudtask/timestamp-task:2.1.0.RC1, version=2.1.0.RC1, defaultVersion=true, metadataUri=maven://org.springframework.cloud.task.app:timestamp-task:jar:metadata:2.1.0.RC1} 2019-04-16 09:45:21.856 DEBUG 1 --- [p-nio-80-exec-9] o.hibernate.internal.util.EntityPrinter : org.springframework.cloud.dataflow.core.TaskDefinition{taskName=test, dslText=timestamp} 2019-04-16 09:45:21.857 DEBUG 1 --- [p-nio-80-exec-9] o.s.orm.jpa.JpaTransactionManager : Not closing pre-bound JPA EntityManager after transaction 2019-04-16 09:45:21.880 ERROR 1 --- [p-nio-80-exec-9] o.s.c.d.s.c.RestControllerAdvice : Caught exception while handling a request java.lang.NullPointerException: null at org.springframework.cloud.scheduler.spi.kubernetes.KubernetesScheduler.getExceptionMessageForField(KubernetesScheduler.java:149) at org.springframework.cloud.scheduler.spi.kubernetes.KubernetesScheduler.schedule(KubernetesScheduler.java:73) at org.springframework.cloud.dataflow.server.service.impl.DefaultSchedulerService.schedule(DefaultSchedulerService.java:151) at org.springframework.cloud.dataflow.server.controller.TaskSchedulerController.save(TaskSchedulerController.java:141) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:189) at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:138) at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:102) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:895) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:800) at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87) at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1038) at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:942) at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1005) at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:908) at javax.servlet.http.HttpServlet.service(HttpServlet.java:660) at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:882) at javax.servlet.http.HttpServlet.service(HttpServlet.java:741) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) at org.springframework.boot.actuate.web.trace.servlet.HttpTraceFilter.doFilterInternal(HttpTraceFilter.java:90) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:99) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:92) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) at org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:93) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) at org.springframework.boot.actuate.metrics.web.servlet.WebMvcMetricsFilter.filterAndRecordMetrics(WebMvcMetricsFilter.java:117) at org.springframework.boot.actuate.metrics.web.servlet.WebMvcMetricsFilter.doFilterInternal(WebMvcMetricsFilter.java:106) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:200) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:200) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:490) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:139) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:74) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343) at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:408) at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66) at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:834) at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1415) at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) at java.lang.Thread.run(Thread.java:748) </code></pre> <p>Has anybody experienced such problem?</p>
<p>I attempted to try a similar use-case with the out-of-the-box <code>timestamp</code> task application, and I notice everything working as expected.</p> <p><strong>Task Definition:</strong></p> <blockquote> <p>dataflow:>task create schtask --definition "timestamp"</p> </blockquote> <p><strong>Schedule via Dashboard:</strong></p> <p><a href="https://i.stack.imgur.com/7QC2f.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/7QC2f.png" alt="enter image description here"></a></p> <p><strong>Schedule via Cron:</strong></p> <blockquote> <p>curl '<a href="http://localhost:80/tasks/schedules" rel="nofollow noreferrer">http://localhost:80/tasks/schedules</a>' -i -X POST \ -d 'scheduleName=sabby-sch2&amp;taskDefinitionName=schtask&amp;properties=scheduler.cron.expression%3D*%2F1%20*%20*%20*%20*&amp;arguments=--foo%3Dbar'</p> </blockquote> <p><strong>CronJobs</strong></p> <pre><code>&gt; k get cronjob NAME SCHEDULE SUSPEND ACTIVE LAST SCHEDULE AGE cronjob.batch/sabby-sch1 */1 * * * * False 1 19s 103s cronjob.batch/sabby-sch2 */1 * * * * False 1 19s 75s </code></pre> <p><strong>Results</strong></p> <pre><code>NAME READY STATUS RESTARTS AGE pod/mysql-f5986679b-ftlz2 1/1 Running 0 21h pod/rabbitmq-7489f8c586-8xq6x 1/1 Running 0 21h pod/sabby-sch1-1555432020-rwwcf 0/1 Completed 0 70s pod/sabby-sch1-1555432080-6wcjb 0/1 Completed 0 10s pod/sabby-sch2-1555432080-k2pwm 0/1 Completed 0 10s pod/scdf-server-77b6dbc46c-d9f57 1/1 Running 0 21h pod/skipper-7ccbbf95dd-94l5j 1/1 Running 0 21h </code></pre> <p>Maybe there's something to the cron-expression in use. Perhaps you could repeat the same cron-expression from my example to verify it on your end?</p>
<p>I'm creating a minimal custom ingress controller in dotnet core. I can access the k8s ingress resources by querying the api server, but polling doesn't seem like a good solution to update ingress rules since in my use case they aren't changed that often but if they change, the changes should be applied right away.</p> <p>Is there a way to receive notifications on ingress resource changes? Like registering a webhook or something along the lines? Or is polling the only way?</p>
<p>What dotnet core library are you using? There is a <code>Watch</code> on every resource in the golang client (e.g. <a href="https://godoc.org/k8s.io/client-go/kubernetes/typed/extensions/v1beta1#IngressInterface" rel="nofollow noreferrer">ingress</a>). You can find our more about this under "Setup a Watch" section in <a href="https://medium.com/programming-kubernetes/building-stuff-with-the-kubernetes-api-part-4-using-go-b1d0e3c1c899" rel="nofollow noreferrer">this article</a></p> <p>It looks like there is a <a href="https://github.com/kubernetes-client/csharp/blob/master/examples/watch/Program.cs" rel="nofollow noreferrer">Watch example in the kubernetes-client/csharp</a> as well.</p>
<p>How can I apply a PSP (PodSecurityPolicy) only for the <code>kube-system</code> namespace and another PSP for all other namespaces?</p>
<p>As we can read in the Kubernetes documentation about <a href="https://kubernetes.io/docs/concepts/policy/pod-security-policy/" rel="nofollow noreferrer">Pod Security Policies</a>.</p> <blockquote> <p>A <em>Pod Security Policy</em> is a cluster-level resource that controls security sensitive aspects of the pod specification. The <code>PodSecurityPolicy</code> objects define a set of conditions that a pod must run with in order to be accepted into the system, as well as defaults for the related fields.</p> </blockquote> <p>You should use <a href="https://kubernetes.io/docs/reference/access-authn-authz/rbac/" rel="nofollow noreferrer">RBAC</a> and setup <code>Role</code> which will use desired <code>PSP</code>.</p> <blockquote> <p>If a <code>RoleBinding</code> (not a <code>ClusterRoleBinding</code>) is used, it will only grant usage for pods being run in the same namespace as the binding. This can be paired with system groups to grant access to all pods run in the namespace:</p> </blockquote> <pre><code># Authorize all service accounts in a namespace: - kind: Group apiGroup: rbac.authorization.k8s.io name: system:serviceaccounts # Or equivalently, all authenticated users in a namespace: - kind: Group apiGroup: rbac.authorization.k8s.io name: system:authenticated </code></pre> <p>You should also check out <a href="https://cloud.google.com/kubernetes-engine/docs/how-to/pod-security-policies" rel="nofollow noreferrer">Using PodSecurityPolicies</a> and <a href="https://medium.com/coryodaniel/kubernetes-assigning-pod-security-policies-with-rbac-2ad2e847c754" rel="nofollow noreferrer">Kubernetes: Assigning Pod Security Policies with RBAC</a>.</p> <p>Hope this helps.</p>
<p>When join node : <code>sudo kubeadm join 172.16.7.101:6443 --token 4mya3g.duoa5xxuxin0l6j3 --discovery-token-ca-cert-hash sha256:bba76ac7a207923e8cae0c466dac166500a8e0db43fb15ad9018b615bdbabeb2</code></p> <p>The outputs:</p> <pre><code>[preflight] Running pre-flight checks [WARNING IsDockerSystemdCheck]: detected "cgroupfs" as the Docker cgroup driver. The recommended driver is "systemd". Please follow the guide at https://kubernetes.io/docs/setup/cri/ [preflight] Reading configuration from the cluster... [preflight] FYI: You can look at this config file with 'kubectl -n kube-system get cm kubeadm-config -oyaml' [kubelet-start] Downloading configuration for the kubelet from the "kubelet-config-1.14" ConfigMap in the kube-system namespace [kubelet-start] Writing kubelet configuration to file "/var/lib/kubelet/config.yaml" [kubelet-start] Writing kubelet environment file with flags to file "/var/lib/kubelet/kubeadm-flags.env" [kubelet-start] Activating the kubelet service [kubelet-start] Waiting for the kubelet to perform the TLS Bootstrap... [kubelet-check] Initial timeout of 40s passed. error execution phase kubelet-start: error uploading crisocket: timed out waiting for the condition </code></pre> <p>And <code>systemctl status kubelet</code>:</p> <pre><code>node@node:~$ sudo systemctl status kubelet ● kubelet.service - kubelet: The Kubernetes Node Agent Loaded: loaded (/lib/systemd/system/kubelet.service; enabled; vendor preset: enabled) Drop-In: /etc/systemd/system/kubelet.service.d └─10-kubeadm.conf Active: active (running) since Wed 2019-04-17 06:20:56 UTC; 12min ago Docs: https://kubernetes.io/docs/home/ Main PID: 26716 (kubelet) Tasks: 16 (limit: 1111) CGroup: /system.slice/kubelet.service └─26716 /usr/bin/kubelet --bootstrap-kubeconfig=/etc/kubernetes/bootstrap-kubelet.conf --kubeconfig=/etc/kubernetes/kubelet.conf --config=/var/lib/kubelet/config.yaml - Apr 17 06:33:38 node kubelet[26716]: E0417 06:33:38.022384 26716 kubelet.go:2244] node "node" not found Apr 17 06:33:38 node kubelet[26716]: E0417 06:33:38.073969 26716 reflector.go:126] k8s.io/kubernetes/pkg/kubelet/kubelet.go:451: Failed to list *v1.Node: Unauthorized Apr 17 06:33:38 node kubelet[26716]: E0417 06:33:38.122820 26716 kubelet.go:2244] node "node" not found Apr 17 06:33:38 node kubelet[26716]: E0417 06:33:38.228838 26716 kubelet.go:2244] node "node" not found Apr 17 06:33:38 node kubelet[26716]: E0417 06:33:38.273153 26716 reflector.go:126] k8s.io/kubernetes/pkg/kubelet/kubelet.go:442: Failed to list *v1.Service: Unauthorized Apr 17 06:33:38 node kubelet[26716]: E0417 06:33:38.330578 26716 kubelet.go:2244] node "node" not found Apr 17 06:33:38 node kubelet[26716]: E0417 06:33:38.431114 26716 kubelet.go:2244] node "node" not found Apr 17 06:33:38 node kubelet[26716]: E0417 06:33:38.473501 26716 reflector.go:126] k8s.io/kubernetes/pkg/kubelet/config/apiserver.go:47: Failed to list *v1.Pod: Unauthorized Apr 17 06:33:38 node kubelet[26716]: E0417 06:33:38.531294 26716 kubelet.go:2244] node "node" not found Apr 17 06:33:38 node kubelet[26716]: E0417 06:33:38.632347 26716 kubelet.go:2244] node "node" not found </code></pre> <p>To <code>Unauthorized</code> I checked at master with <code>kubeadm token list</code>, token is valid. So what's the problem? Thanks a lot.</p>
<p>Please verify pre and post installation steps <a href="https://kubernetes.io/docs/setup/independent/install-kubeadm/" rel="nofollow noreferrer">here</a>:<br/> Please verify also the status of your services enabled and running, docker env.</p> <pre><code> sudo systemctl enable docker sudo systemctl enable kubelet systemctl daemon-reload systemctl restart docker systemctl restart kubelet </code></pre> <p>Are the results the same if you run init command with <strong>--ignore-preflight-errors=all</strong><br/> For more details please use also "<strong>journalctl -u kubelet</strong>"<br /> Having more details from your logs, please take a look at "<em>github - kubeadm/issues</em>" <a href="https://github.com/kubernetes/kubeadm/issues" rel="nofollow noreferrer">here</a>:<br /> Please provide more details about you env in order to recreate this issue and share with your additional findings.</p> <p>Could you please perform another test and run <strong>kubeadm init</strong> on your worker node, in the same way as on the first node (in short please create second master node) just to verify your working env.</p>
<p>I need to create a Cron jobs at K8S.<br> some jobs runs every minute , some of them every 5 minutes (24/7)</p> <p>This jobs need to run rest call (get) to some components and to check the availability and if something is wrong (post) a rest call to other system</p> <p>To handle this task I currently see two approaches </p> <ol> <li><strong>Create k8s cronjob</strong> - which is <strong>native</strong> k8s CRD and use <code>shell script</code> for it, <a href="https://kubernetes.io/docs/concepts/workloads/controllers/cron-jobs/" rel="nofollow noreferrer">https://kubernetes.io/docs/concepts/workloads/controllers/cron-jobs/</a></li> </ol> <p><strong>PROS</strong> is using K8S native way to handle such issue</p> <p><strong>CONS</strong> - very hard to debug, logs debug etc </p> <ol start="2"> <li><strong>Create k8s job/cronjob</strong> - which execute run a <strong>Golang program</strong> that will do use following library as cronjob</li> </ol> <p><strong>PROS</strong> - debug , logging etc , <a href="https://github.com/robfig/cron" rel="nofollow noreferrer">https://github.com/robfig/cron</a></p> <p><strong>CONS</strong> - create some abstraction …</p> <p>Any suggestion, recommendation which is better approach to use If I need a full control on those jobs</p>
<p>I'd approach this problem in several steps.</p> <p>First, write the program that does the REST calls, checks the result, maybe posts the alert, and exits. You can write this program in whatever language or toolkit you feel like. If you're comfortable in Go, great; I might pick Python myself; it'd be possible as a shell script, but probably more awkward than many alternatives. <strong>Build this program completely independently of Kubernetes.</strong> Test it as much as you need to convince yourself that it does what you want.</p> <p>Once you've made the REST polling program work, and only then, build it into a Docker image; push it to a registry; and create a <a href="https://kubernetes.io/docs/concepts/workloads/controllers/cron-jobs/" rel="nofollow noreferrer">CronJob</a> Kubernetes resource that runs it on a schedule.</p> <p>Given how you've described the task, I wouldn't write a specialized program just to replicate Kubernetes' built-in scheduled-task runner. You could; I'd develop it the same way as above but use a Deployment instead of a CronJob; but probably the CronJob path is both simpler and more reliable.</p>
<p>I'm checking Argo and I would like to grant a specific namespace for a user (or multiple users) to use Argo workflow (and let the users access features such as artifacts, outputs, access to secrets). I have set up a user and created a namespace (testing in minikube). How should I bind roles for the user, namespace and Argo workflow? </p> <p>Here is role and rolebinding yaml files I have now. </p> <pre><code>kind: Role apiVersion: rbac.authorization.k8s.io/v1 metadata: namespace: default name: pod-reader rules: - apiGroups: [“”] resources: [“pods”] verbs: [“get”, “watch”, “list”] </code></pre> <pre><code>kind: RoleBinding apiVersion: rbac.authorization.k8s.io/v1 metadata: name: read-pods namespace: default subjects: - kind: User name: user1 apiGroup: rbac.authorization.k8s.io roleRef: kind: Role name: pod-reader apiGroup: rbac.authorization.k8s.io </code></pre> <p>Thank you!</p>
<p>Great guide for you to have a step by step explanation how to create namespace, user and grant permissions to work with this user only in chosen namespace:</p> <p><a href="https://docs.bitnami.com/kubernetes/how-to/configure-rbac-in-your-kubernetes-cluster/#use-case-1-create-user-with-limited-namespace-access" rel="nofollow noreferrer">https://docs.bitnami.com/kubernetes/how-to/configure-rbac-in-your-kubernetes-cluster/#use-case-1-create-user-with-limited-namespace-access</a></p> <p><a href="https://docs.bitnami.com/kubernetes/how-to/configure-rbac-in-your-kubernetes-cluster/#step-1-create-the-office-namespace" rel="nofollow noreferrer">Step 1: Create the namespace</a></p> <p><a href="https://docs.bitnami.com/kubernetes/how-to/configure-rbac-in-your-kubernetes-cluster/#step-2-create-the-user-credentials" rel="nofollow noreferrer">Step 2: Create the credentials</a></p> <p><a href="https://docs.bitnami.com/kubernetes/how-to/configure-rbac-in-your-kubernetes-cluster/#step-3-create-the-role-for-managing-deployments" rel="nofollow noreferrer">Step 3: Create the role for managing deployments</a></p> <p><a href="https://docs.bitnami.com/kubernetes/how-to/configure-rbac-in-your-kubernetes-cluster/#step-4-bind-the-role-to-the-employee-user" rel="nofollow noreferrer">Step 4: Bind the role to the user</a></p> <p><a href="https://docs.bitnami.com/kubernetes/how-to/configure-rbac-in-your-kubernetes-cluster/#step-5-test-the-rbac-rule" rel="nofollow noreferrer">Step 5: Test the RBAC rule</a></p>
<p>Im struggling to get Traefik working on K8s with ACME enabled. I want to store the certs as suggested on a persistantVolume. This for the fact that requesting certs is rateLimited and in case of pod restarts the cert would get lost. Below is my full config that is used for stable/traefik (helm chart) and installed in Azure AKS.</p> <p>There are a issue that do not seem to work (or im just doing it wrong ofcourse). </p> <p><strong>pod has unbound immediate PersistentVolumeClaims</strong></p> <p>This is the initial error that i receive when booting up the pods. The weird thing is that the PersistantVolumeClaim is actually there and ready. When i change the volume itself in my Azure portal it also says its mount to my server</p> <pre><code>traefik-acme Namespace: default pv.kubernetes.io/bind-completed: yes pv.kubernetes.io/bound-by-controller: yes volume.beta.kubernetes.io/storage-provisioner: kubernetes.io/azure-disk Creation Time: 2019-04-16T09:55 UTC Status: Bound Volume: pvc-b673da74-602d-11e9-a537-9275388 Access modes: ReadWriteOnce Storage class: default </code></pre> <p>Also the storageClass itself is active:</p> <pre><code>$ kubectl get sc --all-namespaces NAME PROVISIONER AGE default (default) kubernetes.io/azure-disk 4d managed-premium kubernetes.io/azure-disk 4d </code></pre> <p>When i then wait a little longer i receive below error: <code>Unable to mount volumes for pod "traefik-d65fcbc8b-lkzsh_default(b68c8aa3-602d-11e9-a537-92753888c74b)": timeout expired waiting for volumes to attach or mount for pod "default"/"traefik-d65fcbc8b-lkzsh". list of unmounted volumes=[acme]. list of unattached volumes=[config acme default-token-p2lgf]</code></p> <p>Here the full K8s event trace:</p> <pre><code>pod has unbound immediate PersistentVolumeClaims default-scheduler 2019-04-16T09:55 UTC Successfully assigned default/traefik-d65fcbc8b-lkzsh to aks-default-22301976-0 default-scheduler 2019-04-16T09:55 UTC Unable to mount volumes for pod "traefik-d65fcbc8b-lkzsh_default(b68c8aa3-602d-11e9-a537-92753888c74b)": timeout expired waiting for volumes to attach or mount for pod "default"/"traefik-d65fcbc8b-lkzsh". list of unmounted volumes=[acme]. list of unattached volumes=[config acme default-token-p2lgf] kubelet aks-default-22301976-0 2019-04-16T09:57 UTC AttachVolume.Attach succeeded for volume "pvc-b673da74-602d-11e9-a537-92753888c74b" attachdetach-controller 2019-04-16T09:58 UTC Container image "traefik:1.7.9" already present on machine kubelet aks-default-22301976-0 2019-04-16T10:01 UTC Created container kubelet aks-default-22301976-0 2019-04-16T10:00 UTC Started container kubelet aks-default-22301976-0 2019-04-16T10:00 UTC Back-off restarting failed container kubelet aks-default-22301976-0 2019-04-16T10:02 UTC </code></pre> <h2>Install</h2> <p>Installing the helm chart of Traefik done with:</p> <p><code>helm install -f values.yaml stable/traefik --name traefik</code></p> <p>Below is the full <code>values.yaml</code> used to install the chart</p> <pre><code>## Default values for Traefik image: traefik imageTag: 1.7.9 testFramework: image: "dduportal/bats" tag: "0.4.0" ## can switch the service type to NodePort if required serviceType: LoadBalancer # loadBalancerIP: "" # loadBalancerSourceRanges: [] whiteListSourceRange: [] externalTrafficPolicy: Cluster replicas: 1 # startupArguments: # - "--ping" # - "--ping.entrypoint=http" podDisruptionBudget: {} # maxUnavailable: 1 # minAvailable: 2 # priorityClassName: "" # rootCAs: [] resources: {} debug: enabled: false deploymentStrategy: {} # rollingUpdate: # maxSurge: 1 # maxUnavailable: 0 # type: RollingUpdate securityContext: {} env: {} nodeSelector: {} # key: value affinity: {} # key: value tolerations: [] # - key: "key" # operator: "Equal|Exists" # value: "value" # effect: "NoSchedule|PreferNoSchedule|NoExecute(1.6 only)" ## Kubernetes ingress filters # kubernetes: # endpoint: # namespaces: # - default # labelSelector: # ingressClass: # ingressEndpoint: # hostname: "localhost" # ip: "127.0.0.1" # publishedService: "namespace/servicename" # useDefaultPublishedService: false proxyProtocol: enabled: false # trustedIPs is required when enabled trustedIPs: [] # - 10.0.0.0/8 forwardedHeaders: enabled: false # trustedIPs is required when enabled trustedIPs: [] # - 10.0.0.0/8 ## Add arbitrary ConfigMaps to deployment ## Will be mounted to /configs/, i.e. myconfig.json would ## be mounted to /configs/myconfig.json. configFiles: {} # myconfig.json: | # filecontents... ## Add arbitrary Secrets to deployment ## Will be mounted to /secrets/, i.e. file.name would ## be mounted to /secrets/mysecret.txt. ## The contents will be base64 encoded when added secretFiles: {} # mysecret.txt: | # filecontents... ssl: enabled: false enforced: false permanentRedirect: false upstream: false insecureSkipVerify: false generateTLS: false # defaultCN: "example.com" # or *.example.com defaultSANList: [] # - example.com # - test1.example.com defaultIPList: [] # - 1.2.3.4 # cipherSuites: [] # https://docs.traefik.io/configuration/entrypoints/#specify-minimum-tls-version # tlsMinVersion: VersionTLS12 defaultCert: LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUVtekNDQTRPZ0F3SUJBZ0lKQUpBR1FsTW1DMGt5TUEwR0NTcUdTSWIzRFFFQkJRVUFNSUdQTVFzd0NRWUQKVlFRR0V3SlZVekVSTUE4R0ExVUVDQk1JUTI5c2IzSmhaRzh4RURBT0JnTlZCQWNUQjBKdmRXeGtaWEl4RkRBUwpCZ05WQkFvVEMwVjRZVzF3YkdWRGIzSndNUXN3Q1FZRFZRUUxFd0pKVkRFV01CUUdBMVVFQXhRTktpNWxlR0Z0CmNHeGxMbU52YlRFZ01CNEdDU3FHU0liM0RRRUpBUllSWVdSdGFXNUFaWGhoYlhCc1pTNWpiMjB3SGhjTk1UWXgKTURJME1qRXdPVFV5V2hjTk1UY3hNREkwTWpFd09UVXlXakNCanpFTE1Ba0dBMVVFQmhNQ1ZWTXhFVEFQQmdOVgpCQWdUQ0VOdmJHOXlZV1J2TVJBd0RnWURWUVFIRXdkQ2IzVnNaR1Z5TVJRd0VnWURWUVFLRXd0RmVHRnRjR3hsClEyOXljREVMTUFrR0ExVUVDeE1DU1ZReEZqQVVCZ05WQkFNVURTb3VaWGhoYlhCc1pTNWpiMjB4SURBZUJna3EKaGtpRzl3MEJDUUVXRVdGa2JXbHVRR1Y0WVcxd2JHVXVZMjl0TUlJQklqQU5CZ2txaGtpRzl3MEJBUUVGQUFPQwpBUThBTUlJQkNnS0NBUUVBdHVKOW13dzlCYXA2SDROdUhYTFB6d1NVZFppNGJyYTFkN1ZiRUJaWWZDSStZNjRDCjJ1dThwdTNhVTVzYXVNYkQ5N2pRYW95VzZHOThPUHJlV284b3lmbmRJY3RFcmxueGpxelUyVVRWN3FEVHk0bkEKNU9aZW9SZUxmZXFSeGxsSjE0VmlhNVFkZ3l3R0xoRTlqZy9jN2U0WUp6bmg5S1dZMnFjVnhEdUdEM2llaHNEbgphTnpWNFdGOWNJZm1zOHp3UHZPTk5MZnNBbXc3dUhUKzNiSzEzSUloeDI3ZmV2cXVWcENzNDFQNnBzdStWTG4yCjVIRHk0MXRoQkN3T0wrTithbGJ0ZktTcXM3TEFzM25RTjFsdHpITHZ5MGE1RGhkakpUd2tQclQrVXhwb0tCOUgKNFpZazErRUR0N09QbGh5bzM3NDFRaE4vSkNZK2RKbkFMQnNValFJREFRQUJvNEgzTUlIME1CMEdBMVVkRGdRVwpCQlJwZVc1dFhMdHh3TXJvQXM5d2RNbTUzVVVJTERDQnhBWURWUjBqQklHOE1JRzVnQlJwZVc1dFhMdHh3TXJvCkFzOXdkTW01M1VVSUxLR0JsYVNCa2pDQmp6RUxNQWtHQTFVRUJoTUNWVk14RVRBUEJnTlZCQWdUQ0VOdmJHOXkKWVdSdk1SQXdEZ1lEVlFRSEV3ZENiM1ZzWkdWeU1SUXdFZ1lEVlFRS0V3dEZlR0Z0Y0d4bFEyOXljREVMTUFrRwpBMVVFQ3hNQ1NWUXhGakFVQmdOVkJBTVVEU291WlhoaGJYQnNaUzVqYjIweElEQWVCZ2txaGtpRzl3MEJDUUVXCkVXRmtiV2x1UUdWNFlXMXdiR1V1WTI5dGdna0FrQVpDVXlZTFNUSXdEQVlEVlIwVEJBVXdBd0VCL3pBTkJna3EKaGtpRzl3MEJBUVVGQUFPQ0FRRUFjR1hNZms4TlpzQit0OUtCemwxRmw2eUlqRWtqSE8wUFZVbEVjU0QyQjRiNwpQeG5NT2pkbWdQcmF1SGI5dW5YRWFMN3p5QXFhRDZ0YlhXVTZSeENBbWdMYWpWSk5aSE93NDVOMGhyRGtXZ0I4CkV2WnRRNTZhbW13QzFxSWhBaUE2MzkwRDNDc2V4N2dMNm5KbzdrYnIxWVdVRzN6SXZveGR6OFlEclpOZVdLTEQKcFJ2V2VuMGxNYnBqSVJQNFhac25DNDVDOWdWWGRoM0xSZTErd3lRcTZoOVFQaWxveG1ENk5wRTlpbVRPbjJBNQovYkozVktJekFNdWRlVTZrcHlZbEpCemRHMXVhSFRqUU9Xb3NHaXdlQ0tWVVhGNlV0aXNWZGRyeFF0aDZFTnlXCnZJRnFhWng4NCtEbFNDYzkzeWZrL0dsQnQrU0tHNDZ6RUhNQjlocVBiQT09Ci0tLS0tRU5EIENFUlRJRklDQVRFLS0tLS0K defaultKey: LS0tLS1CRUdJTiBSU0EgUFJJVkFURSBLRVktLS0tLQpNSUlFb3dJQkFBS0NBUUVBdHVKOW13dzlCYXA2SDROdUhYTFB6d1NVZFppNGJyYTFkN1ZiRUJaWWZDSStZNjRDCjJ1dThwdTNhVTVzYXVNYkQ5N2pRYW95VzZHOThPUHJlV284b3lmbmRJY3RFcmxueGpxelUyVVRWN3FEVHk0bkEKNU9aZW9SZUxmZXFSeGxsSjE0VmlhNVFkZ3l3R0xoRTlqZy9jN2U0WUp6bmg5S1dZMnFjVnhEdUdEM2llaHNEbgphTnpWNFdGOWNJZm1zOHp3UHZPTk5MZnNBbXc3dUhUKzNiSzEzSUloeDI3ZmV2cXVWcENzNDFQNnBzdStWTG4yCjVIRHk0MXRoQkN3T0wrTithbGJ0ZktTcXM3TEFzM25RTjFsdHpITHZ5MGE1RGhkakpUd2tQclQrVXhwb0tCOUgKNFpZazErRUR0N09QbGh5bzM3NDFRaE4vSkNZK2RKbkFMQnNValFJREFRQUJBb0lCQUhrTHhka0dxNmtCWWQxVAp6MkU4YWFENnhneGpyY2JSdGFCcTc3L2hHbVhuQUdaWGVWcE81MG1SYW8wbHZ2VUgwaE0zUnZNTzVKOHBrdzNmCnRhWTQxT1dDTk1PMlYxb1MvQmZUK3Zsblh6V1hTemVQa0pXd2lIZVZMdVdEaVVMQVBHaWl4emF2RFMyUnlQRmEKeGVRdVNhdE5pTDBGeWJGMG5Zd3pST3ZoL2VSa2NKVnJRZlZudU1melFkOGgyMzZlb1UxU3B6UnhSNklubCs5UApNc1R2Wm5OQmY5d0FWcFo5c1NMMnB1V1g3SGNSMlVnem5oMDNZWUZJdGtDZndtbitEbEdva09YWHBVM282aWY5ClRIenBleHdubVJWSmFnRG85bTlQd2t4QXowOW80cXExdHJoU1g1U2p1K0xyNFJvOHg5bytXdUF1VnVwb0lHd0wKMWVseERFRUNnWUVBNzVaWGp1enNJR09PMkY5TStyYVFQcXMrRHZ2REpzQ3gyZnRudk1WWVJKcVliaGt6YnpsVQowSHBCVnk3NmE3WmF6Umxhd3RGZ3ljMlpyQThpM0F3K3J6d1pQclNJeWNieC9nUVduRzZlbFF1Y0FFVWdXODRNCkdSbXhKUGlmOGRQNUxsZXdRalFjUFJwZVoxMzlYODJreGRSSEdma1pscHlXQnFLajBTWExRSEVDZ1lFQXcybkEKbUVXdWQzZFJvam5zbnFOYjBlYXdFUFQrbzBjZ2RyaENQOTZQK1pEekNhcURUblZKV21PeWVxRlk1eVdSSEZOLwpzbEhXU2lTRUFjRXRYZys5aGlMc0RXdHVPdzhUZzYyN2VrOEh1UUtMb2tWWEFUWG1NZG9xOWRyQW9INU5hV2lECmRSY3dEU2EvamhIN3RZV1hKZDA4VkpUNlJJdU8vMVZpbDBtbEk5MENnWUVBb2lsNkhnMFNUV0hWWDNJeG9raEwKSFgrK1ExbjRYcFJ5VEg0eldydWY0TjlhYUxxNTY0QThmZGNodnFiWGJHeEN6U3RxR1E2cW1peUU1TVpoNjlxRgoyd21zZEpxeE14RnEzV2xhL0lxSzM0cTZEaHk3cUNld1hKVGRKNDc0Z3kvY0twZkRmeXZTS1RGZDBFejNvQTZLCmhqUUY0L2lNYnpxUStQREFQR0YrVHFFQ2dZQmQ1YnZncjJMMURzV1FJU3M4MHh3MDBSZDdIbTRaQVAxdGJuNk8KK0IvUWVNRC92UXBaTWV4c1hZbU9lV2Noc3FCMnJ2eW1MOEs3WDY1NnRWdGFYay9nVzNsM3ZVNTdYSFF4Q3RNUwpJMVYvcGVSNHRiN24yd0ZncFFlTm1XNkQ4QXk4Z0xiaUZhRkdRSDg5QWhFa0dTd1d5cWJKc2NoTUZZOUJ5OEtUCkZaVWZsUUtCZ0V3VzJkVUpOZEJMeXNycDhOTE1VbGt1ZnJxbllpUTNTQUhoNFZzWkg1TXU0MW55Yi95NUUyMW4KMk55d3ltWGRlb3VJcFZjcUlVTXl0L3FKRmhIcFJNeVEyWktPR0QyWG5YaENNVlRlL0FQNDJod294Nm02QkZpQgpvemZFa2wwak5uZmREcjZrL1p2MlQ1TnFzaWxaRXJBQlZGOTBKazdtUFBIa0Q2R1ZMUUJ4Ci0tLS0tRU5EIFJTQSBQUklWQVRFIEtFWS0tLS0tCg== # Basic auth to protect all the routes. Can use htpasswd to generate passwords # &gt; htpasswd -n -b testuser testpass # &gt; testuser:$apr1$JXRA7j2s$LpVns9vsme8FHN0r.aSt11 auth: {} # basic: # testuser: $apr1$JXRA7j2s$LpVns9vsme8FHN0r.aSt11 kvprovider: ## If you want to run Traefik in HA mode, you will need to setup a KV Provider. Therefore you can choose one of ## * etcd ## * consul ## * boltdb ## * zookeeper ## ## ref: https://docs.traefik.io/user-guide/cluster/ ## storeAcme has to be enabled to support HA Support using acme, but at least one kvprovider is needed storeAcme: false importAcme: false # etcd: # endpoint: etcd-service:2379 # useAPIV3: false # watch: true # prefix: traefik ## Override default configuration template. ## For advanced users :) ## ## Optional # filename: consul.tmpl # username: foo # password: bar # tls: # ca: "/etc/ssl/ca.crt" # cert: "/etc/ssl/consul.crt" # key: "/etc/ssl/consul.key" # insecureSkipVerify: true # # consul: # endpoint: consul-service:8500 # watch: true # prefix: traefik ## Override default configuration template. ## For advanced users :) ## ## Optional # filename: consul.tmpl # username: foo # password: bar # tls: # ca: "/etc/ssl/ca.crt" # cert: "/etc/ssl/consul.crt" # key: "/etc/ssl/consul.key" # insecureSkipVerify: true ## only relevant for etcd acme: enabled: true email: me@gmail.com onHostRule: true staging: true logging: true # Configure a Let's Encrypt certificate to be managed by default. # This is the only way to request wildcard certificates (works only with dns challenge). domains: enabled: true # List of sets of main and (optional) SANs to generate for # for wildcard certificates see https://docs.traefik.io/configuration/acme/#wildcard-domains domainsList: - main: "*.k8s-test.hardstyletop40.com" # - sans: # - "k8s-test.hardstyletop40.com" # - main: "*.example2.com" # - sans: # - "test1.example2.com" # - "test2.example2.com" ## ACME challenge type: "tls-sni-01", "tls-alpn-01", "http-01" or "dns-01" ## Note the chart's default of tls-sni-01 has been DEPRECATED and (except in ## certain circumstances) DISABLED by Let's Encrypt. It remains as a default ## value in this chart to preserve legacy behavior and avoid a breaking ## change. Users of this chart should strongly consider making the switch to ## the recommended "tls-alpn-01" (avaialbe since v1.7), dns-01 or http-01 ## (available since v1.5) challenge. challengeType: tls-alpn-01 ## Configure dnsProvider to perform domain verification using dns challenge ## Applicable only if using the dns-01 challenge type delayBeforeCheck: 0 resolvers: [] # - 1.1.1.1:53 # - 8.8.8.8:53 dnsProvider: name: nil auroradns: AURORA_USER_ID: "" AURORA_KEY: "" AURORA_ENDPOINT: "" azure: AZURE_CLIENT_ID: "" AZURE_CLIENT_SECRET: "" AZURE_SUBSCRIPTION_ID: "" AZURE_TENANT_ID: "" AZURE_RESOURCE_GROUP: "" cloudflare: CLOUDFLARE_EMAIL: "" CLOUDFLARE_API_KEY: "" digitalocean: DO_AUTH_TOKEN: "" dnsimple: DNSIMPLE_OAUTH_TOKEN: "" DNSIMPLE_BASE_URL: "" dnsmadeeasy: DNSMADEEASY_API_KEY: "" DNSMADEEASY_API_SECRET: "" DNSMADEEASY_SANDBOX: "" dnspod: DNSPOD_API_KEY: "" dyn: DYN_CUSTOMER_NAME: "" DYN_USER_NAME: "" DYN_PASSWORD: "" exoscale: EXOSCALE_API_KEY: "" EXOSCALE_API_SECRET: "" EXOSCALE_ENDPOINT: "" gandi: GANDI_API_KEY: "" godaddy: GODADDY_API_KEY: "" GODADDY_API_SECRET: "" gcloud: GCE_PROJECT: "" GCE_SERVICE_ACCOUNT_FILE: "" linode: LINODE_API_KEY: "" namecheap: NAMECHEAP_API_USER: "" NAMECHEAP_API_KEY: "" ns1: NS1_API_KEY: "" otc: OTC_DOMAIN_NAME: "" OTC_USER_NAME: "" OTC_PASSWORD: "" OTC_PROJECT_NAME: "" OTC_IDENTITY_ENDPOINT: "" ovh: OVH_ENDPOINT: "" OVH_APPLICATION_KEY: "" OVH_APPLICATION_SECRET: "" OVH_CONSUMER_KEY: "" pdns: PDNS_API_URL: "" rackspace: RACKSPACE_USER: "" RACKSPACE_API_KEY: "" rfc2136: RFC2136_NAMESERVER: "" RFC2136_TSIG_ALGORITHM: "" RFC2136_TSIG_KEY: "" RFC2136_TSIG_SECRET: "" RFC2136_TIMEOUT: "" route53: AWS_REGION: "" AWS_ACCESS_KEY_ID: "" AWS_SECRET_ACCESS_KEY: "" vultr: VULTR_API_KEY: "" ## Save ACME certs to a persistent volume. ## WARNING: If you do not do this and you did not have configured ## a kvprovider, you will re-request certs every time a pod (re-)starts ## and you WILL be rate limited! persistence: enabled: true annotations: {} ## acme data Persistent Volume Storage Class ## If defined, storageClassName: &lt;storageClass&gt; ## If set to "-", storageClassName: "", which disables dynamic provisioning ## If undefined (the default) or set to null, no storageClassName spec is ## set, choosing the default provisioner. (gp2 on AWS, standard on ## GKE, AWS &amp; OpenStack) ## storageClass: "default" accessMode: ReadWriteOnce size: 1Gi ## A manually managed Persistent Volume Claim ## Requires persistence.enabled: true ## If defined, PVC must be created manually before volume will be bound ## # existingClaim: dashboard: enabled: true domain: traefik.k8s-test.hardstyletop40.com # serviceType: ClusterIP service: {} # annotations: # key: value ingress: {} # annotations: # key: value # labels: # key: value # tls: # - hosts: # - traefik.example.com # secretName: traefik-default-cert auth: {} # basic: # username: password statistics: {} ## Number of recent errors to show in the ‘Health’ tab # recentErrors: service: # annotations: # key: value # labels: # key: value ## Further config for service of type NodePort ## Default config with empty string "" will assign a dynamic ## nodePort to http and https ports nodePorts: http: "" https: "" ## If static nodePort configuration is required it can be enabled as below ## Configure ports in allowable range (eg. 30000 - 32767 on minikube) # nodePorts: # http: 30080 # https: 30443 gzip: enabled: true traefikLogFormat: json accessLogs: enabled: false ## Path to the access logs file. If not provided, Traefik defaults it to stdout. # filePath: "" format: common # choices are: common, json ## for JSON logging, finer-grained control over what is logged. Fields can be ## retained or dropped, and request headers can be retained, dropped or redacted fields: # choices are keep, drop defaultMode: keep names: {} # ClientUsername: drop headers: # choices are keep, drop, redact defaultMode: keep names: {} # Authorization: redact rbac: enabled: false ## Enable the /metrics endpoint, for now only supports prometheus ## set to true to enable metric collection by prometheus metrics: prometheus: enabled: false ## If true, prevents exposing port 8080 on the main Traefik service, reserving ## it to the dashboard service only restrictAccess: false # buckets: [0.1,0.3,1.2,5] datadog: enabled: false # address: localhost:8125 # pushinterval: 10s statsd: enabled: false # address: localhost:8125 # pushinterval: 10s deployment: # labels to add to the pod container metadata # podLabels: # key: value # podAnnotations: # key: value hostPort: httpEnabled: false httpsEnabled: false dashboardEnabled: false # httpPort: 80 # httpsPort: 443 # dashboardPort: 8080 sendAnonymousUsage: false tracing: enabled: false serviceName: traefik # backend: choices are jaeger, zipkin, datadog # jaeger: # localAgentHostPort: "127.0.0.1:6831" # samplingServerURL: http://localhost:5778/sampling # samplingType: const # samplingParam: 1.0 # zipkin: # httpEndpoint: http://localhost:9411/api/v1/spans # debug: false # sameSpan: false # id128bit: true # datadog: # localAgentHostPort: "127.0.0.1:8126" # debug: false # globalTag: "" ## Create HorizontalPodAutoscaler object. ## # autoscaling: # minReplicas: 1 # maxReplicas: 10 # metrics: # - type: Resource # resource: # name: cpu # targetAverageUtilization: 60 # - type: Resource # resource: # name: memory # targetAverageUtilization: 60 ## Timeouts ## # timeouts: # ## responding are timeouts for incoming requests to the Traefik instance # responding: # readTimeout: 0s # writeTimeout: 0s # idleTimeout: 180s # ## forwarding are timeouts for requests forwarded to the backend servers # forwarding: # dialTimeout: 30s # responseHeaderTimeout: 0s </code></pre>
<p>For your issue, it seems you misunderstand the persist volume claims. When you use the command:</p> <pre><code>kubectl get sc --all-namespaces </code></pre> <p>It just shows the storage class, not the persist volume claims. The storage class is used to define how a unit of storage is dynamically created with a persistent volume. You need to create the persist volume claims as you need like this:</p> <pre><code>apiVersion: v1 kind: PersistentVolumeClaim metadata: name: azure-managed-disk spec: accessModes: - ReadWriteOnce storageClassName: managed-premium resources: requests: storage: 5Gi </code></pre> <p>And you can use the command to show the persist volume claims like below:</p> <pre><code>kubectl get pvc --all-namespaces </code></pre> <p>And it actually shows the persist volume claims that you create. Take a look at the <a href="https://learn.microsoft.com/en-us/azure/aks/azure-disks-dynamic-pv" rel="nofollow noreferrer">Dynamically create and use a persistent volume with Azure disks in Azure Kubernetes Service (AKS)</a>. Or <a href="https://learn.microsoft.com/en-us/azure/aks/azure-disk-volume" rel="nofollow noreferrer">Use the special disk that you create</a>.</p> <p><strong>Update</strong></p> <p>Also, I get the error as you, but when the pod in the running state, I check inside the pod and find the volumes all mounted correctly. So I guess if the error came because the pod is not in the running state. When the pod in the running state, volumes will mount as expected.</p>
<p>I have defined an environment variable for a container from a Configmap, But I want to apply changes automatically when changing the variable value in the ConfigMap. Maybe we can target an environment variable in volume path !?</p>
<p>In the following lines I'll try to exhibit an idea (It can be considered as solution, at least for the moment), it consist of mounting the configmap values as Volume, </p> <pre><code>spec: containers: - name ... volumeMounts: - name: config-volume mountPath: /etc/config #just an example volumes: - name: config-volume configMap: name : &lt;name-of-configmap&gt; items: - key: &lt;key-in-onfigmap&gt; path: keys </code></pre> <p>As result we will get the value of our configMap Key inside a volume file (/etc/config/keys) we can ensure by executing theses commands </p> <pre><code>kubectl exec -it &lt;name-of-pod&gt; sh #to get a shell to the running container/pod cat /etc/config/keys # </code></pre> <p>Note : there a delay time from the moment when the ConfigMap is updated to the moment when keys are projected to the pod (it can be as long as kubelet ConfigMap sync period + ttl of ConfigMap cache in kubelet )</p> <p>Take a look to <a href="https://kubernetes.io/docs/tasks/configure-pod-container/configure-pod-configmap/" rel="nofollow noreferrer">this</a> to make it more clear, Best regards </p>
<p>When my Kubernetes pods get terminated (due to restarting or completely stopping), I would like to invoke some kind of a lifecycle hook that will notify me of the termination through email. Something like the following:</p> <pre><code> onTermination: args: - '/bin/sh' - '-c' - | &lt;smtp login and send email script&gt; </code></pre> <p>How I can get an email when my pod is restarted or stop in Kubernetes?</p>
<p>Only way I know that you can get an email if there is something wrong with Cluster/Node/Pod are monitoring tools.</p> <p>You can use i.e paid software with free trial like <a href="https://sysdig.com/" rel="nofollow noreferrer">sysdig</a> or <a href="https://www.datadoghq.com/" rel="nofollow noreferrer">datadog</a>. If you want to learn Kubernetes metrics you can use <a href="https://github.com/kubernetes/kube-state-metrics" rel="nofollow noreferrer">kube-state-metrics</a> with <a href="https://prometheus.io/" rel="nofollow noreferrer">Prometheus</a> (AlertManager) and i.e <a href="https://grafana.com/" rel="nofollow noreferrer">Grafana</a> as backend.</p> <p>Here you have some steps which may be useful.</p> <ol> <li>Install kube-state-metrics.</li> <li>Install Prometheus</li> <li>Install Grafana</li> <li>Connect to Prometheus (kubectl Port Forwarding or expose Prometheus as a Service)</li> <li>Connect to Grafana (kubectl port forwarding)</li> <li>In Grafana you have something like Alerts > Notification Chanels. There you can define how notification can be send (one of the option is email).</li> <li>Create dashboard with desired metrics and add alerting to it.</li> </ol> <p>You can also check InfluxDB or Stackdriver as data source.</p> <p>Tutorials which may help you <br/> <a href="https://devopscube.com/setup-prometheus-monitoring-on-kubernetes/" rel="nofollow noreferrer">https://devopscube.com/setup-prometheus-monitoring-on-kubernetes/</a> <br/> <a href="https://itnext.io/kubernetes-monitoring-with-prometheus-in-15-minutes-8e54d1de2e13" rel="nofollow noreferrer">https://itnext.io/kubernetes-monitoring-with-prometheus-in-15-minutes-8e54d1de2e13</a></p>
<p>We just start to create our cluster on kubernetes.</p> <p>Now we try to deploy tiller but we have en error:</p> <blockquote> <p>NetworkPlugin cni failed to set up pod "tiller-deploy-64c9d747bd-br9j7_kube-system" network: open /run/flannel/subnet.env: no such file or directory</p> </blockquote> <p>After that I call:</p> <pre><code>kubectl get pods --all-namespaces -o wide </code></pre> <p>And got response:</p> <pre><code>NAMESPACE NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE kube-system coredns-78fcdf6894-ksdvt 1/1 Running 2 7d 192.168.0.4 kube-master &lt;none&gt; kube-system coredns-78fcdf6894-p4l9q 1/1 Running 2 7d 192.168.0.5 kube-master &lt;none&gt; kube-system etcd-kube-master 1/1 Running 2 7d 10.168.209.20 kube-master &lt;none&gt; kube-system kube-apiserver-kube-master 1/1 Running 2 7d 10.168.209.20 kube-master &lt;none&gt; kube-system kube-controller-manager-kube-master 1/1 Running 2 7d 10.168.209.20 kube-master &lt;none&gt; kube-system kube-flannel-ds-amd64-42rl7 0/1 CrashLoopBackOff 2135 7d 10.168.209.17 node5 &lt;none&gt; kube-system kube-flannel-ds-amd64-5fx2p 0/1 CrashLoopBackOff 2164 7d 10.168.209.14 node2 &lt;none&gt; kube-system kube-flannel-ds-amd64-6bw5g 0/1 CrashLoopBackOff 2166 7d 10.168.209.15 node3 &lt;none&gt; kube-system kube-flannel-ds-amd64-hm826 1/1 Running 1 7d 10.168.209.20 kube-master &lt;none&gt; kube-system kube-flannel-ds-amd64-thjps 0/1 CrashLoopBackOff 2160 7d 10.168.209.16 node4 &lt;none&gt; kube-system kube-flannel-ds-amd64-w99ch 0/1 CrashLoopBackOff 2166 7d 10.168.209.13 node1 &lt;none&gt; kube-system kube-proxy-d6v2n 1/1 Running 0 7d 10.168.209.13 node1 &lt;none&gt; kube-system kube-proxy-lcckg 1/1 Running 0 7d 10.168.209.16 node4 &lt;none&gt; kube-system kube-proxy-pgblx 1/1 Running 1 7d 10.168.209.20 kube-master &lt;none&gt; kube-system kube-proxy-rnqq5 1/1 Running 0 7d 10.168.209.14 node2 &lt;none&gt; kube-system kube-proxy-wc959 1/1 Running 0 7d 10.168.209.15 node3 &lt;none&gt; kube-system kube-proxy-wfqqs 1/1 Running 0 7d 10.168.209.17 node5 &lt;none&gt; kube-system kube-scheduler-kube-master 1/1 Running 2 7d 10.168.209.20 kube-master &lt;none&gt; kube-system kubernetes-dashboard-6948bdb78-97qcq 0/1 ContainerCreating 0 7d &lt;none&gt; node5 &lt;none&gt; kube-system tiller-deploy-64c9d747bd-br9j7 0/1 ContainerCreating 0 45m &lt;none&gt; node4 &lt;none&gt; </code></pre> <p>We have some flannel pods in CrashLoopBackOff status. For example <code>kube-flannel-ds-amd64-42rl7</code>.</p> <p>When I call:</p> <pre><code>kubectl describe pod -n kube-system kube-flannel-ds-amd64-42rl7 </code></pre> <p>I've got status <code>Running</code>:</p> <pre><code>Name: kube-flannel-ds-amd64-42rl7 Namespace: kube-system Priority: 0 PriorityClassName: &lt;none&gt; Node: node5/10.168.209.17 Start Time: Wed, 22 Aug 2018 16:47:10 +0300 Labels: app=flannel controller-revision-hash=911701653 pod-template-generation=1 tier=node Annotations: &lt;none&gt; Status: Running IP: 10.168.209.17 Controlled By: DaemonSet/kube-flannel-ds-amd64 Init Containers: install-cni: Container ID: docker://eb7ee47459a54d401969b1770ff45b39dc5768b0627eec79e189249790270169 Image: quay.io/coreos/flannel:v0.10.0-amd64 Image ID: docker-pullable://quay.io/coreos/flannel@sha256:88f2b4d96fae34bfff3d46293f7f18d1f9f3ca026b4a4d288f28347fcb6580ac Port: &lt;none&gt; Host Port: &lt;none&gt; Command: cp Args: -f /etc/kube-flannel/cni-conf.json /etc/cni/net.d/10-flannel.conflist State: Terminated Reason: Completed Exit Code: 0 Started: Wed, 22 Aug 2018 16:47:24 +0300 Finished: Wed, 22 Aug 2018 16:47:24 +0300 Ready: True Restart Count: 0 Environment: &lt;none&gt; Mounts: /etc/cni/net.d from cni (rw) /etc/kube-flannel/ from flannel-cfg (rw) /var/run/secrets/kubernetes.io/serviceaccount from flannel-token-9wmch (ro) Containers: kube-flannel: Container ID: docker://521b457c648baf10f01e26dd867b8628c0f0a0cc0ea416731de658e67628d54e Image: quay.io/coreos/flannel:v0.10.0-amd64 Image ID: docker-pullable://quay.io/coreos/flannel@sha256:88f2b4d96fae34bfff3d46293f7f18d1f9f3ca026b4a4d288f28347fcb6580ac Port: &lt;none&gt; Host Port: &lt;none&gt; Command: /opt/bin/flanneld Args: --ip-masq --kube-subnet-mgr State: Waiting Reason: CrashLoopBackOff Last State: Terminated Reason: Error Exit Code: 1 Started: Thu, 30 Aug 2018 10:15:04 +0300 Finished: Thu, 30 Aug 2018 10:15:08 +0300 Ready: False Restart Count: 2136 Limits: cpu: 100m memory: 50Mi Requests: cpu: 100m memory: 50Mi Environment: POD_NAME: kube-flannel-ds-amd64-42rl7 (v1:metadata.name) POD_NAMESPACE: kube-system (v1:metadata.namespace) Mounts: /etc/kube-flannel/ from flannel-cfg (rw) /run from run (rw) /var/run/secrets/kubernetes.io/serviceaccount from flannel-token-9wmch (ro) Conditions: Type Status Initialized True Ready False ContainersReady False PodScheduled True Volumes: run: Type: HostPath (bare host directory volume) Path: /run HostPathType: cni: Type: HostPath (bare host directory volume) Path: /etc/cni/net.d HostPathType: flannel-cfg: Type: ConfigMap (a volume populated by a ConfigMap) Name: kube-flannel-cfg Optional: false flannel-token-9wmch: Type: Secret (a volume populated by a Secret) SecretName: flannel-token-9wmch Optional: false QoS Class: Guaranteed Node-Selectors: beta.kubernetes.io/arch=amd64 Tolerations: node-role.kubernetes.io/master:NoSchedule node.kubernetes.io/disk-pressure:NoSchedule node.kubernetes.io/memory-pressure:NoSchedule node.kubernetes.io/not-ready:NoExecute node.kubernetes.io/unreachable:NoExecute Events: Type Reason Age From Message ---- ------ ---- ---- ------- Normal Pulled 51m (x2128 over 7d) kubelet, node5 Container image "quay.io/coreos/flannel:v0.10.0-amd64" already present on machine Warning BackOff 1m (x48936 over 7d) kubelet, node5 Back-off restarting failed container </code></pre> <p>here <code>kube-controller-manager.yaml</code>:</p> <pre><code>apiVersion: v1 kind: Pod metadata: annotations: scheduler.alpha.kubernetes.io/critical-pod: "" creationTimestamp: null labels: component: kube-controller-manager tier: control-plane name: kube-controller-manager namespace: kube-system spec: containers: - command: - kube-controller-manager - --address=127.0.0.1 - --allocate-node-cidrs=true - --cluster-cidr=192.168.0.0/24 - --cluster-signing-cert-file=/etc/kubernetes/pki/ca.crt - --cluster-signing-key-file=/etc/kubernetes/pki/ca.key - --controllers=*,bootstrapsigner,tokencleaner - --kubeconfig=/etc/kubernetes/controller-manager.conf - --leader-elect=true - --node-cidr-mask-size=24 - --root-ca-file=/etc/kubernetes/pki/ca.crt - --service-account-private-key-file=/etc/kubernetes/pki/sa.key - --use-service-account-credentials=true image: k8s.gcr.io/kube-controller-manager-amd64:v1.11.2 imagePullPolicy: IfNotPresent livenessProbe: failureThreshold: 8 httpGet: host: 127.0.0.1 path: /healthz port: 10252 scheme: HTTP initialDelaySeconds: 15 timeoutSeconds: 15 name: kube-controller-manager resources: requests: cpu: 200m volumeMounts: - mountPath: /etc/ssl/certs name: ca-certs readOnly: true - mountPath: /etc/kubernetes/controller-manager.conf name: kubeconfig readOnly: true - mountPath: /usr/libexec/kubernetes/kubelet-plugins/volume/exec name: flexvolume-dir - mountPath: /etc/pki name: etc-pki readOnly: true - mountPath: /etc/kubernetes/pki name: k8s-certs readOnly: true hostNetwork: true priorityClassName: system-cluster-critical volumes: - hostPath: path: /etc/ssl/certs type: DirectoryOrCreate name: ca-certs - hostPath: path: /etc/kubernetes/controller-manager.conf type: FileOrCreate name: kubeconfig - hostPath: path: /usr/libexec/kubernetes/kubelet-plugins/volume/exec type: DirectoryOrCreate name: flexvolume-dir - hostPath: path: /etc/pki type: DirectoryOrCreate name: etc-pki - hostPath: path: /etc/kubernetes/pki type: DirectoryOrCreate name: k8s-certs status: {} </code></pre> <p>OS is CentOS Linux release 7.5.1804</p> <p>logs from one of pods:</p> <pre><code># kubectl logs --namespace kube-system kube-flannel-ds-amd64-5fx2p main.go:475] Determining IP address of default interface main.go:488] Using interface with name eth0 and address 10.168.209.14 main.go:505] Defaulting external address to interface address (10.168.209.14) kube.go:131] Waiting 10m0s for node controller to sync kube.go:294] Starting kube subnet manager kube.go:138] Node controller sync successful main.go:235] Created subnet manager: Kubernetes Subnet Manager - node2 main.go:238] Installing signal handlers main.go:353] Found network config - Backend type: vxlan vxlan.go:120] VXLAN config: VNI=1 Port=0 GBP=false DirectRouting=false main.go:280] Error registering network: failed to acquire lease: node "node2" pod cidr not assigned main.go:333] Stopping shutdownHandler... </code></pre> <p>Where error is?</p>
<p>For <code>flannel</code> to work correctly, you must pass <code>--pod-network-cidr=10.244.0.0/16</code> to <code>kubeadm init</code>.</p>
<p>I have a <em>.NET core web API</em> and <em>Angular 7</em> app that I need to deploy to multiple client servers, potentially running a plethora of different OS setups. </p> <p>Dockerising the whole app seems like the best way to handle this, so I can ensure that it all works wherever it goes. </p> <p>My question is on my understanding of Kubernetes and the distribution of the application. We use Azure Dev Ops for build pipelines, so if I'm correct would it work as follows:</p> <p>1) Azure Dev Ops builds and deploys the image as a Docker container.<br> 2) Kubernetes could realise there is a new version of the docker image and push this around all of the different client servers? <br> 3) Client specific app settings could be handled by Kubernetes secrets.</p> <p>Is that a reasonable setup? Have I missed anything? And are there any recommendations on setup/guides I can follow to get started.</p> <p>Thanks in advance, James</p>
<p>Azure DevOps will perform the CI part of your pipeline. Once it is completed, Azure DevOps will push images to ACR. CD part should be done either directly from Azure DevOps (You may have to install a private agent on your on-prem servers &amp; configure firewall etc) or Kubernetes native CD tools such as <a href="https://www.spinnaker.io/" rel="nofollow noreferrer">Spinnaker</a> or <a href="https://jenkins-x.io/" rel="nofollow noreferrer">Jenkins-X</a>. Secrets should be kept in Kubernetes secrets.</p>
<p>If I run <code>kubectl get nodes</code> on GKE, EKS, or DigitalOcean Kubernetes, I only see the worker nodes. How are these systems architected at the network or application level to create this separation between workers and masters?</p>
<p>You can run the Kubernetes control plane outside Kubernetes as long as the worker nodes have network access to the control plane. This approach is used on most managed Kubernetes solutions. </p>
<p>I have a requirement to run an ad-hoc job, once in a while. The job needs some state to work. Building the state takes a lot of time. So, it is desired to keep the state persistent and reusable in subsequent runs, for a fast turnaround time. I want this job to be managed as K8s pods.</p> <p>This is a complete set of requirements:</p> <ol> <li>Pods will go down after work finish. The K8s controller should not try to bring up the pods.</li> <li>Each pod should have a persistent volume attached to it. There should be 1 volume per pod. I am planning to use EBS.</li> <li>We should be able to manually bring the pods back up in future.</li> <li>Future runs may have more or less replicas than the past runs.</li> </ol> <p>I know K8s supports both Jobs and Statefulsets. Is there any Controller which supports both at the same time?</p>
<blockquote> <ol> <li>Pods will go down after work finish. The K8s controller should not try to bring up the pods. </li> </ol> </blockquote> <p>This is what Jobs do - run to completion. You only control whether you wanna retry on <code>exit &gt; 0</code>.</p> <blockquote> <ol start="2"> <li>Pods should have a persistent volume attached to them. </li> </ol> </blockquote> <p>Same volume to all? Will they write or only read? What volume backend do you have, AWS EBS or similar? Depending of answers you might want to split input data between few volumes or use separate volumes to write and then finalization job to assemble in 1 volume (kind of map reduce). Or use volume backend which supports multi-mount RW <a href="https://kubernetes.io/docs/concepts/storage/persistent-volumes/#access-modes" rel="nofollow noreferrer">https://kubernetes.io/docs/concepts/storage/persistent-volumes/#access-modes</a> (see table for <code>ReadWriteMany</code>)</p> <blockquote> <ol start="3"> <li>We should be able to manually bring the pods back up in future.</li> </ol> </blockquote> <p>Jobs fit here: You launch it when you need it, and it runs till completion.</p> <blockquote> <ol start="4"> <li>Future runs may have more or less replicas than the past runs.</li> </ol> </blockquote> <p>Jobs fit here. Specify different <code>completions</code> or <code>parallelism</code> when you launch a job: <a href="https://kubernetes.io/docs/concepts/workloads/controllers/jobs-run-to-completion/#parallel-jobs" rel="nofollow noreferrer">https://kubernetes.io/docs/concepts/workloads/controllers/jobs-run-to-completion/#parallel-jobs</a></p> <p>StatefulSets are different concept, they mostly used for clustered software which you run continuously and need to persist the role per pod (e.g. shard). </p>
<p>In <a href="https://kubernetes.io/docs/tasks/configure-pod-container/configure-service-account/#add-imagepullsecrets-to-a-service-account" rel="nofollow noreferrer">this</a> kubernetres documentation, why do you need the extra step replacing the <code>kubectl replace serviceaccount</code>?</p> <p>I can see that the name of the <code>imagePullSecrets</code> is wrong alright, but I would expect <code>kubectl patch serviceaccount</code> to do this - well it does not, so there must be a reason?</p>
<p>It's for the sake of convenience. Imagine you have several typical deployments that use the same serviceaccount and a number of images from Docker registry with authentication. By incorporating imagePullSecrets inside serviceaccount you can now specify only serviceAccountName in your deployments - imagePullSecrets will be automatically added. </p> <p>I would not say this is a very cool feature, but in some cases it can be useful.</p>
<p>I have a docker image with Nginx serving a static site. The site is served from a folder, lets call it "folder". When I request <a href="http://mydomain/folder/" rel="nofollow noreferrer">http://mydomain/folder/</a> it works. However when I request <a href="http://mydomain/folder" rel="nofollow noreferrer">http://mydomain/folder</a> it redirects to <a href="http://mydomain:8080/folder" rel="nofollow noreferrer">http://mydomain:8080/folder</a> which is the internal port used by the container. How can I prevent my ingress controller from adding the port?</p> <pre><code>apiVersion: extensions/v1beta1 kind: Ingress metadata: generation: 1 labels: app.kubernetes.io/instance: administration-env name: administration-env-erst-env namespace: default resourceVersion: "71710149" selfLink: /apis/extensions/v1beta1/namespaces/default/ingresses/administration-env-erst-env uid: c89014d2-60fe-11e9-8a63-000d3a2cc488 spec: rules: - host: mydomain http: paths: - backend: serviceName: administration servicePort: 8080 path: /administration tls: - hosts: - mydomain secretName: some-tls-secret status: loadBalancer: ingress: - ip: xx.xx.xx.xx </code></pre>
<p>you can try as a workaround adding a proxy pass in your <code>nginx.conf</code></p> <p>something like: </p> <pre><code>location /folder { proxy_pass http://mydomain/folder/; } </code></pre>
<h2>Problem Statement</h2> <ul> <li>I want to deliver a private registry which all the images I need for my product bundled in them ( Yes, It will be fat image, but I am fine with that) </li> <li>I would manually upload this image in some way </li> <li>I would run the docker private registry as a service in Kubernetes (probably in some namespace)</li> <li>When other services/deployments (in the same namespace as registry) happen in Kubernetes, they should refer to this registry using a consistent name</li> </ul> <h2>Constraints</h2> <ul> <li>We want registry to be exposed only to the cluster and not outside</li> <li>We want to use self signed certificate and not signed by CA</li> </ul> <p>I followed some instructions from these links (do not know whether it was a right thing to do) </p> <ul> <li><a href="https://kubernetes.io/docs/concepts/cluster-administration/certificates/" rel="nofollow noreferrer">https://kubernetes.io/docs/concepts/cluster-administration/certificates/</a></li> <li><a href="https://kubernetes.io/docs/tasks/tls/managing-tls-in-a-cluster/#create-a-certificate-signing-request-object-to-send-to-the-kubernetes-api" rel="nofollow noreferrer">https://kubernetes.io/docs/tasks/tls/managing-tls-in-a-cluster/#create-a-certificate-signing-request-object-to-send-to-the-kubernetes-api</a></li> </ul> <h3>Create a certificate signed through Kubernetes</h3> <ol> <li><p>Create a server.key </p></li> <li><p>Create a csr.info</p></li> </ol> <pre><code>[ req ] default_bits = 2048 prompt = no default_md = sha256 req_extensions = req_ext distinguished_name = dn [ dn ] C = US ST = oh L = cincinnati O = engg OU = prod CN = prateek.svc.cluster.local [ req_ext ] subjectAltName = @alt_names [ alt_names ] DNS.1 = registry.prateek.svc.cluster.local [ v3_ext ] authorityKeyIdentifier=keyid,issuer:always basicConstraints=CA:FALSE keyUsage=keyEncipherment,dataEncipherment extendedKeyUsage=serverAuth,clientAuth subjectAltName=@alt_names </code></pre> <ol start="3"> <li><p>Created the server.csr (openssl req -new -key server.key -out server.csr -config csr.conf)</p></li> <li><p>Create the CertificateSigningRequest in K8s</p></li> </ol> <pre><code>cat &lt;&lt;EOF | kubectl apply -f - apiVersion: certificates.k8s.io/v1beta1 kind: CertificateSigningRequest metadata: name: registry.prateek spec: groups: - system:authenticated request: $(cat server.csr | base64 | tr -d '\n') usages: - digital signature - key encipherment - server auth EOF </code></pre> <ol start="5"> <li>Checked if the CSR exists</li> </ol> <pre><code>kubectl describe csr registry.prateek Name: registry.prateek Labels: &lt;none&gt; Annotations: kubectl.kubernetes.io/last-applied-configuration={"apiVersion":"certificates.k8s.io/v1beta1","kind":"CertificateSigningRequest","metadata":{"annotations":{},"name":"registry.prateek","namespace":""},"spec":{"groups":["system:authenticated"],"request":"LS0sdfsfsdsfd=","usages":["digital signature","key encipherment","server auth"]}} CreationTimestamp: Thu, 11 Apr 2019 11:15:42 -0400 Requesting User: docker-for-desktop Status: Pending Subject: Common Name: prateek.svc.cluster.local Serial Number: Organization: engg Organizational Unit: prod Country: US Locality: cincinnati Province: oh Subject Alternative Names: DNS Names: registry.prateek.svc.cluster.local Events: &lt;none&gt; </code></pre> <ol start="6"> <li>Approved the CSR : kubectl certificate approve registry.prateek</li> </ol> <h3>Start the registry internal service</h3> <ol start="7"> <li>Added cert and key to the kind: Secret</li> </ol> registry-secret.yml <pre><code>apiVersion: v1 kind: Secret metadata: name: registry-credentials data: certificate: &lt;CERTIFICATE in base64&gt; key: &lt;KEY in base64&gt; </code></pre> <ol start="8"> <li>Create registry deployment and service (using those secrets) registry-deployment.yml</li> </ol> <pre><code>apiVersion: apps/v1 kind: Deployment metadata: name: registry namespace: prateek labels: app: registry spec: replicas: 1 selector: matchLabels: app: registry template: metadata: labels: app: registry spec: containers: - name: registry image: prateek/registry imagePullPolicy: IfNotPresent ports: - containerPort: 443 env: - name: REGISTRY_HTTP_ADDR value: "0.0.0.0:443" - name: REGISTRY_HTTP_TLS_CERTIFICATE value: "/certs/certificate" - name: REGISTRY_HTTP_TLS_KEY value: "/certs/key" volumeMounts: - name: cert-files mountPath: /certs volumes: - name: cert-files secret: secretName: registry-credentials </code></pre> <h3>registry-service.yml</h3> <pre><code>apiVersion: v1 kind: Service metadata: name: registry namespace: prateek spec: selector: app: registry ports: - protocol: TCP port: 443 targetPort: 443 type: LoadBalancer </code></pre> <h3>Test regsitry service is up</h3> <ol start="9"> <li>Tried to this the registry endpoint thru a test pod. I had image of this test pod loaded in docker already. </li> </ol> <pre><code>curl https://registry.prateek.svc.cluster.local/v2/_catalog -k {"repositories":["prateek/echo"]} </code></pre> <h3>Deployment using image from the registry service</h3> <ol start="10"> <li>Tried deployment with image: registry.prateek/prateek/echo:latest</li> </ol> <pre><code>apiVersion: apps/v1 kind: Deployment metadata: name: hello namespace: cequence labels: app: hello spec: replicas: 1 selector: matchLabels: app: hello template: metadata: labels: app: hello spec: containers: - name: hello image: registry.prateek/prateek/echo:latest imagePullPolicy: IfNotPresent ports: - containerPort: 5678 args: ["-text=hello"] </code></pre> <ol start="11"> <li>the deployment gives the error </li> </ol> <pre><code>Normal Pulling 10s (x2 over 25s) kubelet, docker-for-desktop pulling image "registry.prateek/prateek/echo:latest" Warning Failed 10s (x2 over 25s) kubelet, docker-for-desktop Failed to pull image "registry.prateek/prateek/echo:latest": rpc error: code = Unknown desc = Error response from daemon: Get https://registry.prateek/v2/: Service Unavailable </code></pre> <ol start="12"> <li>Changed deployment to have image: registry.prateek.svc.cluster.local/prateek/echo:latest</li> </ol> <pre><code>apiVersion: apps/v1 kind: Deployment metadata: name: hello namespace: cequence labels: app: hello spec: replicas: 1 selector: matchLabels: app: hello template: metadata: labels: app: hello spec: containers: - name: hello image: registry.prateek.svc.cluster.local/prateek/echo:latest imagePullPolicy: IfNotPresent ports: - containerPort: 5678 args: ["-text=hello"] </code></pre> <ol start="13"> <li>get the similar error</li> </ol> <pre><code>Warning Failed 1s kubelet, docker-for-desktop Failed to pull image "registry.prateek.svc.cluster.local/prateek/echo:latest": rpc error: code = Unknown desc = Error response from daemon: Get https://registry.prateek.svc.cluster.local/v2/: Service Unavailable </code></pre> <p>I do not that this is even possible. Run a docker registry as a service and point other service in the namespace to use that registry deployment in the cluster. Any suggestion is welcome</p>
<p>The container daemon is running outside of kubernetes.</p> <p>Therefore, if you want to pull the image, you need to make sure that the registry is reachable from the node directly, without using kubernetes mechanisms like a service. (Not like you tested it in step 9 through a pod, you must be able to work directly on the node!)</p> <p>The usual options are to create a DNS entry or hosts.txt entry to point to a node where either through a <code>hostPort</code> (container) or <code>nodePort</code> (service) the registry is accessible or you use an appropriate ingress.</p>
<p>I feel there is a big blocker in Rancher V2.2.2 where I can't define the Private Azure registry containing the docker images to be used to create a K8s deployment.</p> <p>I can define the azure registry credentials in the Resources -> Registries and authenticate it to create a workload. ( The Workload access the private azure registry and authenticates it using the credentials set )</p> <p>Now if I create a Helm chart that access the same private Azure registry to pull the image and create a pod , it fails saying the docker image could not be pulled. I have researched over it and I find that K8s deployment can find the credentials set in the Rancher UI but the kublet has no access to this credentials.</p> <p>The common suggestion that people give is to use the secrets in the help chart deployment file and that works also but it is a security concern as any person can access the helm chart to find the azure credentials described in it. I feel its still a common problem in Rancher V2. </p> <p>The Question : <a href="https://stackoverflow.com/questions/49669077/helm-chart-deployment-and-private-docker-repository">Helm chart deployment and private docker repository</a> caters to the problem but it has the security concern as expressed above.</p> <p>I am not sure if Rancher community also has the answer because the helm repo also suggests the same solution. Please refer (<a href="https://github.com/helm/helm/blob/master/docs/charts_tips_and_tricks.md#creating-image-pull-secrets" rel="nofollow noreferrer">https://github.com/helm/helm/blob/master/docs/charts_tips_and_tricks.md#creating-image-pull-secrets</a>)</p> <p>I dont want to define image pull secrets in deployement.yaml file of Helm chart as mentioned below</p> <pre><code> name: credentials-name registry: private-docker-registry username: user password: pass </code></pre>
<p>When you configure a new set of registry credentials under Resources -> Registries in your current project, Rancher creates a Kubernetes secret resource for you that holds the specified credentials.</p> <p>You can verify that the secret exists in all namespaces belonging to the project by running the following command:</p> <pre><code>$ kubectl get secrets -n &lt;some-project-namespace&gt; </code></pre> <p>Then - <strong>instead of persisting your plaintext account credentials in your deployment.yaml</strong> - you are going to reference the secret resource in the containers spec like so:</p> <pre><code>spec: containers: - name: mycontainer image: myregistry.azurecr.io/org/myimage imagePullSecrets: - name: project-azure-reg-creds </code></pre> <p>In the example above <code>project-azure-reg-creds</code> matches the name of the registry credential you added in Rancher. Also note, that your deployment must be created in a namespace assigned to the project.</p>
<p>Maybe I'm just a bit confused, but basically I'm trying to establish my workflow with using the <code>gcloud</code> cli through my own host (Mac) terminal rather than the provided gcloud interactive shell.</p> <p>I'm authenticating with an IAM member by running:</p> <p><code>gcloud auth login</code></p> <p>It takes me to the Google Cloud login page, which I successfully authenticate with and then I get the following in my shell:</p> <pre><code>You are now logged in as [MY_EMAIL@gmail.com]. Your current project is [myproperty-1537056464248]. You can change this setting by running: $ gcloud config set project PROJECT_ID </code></pre> <p>After this, I try to issue the following command:</p> <pre><code>gcloud container clusters create somename </code></pre> <p>And I get the following error message:</p> <pre><code>ERROR: (gcloud.container.clusters.create) ResponseError: code=400, message=Project "myproperty-1537056464248" has no network named "default". </code></pre> <p>My IAM user has the following roles:</p> <ul> <li><code>Kubernetes Engine Cluster Admin</code></li> <li><code>Owner</code></li> </ul> <p>All I want to do is avoid using the gcloud interactive shell so I can:</p> <ol> <li>Create clusters through the command line</li> <li>Push docker builds to the Google Container Registry</li> <li>List clusters</li> <li>Create pods</li> <li>etc...</li> </ol> <p>But these IAM policies aren't really working how I expect.</p> <p>Should I be using a service account instead?</p>
<p>You hit two distinct errors:</p> <ol> <li>The 1st error message says your project is missing the 'default' network.</li> </ol> <p>You can check your project's networks with:</p> <pre><code>$ gcloud compute networks list NAME SUBNET_MODE BGP_ROUTING_MODE IPV4_RANGE GATEWAY_IPV4 default AUTO REGIONAL </code></pre> <p>If you create a fully new project it should have a 'default' network.</p> <p>Or you can specify an existing network with:</p> <pre><code>gcloud container clusters create somename --network=put-existing-network-here </code></pre> <ol start="2"> <li>The 2nd error is lack of permission 'compute.networks.get' in the project. </li> </ol> <p>You can verify the actual roles in the project by using 'gcloud projects get-iam-policy PROJECT_ID'. Look for the role 'owner' for your IAM user, like this:</p> <pre><code>$ gcloud projects get-iam-policy PROJECT_ID - members: - user:username@somedomain.com role: roles/owner </code></pre>