Question
stringlengths
65
39.6k
QuestionAuthor
stringlengths
3
30
Answer
stringlengths
38
29.1k
AnswerAuthor
stringlengths
3
30
<p>I am trying to follow this tutorial to backup a persistent volume in Azure AKS:</p> <p><a href="https://learn.microsoft.com/en-us/azure/aks/azure-disks-dynamic-pv" rel="nofollow noreferrer">https://learn.microsoft.com/en-us/azure/aks/azure-disks-dynamic-pv</a></p> <p>I can see the volumes doing</p> <pre><code>az ...
icordoba
<p>Upgrade your az cli version.</p> <p>I was getting this issue with az cli 2.0.75 returning an empty array for the disk list, with an AKS PV.</p> <p>upgraded to az cli 2.9.1 and same command worked.</p>
Ian
<p>My kubernetes ingress is not accepting the self signed certificate and instead when opening the url on firefox the <strong>Kubernetes Ingress Controller Fake Certificate</strong> is added.</p> <blockquote> <p>All the things done locally on pc with minikube in Kali Linus. Kali linus is running in a Virtual Machine by...
yogihosting
<p>You have an error in your ingress manifest, here:</p> <pre><code>rules: - host: example.com - http: paths: </code></pre> <p>You have created two rules, the first matches <code>host: example.com</code> but defines no paths or backends; the second matches path <code>/</code> but doesn't set a <code>host</code>. Yo...
larsks
<p>Yesterday, <a href="https://github.com/naftulikay/katyperry" rel="noreferrer">I built a full-featured example</a> which uses Terraform to create a network and a GKE cluster in Google Cloud Platform. The whole thing runs in Vagrant on a CentOS 7 VM and installs both <code>gcloud</code>, <code>kubectl</code>, and <cod...
Naftuli Kay
<p>After successfully reproducing the issue multiple times by destroying and recreating all the infrastructure, I found <a href="https://gitlab.com/charts/gitlab/merge_requests/227#note_68683418" rel="noreferrer">some arcane post on GitLab</a> that mentions <a href="https://github.com/kubernetes/kubernetes/issues/61943...
Naftuli Kay
<p>Running minio operator on K8S is the solution i need to be able to create many minio tennats (installs) so serve my needs. Its ability to make managing erasure encoding and all the configurations is great. For the disk under minio it creates PVC on K8S using the storage class you choose.</p> <p>We currently using R...
Simon Thompson
<p>weeks of look and immediately after i post this i find the answer !!</p> <p>So DirectCSI would seem to be the answer <a href="https://github.com/minio/directpv" rel="nofollow noreferrer">https://github.com/minio/directpv</a></p> <p><a href="https://www.youtube.com/watch?v=iFTQmHpIsfQ" rel="nofollow noreferrer">https...
Simon Thompson
<p>I need to update a secret with specific value,(the secret contain additional data) my question is how I can update just the value and not all the secret data (I don't want to override the existing data). I mean if the secret have additional values I don’t want to override them just the entry <code>foo</code></p> <pr...
tj holwik
<p>I don't think you can update a single key using the <code>Update</code> method, but you can certainly do that using <code>Patch</code> instead. Here's an example that uses a StrategicMergePatch; it will replace the key <code>val2</code> in a secret with the value <code>newval</code>:</p> <pre class="lang-golang pret...
larsks
<p>I am running the command</p> <pre><code>kubectl create -f mypod.yaml --namespace=mynamespace </code></pre> <p>as I need to specify the environment variables through a configMap I created and specified in the mypod.yaml file. Kubernetes returns</p> <blockquote> <p>pod/mypod created</p> </blockquote> <p>but <cod...
zcleghern
<p>By default, <code>kubectl</code> commands operate in the <code>default</code> namespace. But you created your pod in the <code>mynamespace</code> namespace.</p> <p>Try one of the following:</p> <pre><code>kubectl get pods -n mynamespace kubectl get pods --all-namespaces </code></pre>
Oliver Charlesworth
<p>I need Prometheus to scrape several mongodb exporters one after another in order to compute a valid replication lag. However, the targets are scraped with a difference of several dozen seconds between them, which makes replication lag impossible to compute.</p> <p>The job yaml is below:</p> <pre><code>- job_name: ...
Adrian
<p>This isn't possible, Prometheus makes no guarantees about the phase of scrapes or rule evaluations. Nor is this something you should depend upon, as it'd be very fragile.</p> <p>I'd aim for knowing the lag within a scrape interval, rather than trying to get it perfect. You generally care if replication is completel...
brian-brazil
<p>I'm in learning mode here, so please forgive me if this is a stupid question...</p> <p>I have just installed microk8s on ubuntu following the instructions at <a href="https://ubuntu.com/tutorials/install-a-local-kubernetes-with-microk8s" rel="nofollow noreferrer">https://ubuntu.com/tutorials/install-a-local-kubernet...
Duncan
<blockquote> <p>But what surprised me is that after I stop microk8s (with &quot;microk8s stop&quot;), the web server is still apparently up and running. It continues to respond to curl with its simple page content.</p> <p>Is this expected behavior? Do the pods continue to run after the orchestrator has stopped?</p> </b...
larsks
<p>If i use node port in <code>yml</code> file it give a port more than 30000 but when my user want to use it they do not want to remember that port and want to use 80. my <code>kubernetes</code> cluster is on <code>baremetal</code>. How can i solve that?</p>
yasin lachini
<p>Kubernetes doesn't allow you to expose low ports via the Node Port service type by design. The idea is that there is a significant chance of a port conflict if users are allowed to set low port numbers for their Node Port services.</p> <p>If you really want to use port 80, you're going to have to either use a Load ...
Swiss
<p>I have a 3 node Kubernetes cluster running at home. I deployed traefik with helm, however, it never gets an external IP. Since this is in the private IP address space, shouldn't I expect the external IP to be something in the same address space? Am I missing something critical here?</p> <pre><code>$ kubectl describ...
farhany
<p>Use MetalLB, to get an LB IP. More <a href="https://metallb.universe.tf/" rel="nofollow noreferrer">here</a> on their site. </p>
farhany
<p>I am trying to update a helm-deployed deployment so that it uses a secret stored as a k8s secret resource. This <em>must</em> be set as the STORAGE_PASSWORD environment variable in my pod.</p> <p>In my case, the secret is in secrets/redis and the data item is redis-password:</p> <pre> $ kubectl get secret/redis -oy...
Jeff W
<p>Given a deployment that looks like this:</p> <pre><code>apiVersion: apps/v1 kind: Deployment metadata: name: example spec: replicas: 1 template: spec: containers: - image: alpinelinux/darkhttpd name: darkhttpd args: - --port - &quot;9991&quot; ...
larsks
<p>I have docker and kubernetes (enable kubernetes checked on docker settings) installed on my local macbook. I create containers using docker and after my machine restarts, these exactly same containers are still present. However, if I create containers within pods using kubernetes and machine is restarted, then I do ...
Puri
<p>Even at runtime, Kubernetes may move Pods at will (e.g. during scaling, cluster upgrades, adding and removing nodes, etc.).</p> <p>It is a good idea to try to treat containers as 'cattle, not pets', i.e. don't expect them to be long-lived.</p> <p>If you need a container to be 'the same' after restart, consider usi...
Paul J
<p>I have a K8s cluster created in the context of the Linux Foundation's CKAD course (<a href="https://training.linuxfoundation.org/training/kubernetes-for-developers/" rel="nofollow noreferrer">LFD259</a>). So it is a &quot;bare metal&quot; cluster created with kubeadm.</p> <p>So I have a metrics-server deployment run...
mark
<p>A container is just a process running on your host with some isolation features enabled. The isolation only works in one way: a container can't see resources on your host, but your host has access to all the resources running in a container.</p> <p>Because a container is just a process, it shows up in <code>ps</code...
larsks
<p>The following code will throw an <code>ApiException 410 resource too old</code> on the second <code>watch.stream()</code>:</p> <pre><code># python3 -m venv venv # source venv/bin/activate # pip install 'kubernetes==23.3.0' from kubernetes import client,config,watch config.load_kube_config(context='my-eks-context')...
RubenLaguna
<p>It seems that in the initial response to the watch (from an EKS cluster 1.21) the events can be returned in any order.</p> <p>I did two subsequent watches two seconds apart and they contain the same 30 events in completely different ordering.</p> <p>So it's not guaranteed that the last resource version that you see ...
RubenLaguna
<p>I found that we can create subcharts and conditionally include them as described here: <a href="https://stackoverflow.com/questions/54032974/helm-conditionally-install-subchart">Helm conditionally install subchart</a></p> <p>I have just one template that I want conditionally include in my chart but I could not find...
Eduardo
<p>I discovered that empty templates are not loaded. I solved it by wrapping my yaml file content in an <code>if</code> condition.</p> <pre><code>{{ if .Values.something }} content of yaml file {{ end }} </code></pre>
Eduardo
<p>Is there any standard to deploy flask app with gunicorn and nginx on kubernetes cluster because I am trying to it by on dockerfile like below:</p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-html lang-html pret...
yahiya ayoub
<blockquote> <p>Is the solution is to run two containers for each of gunicorn and nginx inside one pod of kubernetes?</p> </blockquote> <p>Yes. In Kubernetes or when simply running Docker on your local machine, it is always better to compose multiple containers rather than trying to stuff everything into a single conta...
larsks
<p>I have seen both <code>serviceAccount</code> and <code>serviceAccountName</code> been used in a pod manifest. What is the difference?</p>
RubenLaguna
<p>There is no difference.</p> <p><code>serviceAccount</code> is DEPRECATED and you should use <code>serviceAccountName</code> instead.</p> <p>Quoting from the <a href="https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.26/#podspec-v1-core" rel="nofollow noreferrer">Kubernetes API docs &gt; pod spec</a>:...
RubenLaguna
<p>I have a service running in a k8s cluster, which I want to monitor using Prometheus Operator. The service has a <code>/metrics</code> endpoint, which returns simple data like:</p> <pre><code>myapp_first_queue_length 12 myapp_first_queue_processing 2 myapp_first_queue_pending 10 myapp_second_queue_length 4 myapp_sec...
superstator
<p>Prometheus Operator developers are kindly working (as of Jan 2023) on a generic ScrapeConfig CRD that is designed to solve exactly the use case you describe: <a href="https://github.com/prometheus-operator/prometheus-operator/issues/2787" rel="nofollow noreferrer">https://github.com/prometheus-operator/prometheus-op...
mrucci
<p>In my <a href="https://docs.ovh.com/gb/en/kubernetes/" rel="nofollow noreferrer">OVH Managed Kubernetes</a> cluster I'm trying to expose a NodePort service, but it looks like the port is not reachable via <code>&lt;node-ip&gt;:&lt;node-port&gt;</code>.</p> <p>I followed this tutorial: <a href="https://kubernetes.io/...
sdabet
<p>The solution is to NOT enable &quot;Private network attached&quot; (&quot;réseau privé attaché&quot;) when you create the managed Kubernetes cluster.</p> <p>If you already paid your nodes or configured DNS or anything, you can select your current Kubernetes cluster, and select &quot;Reset your cluster&quot; (&quot;r...
Alex F
<p>I'm currently building an API for Firebase Admin SDK and I want to store the Admin SDK credential file as a secret in Kubernetes.</p> <p>This is an example from google on how to use the credential file:</p> <pre><code>var admin = require(&quot;firebase-admin&quot;); var serviceAccount = require(&quot;path/to/servic...
capiono
<p>If the question is just how to include it as a string in the Secret, you could simply add it as a multiline string.</p> <pre><code>apiVersion: v1 kind: Secret metadata: name: paisecret type: Opaque stringData: MONGODB_PASSWORD: &quot;sjldkjsjdfklsl&quot; MONGODB_USERNAME: &quot;prod_user&quot; MONGODB_...
Karl
<p>Is it possible to have array as environmental variable in deployment?</p> <pre><code>kind: Deployment metadata: name: array-deployment namespace: array-deployment spec: replicas: 1 selector: matchLabels: app: array-deployment template: metadata: labels: app: array-deployment ...
yesvladdy
<p>Environment variables are plain strings and do not support arrays as input</p> <p>In order to achieve what you want, you would want to pass the values as a comma separated list. (You might want to use some other separator if your data contains <code>,</code>)</p> <p>so your yaml manifest would become</p> <pre><code>...
codebreach
<p>Background : I am trying to learn and experiment a bit on docker and kubernetes in a "development/localhost" environment, that I could later replicate "for real" on some Cloud. But I'm running low on everything (disk capacity, memory, etc.) on my laptop. So I figured out "why not develop from the cloud ?"</p> <p>I ...
Cyril Duchon-Doris
<p>Heres how to do it</p> <p>Start an ec2 instance with 8gb of ram and a public ip, ensure you can ssh to this box in the normal ways. Ensure its an unbuntu instance (I'm using 16.04).</p> <p>once ssh'd into the instance run the following to update and install docker</p> <pre><code>sudo -i apt-get update -y &amp;&am...
krystan honour
<p>Within my Kubernetes cluster, I manage four deployments:</p> <ul> <li>Laravel Queue Workers: Labelled as laravel-kube-worker.</li> <li>Django Queue Workers: Labelled as django-kube-worker.</li> <li>Laravel Redis Instance: Labelled as laravel-kube-worker-redis.</li> <li>Django Redis Instance: Labelled as djan...
Delano van der Waal
<pre><code>apiVersion: v1 kind: Service .... # HERE IS YOUR PROBLEM selector: tier: backend layer: redis type: NodePort </code></pre> <p>Both of your Services are routing to <em>both</em> Redis deployments. A Service uses the labels on Pods to determine whether it should route to them. You are starting b...
Karl
<p>I have setup a kubernetes cluster of elasticsearch in GCP.</p> <pre><code>kubectl get svc </code></pre> <p>gives me</p> <pre><code>NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE ipgram-elasticsearch-elasticsearch-svc ClusterIP 10.27.247.26 &lt;none&...
Harshdeep Kanhai
<p>You have to convert the service to be of type <code>LoadBalancer</code> which will assign an external IP to the LB or <code>NodePort</code> and then use the nodes IP.</p>
codebreach
<p>I have a productionized Django backend server running as on Kubernetes (Deployment/Service/Ingress) on GCP. My django is configured with something like</p> <pre><code>ALLOWED_HOSTS = [BACKEND_URL,INGRESS_IP,THIS_POD_IP,HOST_IP] </code></pre> <p>Everything is working as expected.</p> <hr /> <p>However, my backend ser...
Roman
<blockquote> <p>My primary question is: Why - what are all of these hosts?.</p> </blockquote> <p>Some of them are web crawlers that gather information for various purposes. For example, the <code>www.google.com</code> address is most likely the web crawlers that populate the search engine databases for Google search, ...
Stephen C
<p>I have created kubernetes cluster on digitalocean. and I have deployed k6 as a job on kubernetes cluster.</p> <pre><code>apiVersion: batch/v1 kind: Job metadata: name: benchmark spec: template: spec: containers: - name: benchmark image: loadimpact/k6:0.29.0 command: [&quot;k6&quot...
Devi varalakshmi Tangilla
<p>The k6 Docker image runs as an unprivileged user, but unfortunately the default work directory is set to <code>/</code>, so it has no permission to write there.</p> <p>To work around this consider changing the JSON output path to <code>/home/k6/out.json</code>, i.e.:</p> <pre><code>command: [&quot;k6&quot;, &quot;ru...
imiric
<p>I have deployed the application developed on springboot and used hazelcast . The application is getting compiled well but when it is getting deployed on kubernetes(docker simulated kubernetes) I am getting the error as below. There is no compilation error but only runtime error.</p> <pre><code> ...
nee nee
<p>I think that you have a problem with your project's Hazelcast dependencies.</p> <p>According to the project history on Github (<a href="https://github.com/hazelcast/hazelcast" rel="nofollow noreferrer">https://github.com/hazelcast/hazelcast</a>), the class <code>com.hazelcast.core.DuplicateInstanceNameException</cod...
Stephen C
<p>From a certain PVC, I'm trying to get the volume id from the metadata of the PV associated with the PVC using <a href="https://github.com/kubernetes-client/python" rel="nofollow noreferrer">Kubernetes Python Api</a>.</p> <p>I'm able to describe PVC with <code>read_namespaced_persistent_volume_claim</code> function a...
falberto
<p>While <code>PersistentVolumeClaims</code> are namedspaced, <code>PersistentVolumes</code> are not. Looking at the available methods in the V1 API...</p> <pre><code>&gt;&gt;&gt; v1 = client.CoreV1Api() &gt;&gt;&gt; print('\n'.join([x for x in dir(v1) if x.startswith('read') and 'volume' in x])) read_namespaced_persis...
larsks
<p>I've deployed a <a href="https://istio.io/" rel="nofollow noreferrer">Istio</a> VirtualService: </p> <pre><code>apiVersion: networking.istio.io/v1alpha3 kind: VirtualService metadata: name: helloweb spec: hosts: - 'helloweb.dev' gateways: - gateway http: - route: - destination: h...
softshipper
<p>Not sure if I understood your question correctly but if you want to just list virtual services you can do this:</p> <pre><code>kubectl get virtualservices </code></pre> <p>VirtualService is just typical CRD.</p>
tefozi
<p>How do i convert the below kubectl command into ansible role/command to run on a cluster?</p> <pre><code>kubectl get openshiftapiserver \ -o=jsonpath='{range .items[0].status.conditions[?(@.type==&quot;Encrypted&quot;)]}{.reason}{&quot;\n&quot;}{.message}{&quot;\n&quot;}' </code></pre> <p>Below ansible playbook fo...
devops
<p>The task you've shown seems to do exactly what you want. For example, consider the following playbook:</p> <pre><code>- hosts: localhost tasks: - command: &gt;- kubectl get openshiftapiserver -o=jsonpath='{range .items[0].status.conditions[?(@.type==&quot;Encrypted&quot;)]}{.reason}{&quot;\n&q...
larsks
<p>With security in mind, I do not want to allow the <code>create</code> verb on <code>Job</code> and <code>CronJob</code> resources because it would allow someone to create a pod (using any image) and expose sensitive information. But I also want to allow the ability to trigger jobs that have already been created on t...
greenboi
<ol> <li><p>You can't &quot;trigger&quot; a Job. A Job is either pending (waiting to run), running, or completed. If it's completed, you can't re-run it; you can only delete and re-create it.</p> </li> <li><p>The only way to manually run a CronJob is by...using it as a template to create a Job (<code>kubectl create job...
larsks
<p>Consider there is one <code>rollout</code> in K8s setting and it creates 2 <code>replicaSet</code>s, each replicaSet has a single <code>pod</code>. Each pod include the same application that has a <code>volume</code> to directory with same value (i.e. /dir/logs/)</p> <pre><code>Rollout |_____ReplicaSet1 ...
Dreamer
<p>Include the pod name as an environment variable and then use this as part of your log path:</p> <pre><code>... env: - name: PODNAME valueFrom: fieldRef: fieldPath: metadata.name command: - sh - -c - | ...
larsks
<p>I have a config I need to apply from kubectl, but I don't quite understand what it is:</p> <pre class="lang-yaml prettyprint-override"><code>apiVersion: v1 kind: ConfigMap data: localHosting.v1: | host: &quot;localhost:1234&quot; containerHost: &quot;container-name:5555&quot; </code></pre> <p>I can't figur...
Stabby
<blockquote> <p>I thought that ConfigMaps were just key-value pairs...</p> </blockquote> <p>They <em>are</em> just key-value pairs. In your example, <code>localHosting.v1</code> is the key, and the string...</p> <pre><code>host: &quot;localhost:1234&quot; containerHost: &quot;container-name:5555&quot; </code></pre> <p>...
larsks
<p>I am working on practicing for the CKAD exam and ran into an interesting problem with a multi-container pod that I can't seem to find an answer to. Lets say I run this imperative command to create a pod.yaml:</p> <pre><code>kubectl run busybox --image=busybox --dry-run=client -o yaml -- /bin/sh -c 'some commands' &g...
humiliatedpenguin
<p>Expanding on my comment:</p> <p>A list in YAML is a series of items marked with a leading <code>-</code>, like this list of strings:</p> <pre><code>- one - two - three </code></pre> <p>Or this list of dictionaries:</p> <pre><code>containers: - image: busybox name: busybox - image: nginx name: nginx </cod...
larsks
<p>Basically I want to automate this task where I have some namespaces in Kubernetes I need to delete and others that I want to leave alone. These namespaces contain the word nginx. So I was thinking in order to do that I could get the output of <strong>get namespace</strong> using some regex and store those namespaces...
Jones
<p><code>kubectl get ns</code> doesn't output JSON unless you add <code>-o json</code>. This:</p> <pre><code>array=($(kubectl get ns | jq -r 'keys[]')) </code></pre> <p>Should result in an error like:</p> <pre><code>parse error: Invalid numeric literal at line 1, column 5 </code></pre> <hr /> <p><code>kubectl get ns -o...
larsks
<p>I'm setting up kubernetes cluster with ansible. I get the following error when trying to enable kernel IP routing:</p> <pre><code>Failed to reload sysctl: sysctl: cannot stat /proc/sys/net/bridge/bridge-nf-call-iptables: No such file or directory </code></pre> <p>Is this a bug in ansible or is there something wron...
Tuomas Toivonen
<p>In the playbook, add the following task to load the <code>br_netfilter</code> module:</p> <pre><code>- name: Ensure br_netfilter is enabled. modprobe: name: br_netfilter state: present </code></pre>
geerlingguy
<p>I have a shell script <code>my-script.sh</code> like:</p> <pre class="lang-bash prettyprint-override"><code>#!/bin/bash while true; do echo '1' done </code></pre> <p>I can deploy a bash pod in Kubernetes like:</p> <pre class="lang-bash prettyprint-override"><code>kubectl run my-shell --rm -it --image bash -- bash ...
Vahid
<p>Just drop the <code>-t</code> to <code>kubectl run</code> (because you're reading from stdin, not a terminal) and the <code>-c</code> from bash (because you're passing the script on stdin, not as an argument):</p> <pre><code>$ kubectl run my-shell --rm -i --image docker.io/bash -- bash &lt; my-script.sh If you don't...
larsks
<p>According to documentation (<a href="https://kubernetes.io/docs/concepts/workloads/controllers/cron-jobs/" rel="noreferrer">https://kubernetes.io/docs/concepts/workloads/controllers/cron-jobs/</a>) I can create cron job in k8s with specify timezone like: <code>&quot;CRON_TZ=UTC 0 23 * * *&quot;</code></p> <p>My depl...
yihereg819
<p>The <code>CRON_TZ=&lt;timezone&gt;</code> prefix won't be available yet, not until 1.22. The inclusion in the 1.21 release docs was an error.</p> <p>Originally, the change adding the syntax was <a href="https://github.com/kubernetes/website/pull/29455/files" rel="nofollow noreferrer">included for 1.22</a>, but it ap...
Martijn Pieters
<p>I would like to apply HostRegExp with Traefik as ingress Controller. I have something similar like below with docker as provider in Traefik service. <code>&quot;traefik.http.routers.test.rule=HostRegexp(`{host:.+}`) &amp;&amp; PathPrefix(`/test`)&quot;</code></p> <p>Would like to replicate similar stuff in Kubernete...
road2victory
<p>I don't know if this functionality is exposed through the <code>Ingress</code> provider, but you can do it using an <code>IngressRoute</code> resource. For example, if I have:</p> <pre><code>apiVersion: traefik.io/v1alpha1 kind: IngressRoute metadata: name: example spec: entryPoints: - web routes: - matc...
larsks
<p>I am trying to deploy an admission controller / mutating webhook</p> <p>Image: <a href="https://hub.docker.com/layers/247126140/aagashe/label-webhook/1.2.0/images/sha256-acfe141ca782eb8699a3656a77df49a558a1b09989762dbf263a66732fd00910?context=repo" rel="nofollow noreferrer">https://hub.docker.com/layers/247126140/aa...
learner
<p>The error seems pretty clear: the code is looking for a <code>CERTIFICATE</code> block in a PEM-encoded file, but it is only find a <code>CERTIFICATE REQUEST</code> block. It looks like you're passing a certificate signing request (csr) where the code expects to find an actual SSL certificate. And in fact, looking ...
larsks
<p>I was trying to test one scenario where pod will mount a volume and it will try to write one file to it. Below mentioned yaml works fine when I exclude command and args. However with command and args it fails with &quot;crashloopbackoff&quot;. The describe command is not providing much information for the failure. W...
harsh
<p>You've configured your pod to run a single shell command:</p> <pre><code>command: [&quot;/bin/sh&quot;] args: [&quot;-c&quot;, &quot;echo 'test complete' &gt; /var/testOut.txt&quot;] </code></pre> <p>This means that the pod starts up, runs <code>echo 'test complete' &gt; /var/testOut.txt</code>, and then <em>immedia...
larsks
<p>I have a Kubernetes cluster where a resource is available in multiple types.</p> <p>They are labeled <code>r_Type=r1</code>, <code>r_Type=r2</code>, and so on.</p> <p>I need to start a pod that can run on a number of those types. For just one type, the corresponding YAML file would be simple:</p> <pre class="lang-ya...
Hans
<p>You can't use the set syntax in a <code>nodeSelector</code>; that field is a simple <code>key: value</code> map:</p> <pre><code>$ kubectl explain pod.spec.nodeSelector KIND: Pod VERSION: v1 FIELD: nodeSelector &lt;map[string]string&gt; DESCRIPTION: NodeSelector is a selector which must be true for the...
larsks
<p>I have Kubernetes cluster set up and managed by AKS, and I have access to it with the python client.</p> <p>Thing is that when I'm trying to send patch scale request, I'm getting an error.</p> <p>I've found information about scaling namespaced deployments from python client in the GitHub docs, but it was not clear w...
Roy Levy
<p>The <code>body</code> argument to the <code>patch_namespaced_deployment_scale</code> can be a <a href="http://jsonpatch.com/" rel="noreferrer">JSONPatch</a> document, as @RakeshGupta shows in the comment, but it can also be a partial resource manifest. For example, this works:</p> <pre><code>&gt;&gt;&gt; api_respon...
larsks
<p>I've read like a dozen tutorials like <a href="https://kubernetes.io/docs/concepts/services-networking/service/" rel="nofollow noreferrer">these</a> and many answers like <a href="https://stackoverflow.com/questions/46535057/how-do-pods-on-the-same-node-communicate-with-each-other">these</a> but they couldn't help m...
topkek
<p>First, I would suggest reading <a href="https://kubernetes.io/docs/concepts/services-networking/service/" rel="nofollow noreferrer">the official documentation</a>, which is a reasonably good introduction to the idea of a service in kubernetes.</p> <blockquote> <p>I have only roughly idea what to put into this servic...
larsks
<p>I am a complete newbie to kubernetes and have set up my own cluster on-premises comprising of one master and two workers, using kubeadm, on some virtual machines. I'd like to deploy a sample web application to get some experience working with docker and containers.</p> <p>Now, once I finish using this sample applica...
gis_iguess
<blockquote> <p>How do I &quot;uninstall&quot; the previous software and remove the old containers/images and &quot;install&quot; a new application on the cluster?</p> </blockquote> <p>How did you deploy the application in the first place? Typically, you do the reverse of whatever you did to deploy your manifests...</p...
larsks
<p>Can not find any issues.</p> <p>I have to add several custom http headers to access my dedicate api-server proxy, but no clues available right now. Did I miss something?</p>
AndyChow
<p>This is a dirty hard coded hack to show you how to get the outcome your looking for it's not a fully vetted solution. This method will compile a new version of kubectl that will add your needed headers. Maybe it will at least give you a idea to run with.</p> <p>The reason I wanted to do this is because I put my k...
Kuberchaun
<p>Sorting by simple keys is straightforward and easy. Both of these work just fine.</p> <pre><code>kubectl get nodes --sort-by=.metadata.name -o wide kubectl get nodes --sort-by=.metadata.labels.affinity -o wide </code></pre> <p>I'm trying to now sort by complex keys such as .metadata.labels.&quot;clm.status&quot; or,...
mbsf
<p>It looks like the solution is to escape the dots in your label with <code>\</code>, so for example:</p> <pre><code>kubectl get nodes \ --sort=by=.metadata.labels.kubernetes\\.io/roles </code></pre> <p>Or if you prefer, use single quotes on the outside to avoid having to escape the escape character:</p> <pre><code>...
larsks
<p>I have multiple apps based on the same chart deployed with Helm. Let's imagine you deploy your app multiple times with different configurations:</p> <pre class="lang-sh prettyprint-override"><code>helm install myapp-01 mycharts/myapp helm install myapp-02 mycharts/myapp helm install myapp-03 mycharts/myapp </code></...
jmservera
<p>Thanks to the tip provided by <a href="https://stackoverflow.com/users/213269/jonas">@Jonas</a> I've managed to create a simple structure to deploy and update lots of pods with the same image base.</p> <p>I created a folder structure like this:</p> <pre><code>├── kustomization.yaml ├── base │ ├── deployment.yaml │...
jmservera
<p>What are the defaults for the Kubernetes <code>CrashLoopBackOff</code>?</p> <p>Say, I have a pod:</p> <pre><code>kubectl run mynginx --image nginx -- echo hello </code></pre> <p>And I inspect its status:</p> <pre><code>kubectl get pods -w NAME READY STATUS RESTARTS AGE mynginx 0/1 Pending 0 ...
Maksim Sorokin
<p>Based on <a href="https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle/#restart-policy" rel="nofollow noreferrer">these docs</a>:</p> <blockquote> <p>The restartPolicy applies to all containers in the Pod. restartPolicy only refers to restarts of the containers by the kubelet on the same node. After cont...
larsks
<p>I'm currently trying to setup heketi on kubernetes, i need to create an endpoint like so (i'm using Ansible):</p> <pre><code>- hosts: 'masters' remote_user: kube become: yes become_user: kube vars: ansible_python_interpreter: /usr/bin/python3 tasks: - name: &quot;Create gluster endpoints on kubern...
noname
<p>An <code>Endpoints</code> resource (like a <code>Pod</code>, <code>Service</code>, <code>Deployment</code>, etc) is a <em>namespaced</em> resource: it cannot be created globally; it must be created inside a specific <a href="https://kubernetes.io/docs/concepts/overview/working-with-objects/namespaces/" rel="nofollow...
larsks
<p>I would like to know if there is a way to launch a pod from a yaml but with a custom name.</p> <p>The objective of all this is to be able to add to the pod name something like a user id and then be able to delete it when the user requires it, having this way an unequivocal way to find the pod.</p> <p>It would be som...
AdCerros
<p>You can't do that with <code>kubectl</code>, but you can:</p> <ul> <li><p>Perform the substitution with something like <code>sed</code> and pipe the result to <code>kubectl apply</code>:</p> <pre><code>sed 's/PODNAME/custom-name/' foo.yaml | kubectl apply -f- </code></pre> <p>(This assumes that you have <code>name...
larsks
<p>I use <code>.kube/config</code> to access Kubernetes api on a server. I am wondering does the token in config file ever get expired? How to prevent it from expire?</p>
cometta
<p>the solution is to use kubernetes service account</p>
cometta
<p>I am trying to contact from a customized helm chart to a fully managed Postgres service on azure, and then I have to put the url connection string according to the app I want to deploy.</p> <p>I want to ask which value should be the <code>DATABASE_URL</code> at the helm chart deployment? My situation is the followin...
bgarcial
<p>I think the problem with your connection string is, its <em>username</em> has a special character <code>@</code>, which might be breaking the connection string format and causing the validation error.</p> <p>Your value</p> <pre><code>- name: DATABASE_URL value: &quot;postgres://nmbrs@postgresql-nmb-psfc-stag:$(POS...
Arun P Johny
<p>When running <code>kubectl apply -f ./sftest.yml</code>, I get the following error:</p> <blockquote> <p>Error from server (BadRequest): error when creating &quot;./sftest.yaml&quot;: Service in version &quot;v1&quot; cannot be handled as a Service: json: cannot unmarshal object into Go struct field ServiceSpec.spec...
mordgren
<p>In your Service manifest, the value of <code>ports</code> needs to be an <em>array</em>, not a mapping; see the example <a href="https://kubernetes.io/docs/concepts/services-networking/service/#defining-a-service" rel="nofollow noreferrer">here</a>. That would look like:</p> <pre><code>apiVersion: v1 kind: Service m...
larsks
<p>I'm trying to install Jenkins X on an existing Kubernetes cluster (GKE), using <code>jx boot</code>, but it always gives me the error <code>trying to execute 'jx boot' from a non requirements repo</code></p> <p>In fact, I have tried to use <code>jx install</code>, and it works, but this command is already marked as...
Lewen
<p>Are you trying to execute <code>jx boot</code> from within an existing git repository? Try changing into an empty, non-git directory run <code>jx boot</code> from there. </p> <p><code>jx</code> wants to clone the <a href="https://github.com/jenkins-x/jenkins-x-boot-config" rel="noreferrer">jenkins-x-boot-config</a>...
Hardy
<p>The following says &quot;I can&quot; use <code>get</code> SubjectAccessReview, but then it returns a MethodNotAllowed error. Why?</p> <pre><code>❯ kubectl auth can-i get SubjectAccessReview Warning: resource 'subjectaccessreviews' is not namespace scoped in group 'authorization.k8s.io' yes ❯ kubectl get SubjectAcc...
jersey bean
<p><code>kubectl auth can-i</code> is not wrong.</p> <p>The <code>can-i</code> command is checking cluster RBAC (does there exist a role and rolebinding that grant you access to that operation). It doesn't know or care about &quot;supported methods&quot;. Somewhere there is a role that grants you the <code>get</code> v...
larsks
<p><strong>Heads up</strong>: I need Hyper-V as VM driver because I want to be able to use the ingress addon; using Docker as the driver will not allow the use of addons in Windows.</p> <p>I am using Minikube v1.11.0 and Kubernetes v1.18.3. When I am trying to create and launch a Minikube cluster according to <a href=...
marcuse
<p>Fix On Azure VM in Windows Server 2019:</p> <ol start="0"> <li><p>Check if minikube VM has an IP Address in Networking tab</p> <ul> <li>If <em>NO</em> IP address and no DHCP is running in VM, then go to next step</li> </ul> </li> <li><p>Create <a href="https://learn.microsoft.com/en-us/azure/virtual-machines/windows...
Lydon Ch
<p>Alright, various permutations of this question have been asked and I feel terrible asking; I'm throwing the towel in and was curious if anyone could point me in the right direction (or point out where I'm wrong). I went ahead and tried a number of <a href="https://github.com/kubernetes/ingress-nginx/tree/main/docs/e...
Thomas
<p>The problem you reported in your most recent comment is resolved by looking at the <a href="https://kubernetes.github.io/ingress-nginx/examples/rewrite/" rel="nofollow noreferrer">rewrite example</a> in the nginx-ingress documentation.</p> <p>The <code>rewrite-target</code> annotation configures the ingress such tha...
larsks
<p>I would like to create an argoCD application right from the git repository, ie the gitOps way. I already created a CRD file for the application which looks like this:</p> <pre class="lang-yaml prettyprint-override"><code>apiVersion: argoproj.io/v1alpha1 kind: Application metadata: name: my-service namespace: arg...
Melkis H.
<p>At some point you have to manually apply a manifest to your ArgoCD instance.</p> <p>You can limit that to a single manifest if you utilize the <a href="https://argo-cd.readthedocs.io/en/stable/operator-manual/cluster-bootstrapping/" rel="noreferrer">app-of-apps</a> pattern, in which you have a repository that contai...
larsks
<p>In kubernetes pod yaml specification file, you can set a pod to use the host machine's network using <code>hostNetwork:true</code>.</p> <p>I can't find anywhere a good (suitable for a beginner) explanation of what the <code>hostPID:true</code> and <code>hostIPC:true</code> options mean. Please could someone explain ...
mleonard
<p>they're roughly described within the <a href="https://kubernetes.io/docs/concepts/policy/pod-security-policy/#host-namespaces" rel="noreferrer">Pod Security Policies</a></p> <blockquote> <p><code>hostPID</code> - Use the host’s pid namespace. Optional: Default to false.</p> <p><code>hostIPC</code> - Use the host’s i...
pagid
<p>I'm new to Kubernetes and plan to use Google Kubernetes Engine. Hypothetically speaking, let's say I have a K8s cluster with 2 worker nodes. Each node would have its own pod housing the same application. This application will grab a file from some persistent volume and generate an output file that will be pushed bac...
Adriano Matos
<blockquote> <p>Do the pods inherently know NOT to grab the same file that one pod is already using?</p> </blockquote> <p>Pods are just processes. Two separate processes accessing files from a shared directory are going to run into conflicts unless they have some sort of coordination mechanism.</p> <h2>Option 1</h2> <p...
larsks
<p>I have a devops pipeline divided in three steps:</p> <ul> <li><code>kubectl apply -f configmap.yml</code></li> <li><code>kubectl apply -f deployment.yml</code></li> <li><code>kubectl rollout restart deployment/test-service</code></li> </ul> <p>I think that when the <code>configmap.yml</code> changes the <code>rollou...
freedev
<p>This isn't a direct answer, but it ended up being too long for a comment and I think it's relevant. If you were to apply your manifests using <a href="https://kustomize.io/" rel="nofollow noreferrer"><code>kustomize</code></a> (<em>aka</em> <code>kubectl apply -k</code>), then you get the following behavior:</p> <ul...
larsks
<p>I just installed a new centos server with docker</p> <pre><code>Client: Version: 1.13.1 API version: 1.26 Package version: &lt;unknown&gt; Go version: go1.8.3 Git commit: 774336d/1.13.1 Built: Wed Mar 7 17:06:16 2018 OS/Arch: linux/amd64 Server: Version: 1....
ouatrahim
<p>You can bring up the cluster using your IP address like: oc cluster up --public-hostname=192.168.122.154 </p> <p>This way you should be able to access using <a href="https://master.ouatrahim.com:8443/" rel="nofollow noreferrer">https://master.ouatrahim.com:8443/</a></p>
kumar
<p>You can simply interact with K8s using its REST API. For example to get pods:</p> <pre><code>curl http://IPADDR/api/v1/pods </code></pre> <p>However I can't find any example of authentication based only on curl or REST. All the examples show the usage of <code>kubectl</code> as proxy or as a way to get credentials.<...
collimarco
<p>The <code>kubeconfig</code> file you download when you first install the cluster includes a client certificate and key. For example:</p> <pre><code>clusters: - cluster: certificate-authority-data: ... server: https://api.cluster1.ocp.virt:6443 name: cluster1 contexts: - context: cluster: cluster1 u...
larsks
<p>I am building postgresql on kubernetes, but I cannot persist postgres data. The host is a GCP instance with Ubuntu-20.4. The volumes for disk are using GCP volumes, which are mounted after attaching to the instance.</p> <pre><code>Filesystem 1K-blocks Used Available Use% Mounted on /dev/root 9982728 ...
山村武
<p>The source of your problem is here:</p> <pre><code>volumeMounts: - name: postgredb mountPath: /var/lib/postgresql </code></pre> <p>The <code>postgres</code> image itself mounts a volume on <code>/var/lib/postgresql/data</code>. We can see that if we inspect the image:</p> <pre><code>$ docker image inspect dock...
larsks
<p>To preface: I know this is a bit of duplicate (this question has been asked many times here in different versions) but I can't really find a clear answer for how this is handled on bare metal.</p> <p>The issue: I want to be able to access internal services without needing to port forward for each one. Like accessing...
stewbert
<p>The simplest way to expose a <code>k3s</code> service on your host is just to create a <code>LoadBalancer</code> service. You don't actually need to install a load balancer of any sort; this will expose your service ports on your host.</p> <p>For example, start a pod:</p> <pre><code>k3s kubectl run --image docker.io...
larsks
<p>I have the following CronJob to run a backup of my database, and I'd like the backup files to be appended with the date:</p> <pre class="lang-yaml prettyprint-override"><code>{{- if .Values.postgresqlBackup.enabled }} apiVersion: batch/v1 kind: CronJob metadata: name: postgres-backup spec: schedule: {{ .Values.p...
lordnoob
<p>If you want to use shell substitution, then you need to execute your command <strong>with a shell</strong>. For example:</p> <pre><code>containers: - name: postgres image: postgres:latest imagePullPolicy: IfNotPresent command: - /bin/sh - -c - &gt; pg_dump --username=p...
larsks
<p>I want to run two different commands in two different location inside the kubernetes pod. How can I do it. My approach is below;</p> <pre><code>apiVersion: apps/v1 kind: Deployment metadata: name: wso2is-deployment namespace: tech-ns labels: app: wso2is spec: replicas: 1 selector: matchLabels: ...
Feezan Khattak
<p>You want to pass your multiple commands as a shell script embedded in a call to <code>sh -c</code>, like this:</p> <pre><code>command: - /bin/sh - -c - | cd /home/wso2carbon/wso2is-5.11.0/repository/resources/security/ keytool -exportcert -alias wso2carbon -keystore wso2carbon.jks -rfc -file wso2carbon...
larsks
<p>I am trying to obtain the list of events from a minikube cluster usigh the Python Kubernetes api using the following code:</p> <pre class="lang-py prettyprint-override"><code>from kubernetes import config, client config.load_kube_config() api = client.EventsV1beta1Api() print(api.list_event_for_all_namespaces()) <...
João Pinto
<p>That looks like either a bug in the Python client, or a bug in the OpenAPI specification used to generate the client: clearly, <code>null</code> is a value for <code>eventTime</code> that is supported by the API.</p> <p>I think the only workaround is to monkey-patch the <code>kubernetes.client</code> module so that ...
larsks
<p>When using Istio with Kubernetes, a number of different manifests require the same environment-specific values. For example, the host address is required by both the Gateway (under <code>spec/servers/hosts</code>) and VirtualService (under <code>spec/hosts)</code>. The typical approach to changing the address for di...
Boon
<p>This isn't going to be possible with just Kustomize other than by using multiple patches. Because you're looking to change the value in objects of different types, this can't be done with a single patch. So you could do this:</p> <pre class="lang-yaml prettyprint-override"><code>apiVersion: kustomize.config.k8s.io/v...
larsks
<p>I have a working mongoDB deployment on minikube and I have managed to create a database , collection as well as a user (same as the user referenced in yaml) to do backups on that database.</p> <p>In the yaml file for my backup cron job I need to specify a <strong>MONGODB_URI</strong> parameter and quite frankly I am...
Golide
<p>Given the structure of your <code>Service</code>, you'll need to use the hostname <code>mongodb-service</code> (or <code>mongodb-service.&lt;namesapce&gt;.svc.cluster.local</code>, if you like fully qualified names). The connection URI -- as far as I can tell from <a href="https://www.mongodb.com/docs/manual/referen...
larsks
<p>I have <code>sizeLimit</code> property under <code>emptyDir</code> set to 2Gi in my template base file. I want to remove the <code>sizelimit</code> and just have <code>emptyDir: {}</code>. I've been unable to achieve this using Kustomization overlays. I will detail my folder structure and kustomization yamls below.<...
vishal
<p>NB: This answer assumes a recent version of Kustomize (I'm running 4.5.2 locally). Your examples are using deprecated syntax (the <code>bases</code> section was deprecated <a href="https://github.com/kubernetes-sigs/kustomize/blob/661743c7e5bd8c3d9d6866b6bc0a6f0e0b0512eb/site/content/en/blog/releases/v2.1.0.md#resou...
larsks
<p>I have a Kubernetes cluster with an install of <a href="https://github.com/prometheus-community/helm-charts/tree/main/charts/kube-prometheus-stack" rel="nofollow noreferrer">kube-prometheus-stack</a> (Prometheus 2.27.1, kube-state-metrics v2.0.0)</p> <p>I would like to have a query to return how much time each pod w...
Vladimir Prus
<p>One working solution is this:</p> <pre><code>sum by(namespace, pod) ( (last_over_time(kube_pod_completion_time[1d]) - last_over_time(kube_pod_created[1d])) or (time() - kube_pod_created) ) </code></pre> <p>The first part inside <code>sum</code> handles the case of pods that have terminated. We pic...
Vladimir Prus
<p>I have a problem. In my kubernetes cluster I am running a GitLab image for my own project. This image requires a .crt and .key as certificates for HTTPS usage. I have setup an Ingress resource with a letsencrypt-issuer, which successfully obtains the certificates. But to use those they need to be named as <code>my.d...
A. Vreeswijk
<p>Why are you bothering with this complicated process of creating a new secret? Just rename them in your <code>volumeMounts</code> section by using a <code>subPath</code>:</p> <pre><code>containers: - ... volumeMounts: - name: registry-certs mountPath: /etc/gitlab/ssl/my.dns.com.crt subPath...
larsks
<p>I would like to deploy an ssh bastion jumper as a deployment in a Kubernetes cluster. This should receive its sshd_config as well as the authorized_keys via a ConfigMap or Secret. These can of course change over time, so that a reload of the sshd service becomes necessary.</p> <p>How can I automate this process? Exi...
user5580578
<p>If you mount a <code>ConfigMap</code> as a directory, the directory contents will update when you update the <code>ConfigMap</code> (possibly after a short delay).</p> <p>That means if you were just concerned about your <code>authorized_keys</code> file, you could do something like this:</p> <p>Create the following ...
larsks
<p>So I have a values.yaml file with an string variable representing a database connection string with no quotes looking like this (don't worry, not the real password):</p> <pre><code>ActionLogsConnectionString: Database=ActionLogs;Server=SQL_DEV;User Id=sa;Password=Y19|yx\dySh53&amp;h </code></pre> <p>My goal is to pr...
Dunge
<p>Using <code>toJson</code> or <code>toRawJson</code> is the wrong solution here, because the JSON representation of a string by definition includes the double quotes. <code>&quot;foo&quot;</code> is a JSON string, <code>foo</code> isn't valid JSON.</p> <p>But you're only working with a scalar value, so there's not mu...
larsks
<p>I have a Kubernetes v1.9.3 (no OpenShift) cluster I'd like to manage with ManageIQ (gaprindashvili-3 running as a Docker container).</p> <p>I prepared the k8s cluster to interact with ManageIQ following <a href="http://manageiq.org/docs/guides/providers/kubernetes" rel="nofollow noreferrer">these instructions</a>. ...
Matteo
<p>For the <code>ClusterRole</code> to take effect it must be bound to the group <code>management-infra</code> or user <code>management-admin</code>.</p> <p>Example of creating group binding:</p> <pre><code>kind: ClusterRoleBinding apiVersion: rbac.authorization.k8s.io/v1 metadata: name: read-cluster-state subjects...
lexsys
<p>I am trying to patch a secret using kubectl</p> <pre><code>kubectl patch secret operator-secrets --namespace kube-system --context=cluster1 --patch &quot;'{\&quot;data\&quot;: {\&quot;FOOBAR\&quot;: \&quot;$FOOBAR\&quot;}}'&quot; </code></pre> <p>But I receive the error</p> <blockquote> <p>Error from server (BadRequ...
Rodrigo
<blockquote> <p>If I run the command using echo, it seems to be a valid JSON</p> </blockquote> <p>In fact, it does not. Look carefully at the first character of the output:</p> <pre><code>'{&quot;data&quot;: {&quot;FOOBAR&quot;: &quot;value that I want&quot;}}' </code></pre> <p>Your &quot;JSON&quot; string starts with ...
larsks
<p>All namespaces in my cluster are supposed to trust the same root CA. I have a mono repo with all my Kustomize files, and I'm trying to avoid having to add the root CA certificate everywhere.</p> <p>My idea was to go for something like that in my kustomization files:</p> <pre><code># [project_name]/[namespace_name]/b...
Yohan Courbe
<p>This seems like a good place to use a <a href="https://github.com/kubernetes-sigs/kustomize/blob/master/examples/components.md" rel="nofollow noreferrer">component</a>. For example, if I have my files organized like this:</p> <pre><code>. ├── components │   └── trusted-root-ca │   ├── kustomization.yaml │   ...
larsks
<p>I'm new to k8s and I'm trying to build a distributed system. The idea is that a stateful pod will be spawened for each user.</p> <p>Main services are two Python applications <code>MothershipService</code> and <code>Ship</code>. MothershipService's purpose is to keep track of ship-per-user, do health checks, etc. <co...
Pithikos
<p>One possibility is to use the <code>kubectl port-forward</code> command to expose the pod port locally on your system. For example, if I'm use this deployment to run a simple web server listening on port 8000:</p> <pre><code>apiVersion: apps/v1 kind: Deployment metadata: labels: app: example name: example sp...
larsks
<p>I have deployed a java application (backend) in openshift, and i have spun up 3 pods backend-1-abc, backend-1-xyz and backend-1-def. </p> <p>How can I get the list of all the pod names for this service "backend"? Is it possible to obtain it programatically or is there any endpoint exposed in openshift to obtain thi...
Pramod S
<p>Are you saying you have actually created three separate Pod definitions with those names? Are you not using a DeploymentConfig or StatefulSet?</p> <p>If you were using StatefulSet the names would be predictable.</p> <p>Either way, the Pods would usually be set up with labels and could use a command like:</p> <pre...
Graham Dumpleton
<p>Inventory file (inventory/k8s.yaml):</p> <pre><code>plugin: kubernetes.core.k8s connections: - kubeconfig: ~/.kube/config context: 'cluster-2' </code></pre> <p>Task file (roles/common/tasks/main.yaml):</p> <pre><code># Method 1: Using `kubernetes.core` plugin to list the pod names: - name: Get a list of all po...
RNK
<p>You're trying to use both the kubernetes inventory plugin <strong>and</strong> the <code>k8s_info</code> module, and because of that you're getting conflicting results. The two don't have anything to do with each other.</p> <h2>The inventory module</h2> <p>The kubernetes inventory module is -- I think -- a weird bea...
larsks
<p>I'm using <code>Kubernetes v1.23.16 cluster (One master and three workers)</code> bare metal based.</p> <p>I have created couple of services in a separate namespace. The same as follows.</p> <pre><code>$ kubectl get services --all-namespaces NAMESPACE NAME TYPE CLUSTER-IP EXTERNAL-IP ...
user4948798
<p>An Ingress resource can only refer to Services in the same namespace as the Ingress. To manage two paths on the same hostname that lead to backends in different namespaces, you will need two separate Ingress resources.</p> <p>In the <code>app1</code> namespace:</p> <pre><code>apiVersion: networking.k8s.io/v1 kind: I...
larsks
<p>With kubectl, I know i can run below command if I want to see specific resources YAML file</p> <pre><code>kubectl -n &lt;some namespace&gt; get &lt;some resource&gt; &lt;some resource name&gt; -o yaml </code></pre> <p>How would I get this same data using python's kubernetes-client ? Everything I've found so far only...
jlrivera81
<p>If you take a look at the methods available on an object, e.g.:</p> <pre><code>&gt;&gt;&gt; import kubernetes.config &gt;&gt;&gt; client = kubernetes.config.new_client_from_config() &gt;&gt;&gt; core = kubernetes.client.CoreV1Api(client) &gt;&gt;&gt; res = core.read_namespace('kube-system') &gt;&gt;&gt; dir(res) ['_...
larsks
<p>I want to use the RestApi to update the deployment. and I test it with postman, but always got 415 back.</p> <hr> <p>the info is as follows:</p> <p><strong>type:</strong> PATCH</p> <p><strong>url:</strong> <a href="https://k8sClusterUrl:6443/apis/extensions/v1beta1/namespaces/ns/deployments/peer0" rel="nofollow ...
ling
<p><code>415</code> is invalid media type.</p> <p>In this case, you should be setting the media type as <code>application/json+patch+json</code> (you can see this in the documentation <a href="https://kubernetes.io/docs/reference/federation/extensions/v1beta1/operations/" rel="nofollow noreferrer">here</a>) </p>
Jeff Foster
<p>I have an <code>ingress.yaml</code> with two paths; each to one of my microfrontends. However I'm really struggling to get the rewrite-target to work. mf1 loads correctly, but mf2 doesn't. I've done some research and know I need to use <a href="https://github.com/kubernetes/ingress-nginx/tree/main/docs/examples/rewr...
Furkan Öztürk
<p>You need to use a regular expression capture group in your <code>path</code> expression, and then reference the capture group in your <code>.../rewrite-target</code> annotation.</p> <p>That might look like this:</p> <pre><code>apiVersion: networking.k8s.io/v1 kind: Ingress metadata: name: http-ingress annotation...
larsks
<p>I want to create a script that will run <code>port-forwarding</code> for a pod automatically, for specific pod name(app3, I've multiple apps in this namespace and I need to run just for <code>app3</code> ) when I run this script.</p> <p>e.g.</p> <p><code>kubectl port-forward pods/app3-86499b66d-dfwf7 8000:8000 -n ...
Beno Odr
<pre><code>POD_NAME=`kubectl get pod -n webide-system | grep app3 | sed 's/ .*//'` kubectl port-forward pods/$POD_NAME 8000:8000 -n web </code></pre>
Beta
<p>On a Kubernetes cluster, I have multiple <code>Deployment</code> resources. For security, I am using a sidecar proxy pattern where the <code>Service</code> will proxy traffic to the sidecar, which will ensure authentication before passing on to the deployed application.</p> <p>I am trying to set up Kustomize to do t...
Mike
<blockquote> <p>In summary, I want the overlay to be able to define when the sidecar should be added, and to which specific deployments to add it to.</p> </blockquote> <p>My first thought was that you could have a label that means &quot;apply the sidecar patch&quot;, and use that in the Component:</p> <pre><code>apiVer...
larsks
<p>In the Base Ingress file I have added the following annotation <code>nginx.ingress.kubernetes.io/auth-snippet</code> and it needs to be removed in one of the environment.</p> <p>Base Ingress:</p> <pre><code>apiVersion: networking.k8s.io/v1 kind: Ingress metadata: name: ingress annotations: nginx.ingress.kub...
Container-Man
<p>The path <code>/metadata/annotations/nginx.ingress.kubernetes.io/auth-snippet</code> doesn't work because <code>/</code> is the character that JSONPath uses to separate elements in the document; there's no way for a JSONPath parser to know that the <code>/</code> in <code>nginx.ingress.kubernetes.io/auth-snippet</co...
larsks
<p>I am testing moleculer microservices framework to setting up an infraestructure. I will to use typescript (<a href="https://github.com/moleculerjs/moleculer-template-project-typescript" rel="nofollow noreferrer">https://github.com/moleculerjs/moleculer-template-project-typescript</a>). My idea is according the docum...
dlopezgonzalez
<p>You can separate every microservices into a separated projects, but with Moleculer you don't need it. You can put all services into one project. The development will be easy and fast, and at deploying you can control which services will be loaded. So you can generate one docker image and control the loaded services ...
Icebob
<p>I have an environment made of pods that address their target environment based on an environment variable called <code>CONF_ENV</code> that could be <code>test</code>, <code>stage</code> or <code>prod</code>.</p> <p>The application running inside the Pod has the same source code across environments, the configuratio...
TPPZ
<p>If I understand your goal correctly, I think you may be grossly over-complicating things. I <em>think</em> you want a common properties file defined in your base, but you want to override specific properties in your overlays. Here's one way of doing that.</p> <p>In base, I have:</p> <pre><code>$ cd base $ tree . ├──...
larsks
<p>I am trying to deploy a K8s application using Kustomize. Up to now I have done simple implementations where we have a few of the K8s files such as <code>ingress.yaml</code> with something like the following:</p> <pre><code>apiVersion: extensions/v1beta1 kind: Ingress metadata: name: ingressname namespace: namesp...
nray
<p>Kustomize isn't a templating system and doesn't do variable substitution. It <em>can</em> perform a variety of YAML patching tricks, so one option you have is to start with a base manifest like this:</p> <pre><code>apiVersion: extensions/v1beta1 kind: Ingress metadata: name: ingressname spec: tls: - hosts: [...
larsks
<p>My Elasticsearch7.8.0 is running in OCI OKE (Kubernetes running in Oracle Cloud). I want to setup Elasticsearch backup snapshot with OCI Object store using OCI Amazon S3 Compatibility API. Added repository-s3 plugin and configured ACCESS_KEY and SECRET_KEY in the PODs. While repository, I am getting &quot;s_s_l_peer...
Binoy Thomas
<p>Well you shouldn't be talking to es-backup.OCI_TENANCY.compat.objectstorage.OCI_REGION.oraclecloud.com where your bucket name is part of the domain. You can try it in your browser and you'll get a similar security warning about certs.</p> <p>If you look at <a href="https://docs.cloud.oracle.com/en-us/iaas/Content/Ob...
Chase
<p>Is it possible to provide environment variables which will be set in all pods instead of configuring in each pods spec?</p> <p>If not natively possible in Kubernetes, what would be an efficient method to accomplish it? We have Helm, but that still requires a lot of duplication.</p> <p>This old answer suggested &quot...
sean
<p>You could do this using a <a href="https://kubernetes.io/docs/reference/access-authn-authz/admission-controllers/#mutatingadmissionwebhook" rel="nofollow noreferrer">mutating admission webhook</a> to inject the environment variable into the pod manifest.</p> <p>There are more details on implementing webhooks <a href...
larsks
<p>I refactored my k8s objects to use Kustomization, Components, replacements, patches and got to a good DRY state so that I don't repeat much between 2 apps and between those across dev and test environments. While doing so I am referring to objects outside of the folder (but same repository)</p> <pre><code>components...
bhantol
<p>Yes. ArgoCD runs <code>kustomize build</code> to realize your manifests before trying to apply them to the cluster. ArgoCD doesn't care which files have changed; it simply cares that the manifests produced by <code>kustomize build</code> differ (or not) from what is currently deployed in the cluster.</p>
larsks
<p>I created a Kubernetes cluster through Kops. The configuration and the ssh keys were in a machine that I don't have access to anymore. Is it possible to ssh to the nodes through kops even if I have lost the key? I see there is a command - </p> <blockquote> <p>kops get secrets</p> </blockquote> <p>This gives me a...
Anshul Tripathi
<p>You can't recover the private key, but you should be able install a new public key following this procedure:</p> <pre><code>kops delete secret --name &lt;clustername&gt; sshpublickey admin kops create secret --name &lt;clustername&gt; sshpublickey admin -i ~/.ssh/newkey.pub kops update cluster --yes to reconfigure ...
Ben W.
<p>I want to use the ClusterRole <strong>edit</strong> for some users of my Kubernetes cluster (<a href="https://kubernetes.io/docs/reference/access-authn-authz/rbac/#user-facing-roles" rel="nofollow noreferrer">https://kubernetes.io/docs/reference/access-authn-authz/rbac/#user-facing-roles</a>).</p> <p>However, it is ...
tobias
<p>The <code>edit</code> role gives only <em>read</em> access to <code>resourcequotas</code> and <code>limitranges</code>:</p> <pre><code>- apiGroups: - &quot;&quot; resources: - bindings - events - limitranges - namespaces/status - pods/log - pods/status - replicationcontrollers/status - resourcequ...
larsks
<p>I am learning about k8s and I am trying to make a deployment out of mongo db. This are my yamls</p> <p>Deployment</p> <pre class="lang-yaml prettyprint-override"><code>apiVersion: apps/v1 kind: Deployment metadata: name: mongodb-deployment labels: app: mongodb spec: replicas: 2 selector: matchLabels:...
sebsmgzz
<p>If you look at the logs for the failing pod, you will see:</p> <pre><code>$ k logs deploy/mongodb-deployment error: missing 'MONGO_INITDB_ROOT_USERNAME' or 'MONGO_INITDB_ROOT_PASSWORD' both must be specified for a user to be created </code></pre> <p>This gives us an idea where we should look for the source o...
larsks
<p>I was looking at step-by-step tutorial on how to run my spring boot, mysql-backed app using AWS EKS (Elastic Container service for Kubernetes) using the existing SSL wildcard certificate and wasn't able to find a complete solution. </p> <p>The app is a standard Spring boot self-contained application backed by MySQL...
Bostone
<p>This a step-by-step tutorial. Please don't proceed forward until the previous step is complete. </p> <p><strong>CREATE EKS CLUSTER</strong></p> <p>Follow <a href="https://docs.aws.amazon.com/eks/latest/userguide/getting-started.html" rel="nofollow noreferrer">the standard tutorial</a> to create EKS cluster. Don't ...
Bostone
<p>When a POD is terminating, how to get correct status <strong>Terminating</strong> using Kubernetes <strong>REST</strong> API. I am not able to figure it out. But <strong>kubectl</strong> always report correct status, and it also uses REST API to do that.</p> <p>What magic am I missing in REST API ? does it call tw...
SuVeRa
<p>You are not the <a href="https://github.com/kubernetes/kubernetes/issues/22839" rel="nofollow noreferrer">first person to ask this question</a>. The answer appears to be that <code>kubectl</code> inspects <code>metadata.deletionTimestamp</code>; if this exists (and, presumably, has a non-null value) then the pod is ...
larsks