prompt
stringlengths
65
38.7k
response
stringlengths
41
29.1k
<p>I have default nginx file which I am copying on /etc/nginx/sites-available/ location, when I do certain changes in default file the changes are not getting reflected in that file under pod.</p> <p>I have mentioned the copy command to copy default file under /etc/nginx/sites-available/, wanted to know if this default file is being auto generated by nginx as a result not able to reflect my changes. Is there any way to change default file?</p> <p>I tried by directly changing the default file inside pod but once pod gets restart changes will be lost.</p> <p>default file</p> <pre><code>## # You should look at the following URL's in order to grasp a solid understanding # of Nginx configuration files in order to fully unleash the power of Nginx. # http://wiki.nginx.org/Pitfalls # http://wiki.nginx.org/QuickStart # http://wiki.nginx.org/Configuration # # Generally, you will want to move this file somewhere, and start with a clean # file but keep this around for reference. Or just disable in sites-enabled. # # Please see /usr/share/doc/nginx-doc/examples/ for more detailed examples. ## # Default server configuration # server { listen 80 default_server; listen [::]:80 default_server; # SSL configuration # # listen 443 ssl default_server; # listen [::]:443 ssl default_server; # # Self signed certs generated by the ssl-cert package # Don't use them in a production server! # # include snippets/snakeoil.conf; root /var/www/html; # Add index.php to the list if you are using PHP index index.html index.htm index.nginx-debian.html; server_name _; location / { # First attempt to serve request as file, then # as directory, then fall back to displaying a 404. try_files $uri $uri/ =404; #Sample testing to the file } # pass the PHP scripts to FastCGI server listening on 127.0.0.1:8000 # location ~ \.php$ { include snippets/fastcgi-php.conf; # # With php5-cgi alone: # fastcgi_pass 127.0.0.1:9000; # # With php5-fpm: fastcgi_pass unix:/var/run/php5-fpm.sock; } # deny access to .htaccess files, if Apache's document root # concurs with nginx's one # #location ~ /\.ht { # deny all; #} } # Virtual Host configuration for example.com # # You can move that to a different file under sites-available/ and symlink that # to sites-enabled/ to enable it. # #server { # listen 80; # listen [::]:80; # # server_name example.com; # # root /var/www/example.com; # index index.html; # # location / { # try_files $uri $uri/ =404; # } #} </code></pre> <p>Dockerfile</p> <pre><code>FROM node:12.10.0 ENV APP_ROOT /usr/src/webapp/ ENV DOC_ROOT /var/www/html/ ENV DEV_ENV development ENV DEV_BASE_HREF https://app.com/app-development/ RUN mkdir -p $APP_ROOT $DOC_ROOT RUN chmod 777 $DOC_ROOT COPY . $APP_ROOT RUN chmod 777 init.sh RUN apt-get update \ &amp;&amp; apt-get install nginx -y RUN npm cache clean --force \ &amp;&amp; npm rebuild node-sass \ &amp;&amp; npm install -g @angular/cli@v1.6.5 --unsafe RUN rm -rf /etc/nginx/sites-available/default COPY default /etc/nginx/sites-available/default RUN ls /etc/nginx/sites-available &amp;&amp; cat /etc/nginx/sites-available/default RUN npm cache clear --force &amp;&amp; npm install --no-shrinkwrap --update-binary RUN node --max_old_space_size=8192 ./node_modules/@angular/cli/bin/ng build --prod --env=prod -extract-css false --base-href $DEV_BASE_HREF --output-path=./dist EXPOSE 80 ENTRYPOINT [&quot;/bin/bash&quot;, &quot;init.sh&quot;] CMD [&quot;dev&quot;] </code></pre>
<p>Not sure why you are using the Nginx and Node both in single Dockerfile</p> <p>ideally, you should be running the single process inside the container.</p> <pre><code>COPY ./nginx/default.conf /etc/nginx/nginx.conf </code></pre> <p>You can overwrite the file inside the Dockerfile like above.</p> <pre><code>COPY default /etc/nginx/sites-available/default </code></pre> <p>Make sure your file is getting removed or else you can run the remove command</p> <pre><code>RUN ls /etc/nginx/sites-available &amp;&amp; cat /etc/nginx/sites-available/default </code></pre> <p>verify actually your file getting placed into <strong>docker</strong></p> <pre><code>RUN npm cache clean --force \ &amp;&amp; npm rebuild node-sass \ &amp;&amp; npm install -g @angular/cli@v1.6.5 --unsafe RUN rm /etc/nginx/sites-available/default COPY default /etc/nginx/sites-available/ RUN ls /etc/nginx/sites-available &amp;&amp; cat /etc/nginx/sites-available/default RUN npm cache clear --force &amp;&amp; npm install --no-shrinkwrap --update-binary </code></pre>
<p>I used Nats Streaming before for my microservices based on Docker and Kubernetes and node.js but because Nats Streaming is currently being deprecated I want to migrate to NATS and NATS JetStream.</p> <p>This is the deployment yaml config file that I used for NATS Streaming server in my k8s folder which is using by skaffold to apply and it works fine:</p> <pre><code>apiVersion: apps/v1 kind: Deployment metadata: name: nats-depl spec: replicas: 1 selector: matchLabels: app: nats template: metadata: labels: app: nats spec: containers: - name: nats image: nats-streaming:0.23.2 args: [ '-p', '4222', '-m', '8222', '-hbi', '5s', '-hbt', '5s', '-hbf', '2', '-SD', '-cid', 'adrian', ] --- apiVersion: v1 kind: Service metadata: name: nats-srv spec: selector: app: nats ports: - name: client protocol: TCP port: 4222 targetPort: 4222 - name: monitoring protocol: TCP port: 8222 targetPort: 8222 </code></pre> <p>The cluster named <code>adrian</code> and I could connect to NATS Streaming server as a client like this in my node.js application:</p> <pre><code>import nats from 'node-nats-streaming'; const stan = nats.connect( 'adrian', 'abc', { url: &quot;http://localhost:4222&quot; } ); </code></pre> <p>Now I want to migrate to NATS and NATS JetStream. So, I changed my Kubernetes deployment config to this:</p> <pre><code>apiVersion: apps/v1 kind: Deployment metadata: name: nats-depl spec: replicas: 1 selector: matchLabels: app: nats template: metadata: labels: app: nats spec: containers: - name: nats image: nats args: [ '-p', '4222', '-m', '8222', '-D', '-js', '--cluster_name', 'adrian', ] --- apiVersion: v1 kind: Service metadata: name: nats-srv spec: selector: app: nats ports: - name: client protocol: TCP port: 4222 targetPort: 4222 - name: monitoring protocol: TCP port: 8222 targetPort: 8222 </code></pre> <p>And when I try new NATS client's connect method to connect to NATS server like below:</p> <pre><code>import { connect } from 'nats'; const natsPublisher = async () =&gt; { try { const nc = await connect( { servers: &quot;http://localhost:4222&quot; } ); console.log(`connected to ${nc.getServer()}`); } catch ( error ) { console.log( '--- NATS ERROR: ', error ) } } natsPublisher(); </code></pre> <p>I get this error in terminal:</p> <pre><code>--- NATS ERROR: NatsError: CONNECTION_REFUSED at Function.errorForCode (E:\Projects\express-projects\adrian-microservices\nats-test\node_modules\nats\nats-base-client\error.ts:119:12) at NodeTransport.&lt;anonymous&gt; (E:\Projects\express-projects\adrian-microservices\nats-test\node_modules\nats\src\node_transport.ts:92:21) at Generator.throw (&lt;anonymous&gt;) at rejected (E:\Projects\express-projects\adrian-microservices\nats-test\node_modules\nats\lib\src\node_transport.js:6:65) at processTicksAndRejections (node:internal/process/task_queues:96:5) { code: 'CONNECTION_REFUSED', chainedError: Error: connect ECONNREFUSED 127.0.0.1:4222 at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1161:16) { errno: -4078, code: 'ECONNREFUSED', syscall: 'connect', address: '127.0.0.1', port: 4222 } } </code></pre> <p><strong>So how could I solve the issue and connect to NATS without any problem?</strong></p> <p>Any help would be appreciated.</p>
<p>After some trials and errors and some research, I realized that it is actually better to use Helm (Kubernetes package manager) to have a complete and correct manifest for things like NATS or Kafka or ElasticSearch, etc... So, after installing Helm Kubernetes package manager you can install NATS in your Kubernetes cluster by running a command as simple as &quot;<code>helm install my-nats nats/nats</code>&quot; and then you have NATS up and running there in your Kubernetes.</p> <p>But in this case with the manifest I came up with for NATS unlike before that it was common to connect to NATS server from node.js client using <code>localhost</code> and external access was possible, you can connect to NATS server from node.js client by using service name like this, that is perhaps even more appropriate:</p> <pre><code>import { connect } from 'nats'; const natsPublisher = async () =&gt; { try { const nc = await connect( { servers: &quot;http://nats-srv:4222&quot; } ); console.log( `connected to ${ nc.getServer() }` ); } catch ( error ) { console.log( 'NATS ERROR: ', error ) } } </code></pre> <p>And this is my terminal logs after connecting to NATS:</p> <pre><code>[taxonomy] Listening on port 3000! [taxonomy] connected to nats-srv:4222 </code></pre> <p>Hopefully, that'll be helpful for others.</p>
<p>I have an ingress pod deployed with Scaleway on a Kubernetes cluster and it exists in the kube-system namespace. I accidentally created a load balancer service on the <code>default</code> namespace and I don't want to delete and recreate it a new one on the <code>kube-system</code> namespace so I want my Load balancer in the <code>default</code> namespace to have the ingress pods as endpoints:</p> <pre><code>apiVersion: v1 kind: Service metadata: name: ecom-loadbalancer labels: app.kubernetes.io/name: ingress-nginx app.kubernetes.io/part-of: ingress-nginx spec: selector: app.kubernetes.io/name: ingress-nginx app.kubernetes.io/part-of: ingress-nginx ports: - port: 443 targetPort: 443 type: LoadBalancer </code></pre> <p>Is that possible? Is there something I should add in the selector fields?</p> <hr /> <p>I tried creating a <code>clusterIP</code> service in the <code>kube-system</code> namespace that communicates with the ingress pods, it worked.</p> <pre><code>apiVersion: v1 kind: Service metadata: name: ecom-loadbalancer namespace: kube-system labels: app.kubernetes.io/name: ingress-nginx app.kubernetes.io/part-of: ingress-nginx spec: selector: app.kubernetes.io/name: ingress-nginx app.kubernetes.io/part-of: ingress-nginx ports: - port: 443 targetPort: 443 type: ClusterIP </code></pre> <p>Then, I tried referencing that service to my <code>loadbalancer</code> in the default namespace like that:</p> <pre><code>apiVersion: v1 kind: Service metadata: name: ecom-loadbalancer spec: type: ExternalName externalName: ecom-loadbalancer.kube-system.svc.cluster.local ports: - port: 443 targetPort: 443 type: LoadBalancer </code></pre> <p>But no result. The <code>clusterIP</code> points to the Ingress pods, but the load balancer remains without endpoints.</p>
<p>At least three reasons why you need to re-create it properly (2 technical and advice):</p> <ol> <li><p><code>ExternalName</code> is used for accessing external services or services in other namespaces. The way it works is when looking up the service's name happens, CNAME will be returned. So in other words it works for egress connections when requests should be directed somewhere else.</p> <p>See <a href="https://kubernetes.io/docs/concepts/services-networking/service/#externalname" rel="nofollow noreferrer">service - externalname type</a> and use cases <a href="https://akomljen.com/kubernetes-tips-part-1/" rel="nofollow noreferrer">Kubernetes Tips - Part 1 blog post from Alen Komljen</a>.</p> <p>Your use case is different. You want to get requests from outside the kubernetes cluster to exposed loadbalancer and then direct traffic from it to another service within the cluster. It's not possible by built-in kubernetes terms, because service can be either <code>LoadBalancer</code> or <code>ExternalName</code>. You can see in your last manifest there are <strong>two</strong> types which will not work at all. See <a href="https://kubernetes.io/docs/concepts/services-networking/service/#publishing-services-service-types" rel="nofollow noreferrer">service types</a>.</p> </li> <li><p>Avoid unnecessary complexity. It will be hard to keep track of everything since there will be more and more services and other parts.</p> </li> <li><p>Based on documentation it's generally possible to have issues using <code>ExternalName</code> with some protocols:</p> <blockquote> <p>Warning: You may have trouble using ExternalName for some common protocols, including HTTP and HTTPS. If you use ExternalName then the hostname used by clients inside your cluster is different from the name that the ExternalName references.</p> <p>For protocols that use hostnames this difference may lead to errors or unexpected responses. HTTP requests will have a Host: header that the origin server does not recognize; TLS servers will not be able to provide a certificate matching the hostname that the client connected to.</p> </blockquote> <p><a href="https://kubernetes.io/docs/concepts/services-networking/service/#externalname" rel="nofollow noreferrer">Reference - Warning</a></p> </li> </ol>
<p>Is it possible to have multiple databse in a cluster with Crunchydata (postgres)? When I create a cluster with &quot;pgo create cluster&quot; command I can specify only one database.</p> <pre><code> -d, --database string If specified, sets the name of the initial database that is created for the user. Defaults to the value set in the PostgreSQL Operator configuration, or if that is not present, the name of the cluster </code></pre> <p>But I need multiple database per cluster, and I can't find any official way to create them.</p> <p>Another question: How can I find the &quot;superuser&quot; username and password to login to PGOAmin Web?</p> <p>Thanks a lot.</p>
<p>This could be useful, however it stated:</p> <blockquote> <p>&quot;It may make more sense to have each of your databases in its own cluster if you want to have them spread out over your Kubernetes topology.&quot;</p> </blockquote> <p><a href="https://github.com/CrunchyData/postgres-operator/issues/2655" rel="nofollow noreferrer">https://github.com/CrunchyData/postgres-operator/issues/2655</a></p>
<p>Let's say you are using either <em><strong>ServiceFabric</strong></em> or <em><strong>Kubernetes</strong></em>, and you are hosting a transaction data warehouse microservice (maybe a bad example, but suppose all it dose is a simple CQRS architecture consisting of Id of sender, receiver, date and the payment amount, writes and reads into the DB).</p> <p>For the sake of the argument, if we say that this microservice needs to be replicated among different geographic locations to insure that the data will be recoverable if one database goes down.</p> <p>Now the naïve approach that I'm thinking is to have an event which gets fired when the transaction is received, and the orchestrator microservice will except to receive event-processed acknowledgment within specific timeframe. But the question stays that what about the database ? what will happen when we will scale out the microservices and a new microservice instances will be raise up? they will write to the same database, no ?</p> <p>One of solutions can be to put the database within the docker, and let it be owned by each replica, is this a good solution?</p> <p>Please share your thoughts and best practices.</p>
<blockquote> <p>what will happen when we will scale out the microservices and a new microservice instances will be raise up? they will write to the same database?</p> </blockquote> <p>Yes, the instances of your service, all share the same logical database. To achieve high availability, you typically run a distributed database cluster, but it appears as a single database system for your service.</p> <blockquote> <p>One of solutions can be to put the database within the docker, and let it be owned by each replica, is this a good solution?</p> </blockquote> <p>No, you typically want that all your instances of your service <strong>see the same consistent data</strong>. E.g. a read-request sent to two different instances of your service, should respond with the same data.</p> <p>If the database becomes your bottleneck, then you can mitigate that by implementing caching or shard your data, or serve read-requests from specific read-instances.</p>
<p>I have microservices running within EKS 1.22. Is there a possible way to check the microservice communication also pod-to-pod communication within the cluster through CLI?</p>
<p>Everything out of the box should work properly (assuming you have <a href="https://aws.amazon.com/eks/" rel="nofollow noreferrer">AWS EKS</a>).</p> <p>I think this article - <a href="https://kubernetes.io/docs/tasks/debug-application-cluster/debug-service/" rel="nofollow noreferrer">Debug Services</a> has very helpful hints.</p> <p>Let's first check pod to pod communication using trival method - <code>ping</code> command. I created two NGINX deployments (one in default namespace, second one in namespace <code>test</code>):</p> <pre><code>kubectl create deployment nginx --image=nginx kubectl create deployment nginx --image=nginx -n test </code></pre> <p>Now I will check IP addresses of both of them:</p> <pre><code>user@shell:~$ kubectl get pods -o wide NAME READY STATUS RESTARTS AGE IP nginx-6799fc88d8-jxpj4 1/1 Running 0 3m13s 172.17.0.2 </code></pre> <p>And also in <code>test</code> namespace:</p> <pre><code>user@shell:~$ kubectl get pods -o wide -n test NAME READY STATUS RESTARTS AGE IP nginx-6799fc88d8-z2glk 1/1 Running 0 103s 172.17.0.4 </code></pre> <p>Now I will <a href="https://kubernetes.io/docs/tasks/debug-application-cluster/get-shell-running-container/" rel="nofollow noreferrer">execute into one pod</a> and check connectivity to the second one:</p> <pre><code>user@shell:~$ kubectl exec -it nginx-6799fc88d8-jxpj4 -- sh # apt update Hit:1 http://security.debian.org/debian-security bullseye-security InRelease ... All packages are up to date. # apt-get install inetutils-ping Reading package lists... Done ... Setting up inetutils-ping (2:2.0-1) ... # ping 172.17.0.4 PING 172.17.0.4 (172.17.0.4): 56 data bytes 64 bytes from 172.17.0.4: icmp_seq=0 ttl=64 time=0.058 ms 64 bytes from 172.17.0.4: icmp_seq=1 ttl=64 time=0.123 ms </code></pre> <p>Okay, so the pod to pod connection is working. Keep in mind that container images are minimal, so you may install <code>ping</code> as I did in my example. Also, depending on your application you can use different methods for checking connectivity - I could use <code>curl</code> command as well and I will get the standard NGINX home page.</p> <p>Now time to create <a href="https://kubernetes.io/docs/concepts/services-networking/service/" rel="nofollow noreferrer">services</a> (I am assuming this is what you mean by microservice) and test connectivity. Service is an abstract mechanism for exposing pods on a network. So we can test connectivity either by getting list of endpoints - IP address of the pods associated with this service - <code>kubectl get endpoints my-service</code>, and then checking pod to pod connection like in previous example, or we can just <code>curl</code> service IP address/hostname. For hostname between namespaces it's little bit different! Check below:</p> <p>Let's create deployments with 3 replicas:</p> <pre><code>kubectl create deployment nginx --image=nginx --replicas=3 kubectl create deployment nginx --image=nginx --replicas=3 -n test </code></pre> <p>For each deployment we will <a href="https://kubernetes.io/docs/tutorials/stateless-application/expose-external-ip-address/#creating-a-service-for-an-application-running-in-five-pods" rel="nofollow noreferrer">create service using <code>kubectl expose</code></a>:</p> <pre><code>kubectl expose deployment nginx --name=my-service --port=80 kubectl expose deployment nginx --name=my-service-test --port=80 -n test </code></pre> <p>Time to get IP addresses of the services:</p> <pre><code>user@shell:~$ kubectl get svc NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE kubernetes ClusterIP 10.96.0.1 &lt;none&gt; 443/TCP 64d my-service ClusterIP 10.107.224.54 &lt;none&gt; 80/TCP 12m </code></pre> <p>And in <code>test</code> namespace:</p> <pre><code>user@shell:~$ kubectl get svc -n test NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE my-service-test ClusterIP 10.110.51.62 &lt;none&gt; 80/TCP 8s </code></pre> <p>I will exec into pod in default namespace and <code>curl</code> IP address of the <code>my-service-test</code> in second namespace:</p> <pre><code>user@shell:~$ kubectl exec -it nginx-6799fc88d8-w5q8s -- sh # curl 10.110.51.62 &lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt; &lt;title&gt;Welcome to nginx!&lt;/title&gt; &lt;style&gt; </code></pre> <p>Okay, it's working... Let's try with hostname:</p> <pre><code># curl my-service-test curl: (6) Could not resolve host: my-service-test </code></pre> <p>Not working... why? Let's check <code>/etc/resolv.conf</code> file:</p> <pre><code># cat resolv.conf nameserver 10.96.0.10 search test.svc.cluster.local svc.cluster.local cluster.local options ndots:5 </code></pre> <p>It's looking for <a href="https://kubernetes.io/docs/tasks/debug-application-cluster/debug-service/#does-the-service-work-by-dns-name" rel="nofollow noreferrer">hostnames only in namespace where pod is located</a>.</p> <p>So pod in the <code>test</code> namespace will have something like:</p> <pre><code># cat resolv.conf nameserver 10.96.0.10 search test.svc.cluster.local svc.cluster.local cluster.local options ndots:5 </code></pre> <p>Let's try to curl <code>my-service-test.test.svc.cluster.local</code> from pod in default namespace:</p> <pre><code># curl my-service-test.test.svc.cluster.local &lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt; &lt;title&gt;Welcome to nginx!&lt;/title&gt; </code></pre> <p>It's working.</p> <p>To sum up:</p> <ul> <li>communication between pods in cluster should work properly between all namespaces (assuming that you have proper <a href="https://kubernetes.io/docs/concepts/extend-kubernetes/compute-storage-net/network-plugins/" rel="nofollow noreferrer">CNI plugin</a> installed, on AWS EKS you have)</li> <li>pods containers are in most cases Linux containers so just use <a href="https://geekflare.com/linux-test-network-connectivity/" rel="nofollow noreferrer">Linux tools</a> to check connectivity (like <code>ping</code> or <code>curl</code>)</li> <li>Services are an abstract mechanism for exposing pods on a network, you can connect to them for example using <code>curl</code> command</li> <li>IP addresses are cluster wide, hostnames are namespace wide - if you want to connect to the resource from the other namespace you need to use fully-qualified name (it applies for services, pods...)</li> </ul> <p>Also check these articles:</p> <ul> <li><a href="https://kubernetes.io/docs/tasks/administer-cluster/access-cluster-services/" rel="nofollow noreferrer">Access Services Running on Clusters | Kubernetes</a></li> <li><a href="https://kubernetes.io/docs/concepts/services-networking/service/" rel="nofollow noreferrer">Service | Kubernetes</a></li> <li><a href="https://kubernetes.io/docs/tasks/debug-application-cluster/debug-service/" rel="nofollow noreferrer">Debug Services | Kubernetes</a></li> <li><a href="https://kubernetes.io/docs/concepts/services-networking/dns-pod-service/" rel="nofollow noreferrer">DNS for Services and Pods | Kubernetes</a></li> </ul>
<p>I am using Azure Kubernetes Services with K8S version 1.20.9 and have following K8S deployment</p> <p>Version 1:</p> <pre><code>apiVersion: apps/v1 kind: Deployment metadata: namespace: test name: busybox-deployment labels: app: busybox spec: replicas: 1 strategy: type: RollingUpdate selector: matchLabels: app: busybox template: metadata: labels: app: busybox spec: containers: - name: busybox image: busybox imagePullPolicy: IfNotPresent command: ['sh', '-c', 'echo Container 1 is Running ; sleep 3600'] env: - name: KEY_1 value: VALUE_1 </code></pre> <p>I deploy with <code>kubectl apply</code> it and check the value of the <code>KEY_1</code> environment variable - it is correctly set to <code>VALUE_1</code>.</p> <p>Then I deploy 2 more versions (again via <code>kubectl apply</code>) where I change the key-value pair in the env section like this effectively deleting the old environment variable and creating a new one:</p> <p>Version 2:</p> <pre><code> env: - name: KEY_2 value: VALUE_2 </code></pre> <p>Version 3:</p> <pre><code> env: - name: KEY_3 value: VALUE_3 </code></pre> <p>After each deploy I check the environment variables and they are fine - version 2 contains the <code>KEY_2:VALUE_2</code> pair and version 3 contains the <code>KEY_3:VALUE_3</code> pair.</p> <p>Now I rollback to version 2 by invoking</p> <pre><code>kubectl rollout undo deployment ... </code></pre> <p>This is also correctly working and now we have the <code>KEY_2:VALUE_2</code> pair as environment variables.</p> <p>However, if I deploy version 3 again the container and the deployment descriptor have both the <code>KEY_2:VALUE_2</code> and the <code>KEY_3:VALUE</code> as environment variables. This matches none of the deployed descriptors because they always contain only a single environment variable. Subsequent deployments result in the same behavior until I manually edit and delete the unnecessary property.</p> <p>I read some explanations like <a href="https://blog.atomist.com/kubernetes-apply-replace-patch/" rel="nofollow noreferrer">this nice article</a> where it is explained that <code>kubectl apply</code> would remove old properties, while patch would not.</p> <p>However this does not happen when &quot;undo&quot; is performed. Any idea why?</p> <p>Thank you.</p>
<p>This is a known problem with <code>rollout undo</code>, reported here <a href="https://github.com/kubernetes/kubernetes/issues/94698" rel="nofollow noreferrer">#94698</a>, here <a href="https://github.com/kubernetes/kubernetes/issues/25236" rel="nofollow noreferrer">#25236</a>, and here <a href="https://github.com/kubernetes/kubernetes/issues/22512" rel="nofollow noreferrer">#22512</a>.</p> <p>In layman terms - <code>kubectl</code> incorrectly calculates differences and merges changes, becacuse <code>undo</code> does not properly load previous configuration.</p> <p>More about how K8s calculates differences can be found in the <a href="https://kubernetes.io/docs/tasks/manage-kubernetes-objects/declarative-config/#how-apply-calculates-differences-and-merges-changes" rel="nofollow noreferrer">docs</a>.</p> <p>Workaround is to update manually last-applied-configuration before re-applying another deployment from config file</p> <pre class="lang-text prettyprint-override"><code>kubectl apply set-last-applied -f Deployment_v2.yaml -o yaml </code></pre>
<p>I have a Kubernetes cluster with three control and three worker nodes. To install Ceph I'm using rook. After the installation, only the worker nodes are included in the Ceph cluster - but not the controller nodes.</p> <p>The configuration snippet:</p> <pre><code>storage: useAllNodes: true useAllDevices: true </code></pre> <p>Is there an easy way to also include the controller nodes in the Ceph cluster? Or: do I need to explicitly list all controller and worker nodes in the storage nodes list?</p>
<p>The root cause for the problem was, that the master nodes were tainted in a way that no 'normal' pod was allowed to run there.</p> <p>Adapting the <code>cluster.yaml</code> configuration of rook and adding the following lines which explicitly allowed the ceph pods run also on master nodes solved the problem:</p> <pre><code>placement: all: tolerations: - effect: NoSchedule key: node-role.kubernetes.io/master </code></pre> <p>Thanks a lot to Hackaholic who pointed me in this direction.</p> <p><strong>Update 2024-03:</strong> The above solution stopped working for me using kubernetes 1.26.3 and kubespray 1.10.13. IMHO one of the reasons is, that <a href="https://kubernetes.io/docs/reference/labels-annotations-taints/#node-role-kubernetes-io-master-taint" rel="nofollow noreferrer">the <code>master</code> label is deprecated</a>. Using the deprecated master and new control-plane label works for me - specifying only one does not. So the current solution looks like:</p> <pre><code>placement: all: tolerations: - effect: NoSchedule key: node-role.kubernetes.io/control-plane - effect: NoSchedule key: node-role.kubernetes.io/master </code></pre>
<p>I am trying to pass JVM args to Docker image of Spring boot app on Kubernetes. Specifically, I wanted to pass these three arguments:</p> <pre><code>-Djavax.net.ssl.trustStore=/certs/truststore/cacerts -Djavax.net.ssl.trustStorePassword=password -Djavax.net.debug=ssl </code></pre> <p>I tried adding it to &quot;env&quot; section with name as &quot;JAVA_OPTS&quot;, &quot;JDK_JAVA_OPTIONS&quot; and &quot;JAVA_TOOL_OPTIONS&quot;, none of which seemed like they were working.</p> <p>I also tried adding it under &quot;args&quot; section, that did not work either. At best I get no change in behaviour at all, at worst my pods won't start at all with this error:</p> <blockquote> <p>Error: failed to create containerd task: OCI runtime create failed: container_linux.go:380: starting container process caused: process_linux.go:545: container init caused: setenv: invalid argument: unknown</p> </blockquote> <p>Entry point in Dockerfile is defined as such:</p> <pre><code>ENTRYPOINT [&quot;java&quot;,&quot;-jar&quot;,&quot;/app/appname-exec.jar&quot;] </code></pre> <p>Any ideas?</p>
<p>To override the container's default <code>ENTRYPOINT</code> setting, I sometimes do the following:</p> <pre class="lang-yaml prettyprint-override"><code>containers: - name: my-container image: mycontainer:latest command: [&quot;java&quot;] args: [&quot;-Djavax...&quot;, &quot;-Djavax...&quot;, &quot;-jar&quot;, &quot;myapp.jar&quot;] </code></pre> <p>You can define content in the manifest that you would describe in a Dockerfile. In <code>args</code> section, you can describe as many settings as you want.</p>
<p>I am trying to use Ingress in minikube by <code>minikube addons enable ingress</code>. However, currently Ingress cannot be used with minikube when the driver is <code>docker</code> on macOS based on this <a href="https://github.com/kubernetes/minikube/issues/7332" rel="nofollow noreferrer">issue ticket</a>.</p> <p>So I turn to use <code>hyperkit</code> or <code>virtualbox</code> as driver. One image that need to be pulled when enabling Ingress is <code>k8s.gcr.io/ingress-nginx/controller:v0.44.0</code>. However, k8s.gcr.io is blocked in my current location.</p> <p>So I try to use a VPN in global mode for my computer. However, I met <a href="https://github.com/kubernetes/minikube/issues/6296" rel="nofollow noreferrer">this issue</a> that hyperkit is unable to access k8s.gcr.io when the VPN is in use.</p> <p>Then I found this document <a href="https://minikube.sigs.k8s.io/docs/handbook/vpn_and_proxy/" rel="nofollow noreferrer">https://minikube.sigs.k8s.io/docs/handbook/vpn_and_proxy/</a></p> <p>My VPN is listening at 127.0.0.1:1087, I set</p> <pre class="lang-sh prettyprint-override"><code>export HTTP_PROXY=http://127.0.0.1:1087 export HTTPS_PROXY=https://127.0.0.1:1087 export NO_PROXY=localhost,127.0.0.1,10.96.0.0/12,192.168.99.0/24,192.168.39.0/24 </code></pre> <p>Then I tried all these methods to start minikube:</p> <pre class="lang-sh prettyprint-override"><code>minikube start --driver=hyperkit minikube start --driver=virtualbox minikube start --driver=hyperkit --docker-env HTTP_PROXY=http://127.0.0.1:1087 --docker-env HTTPS_PROXY=https://127.0.0.1:1087 --docker-env NO_PROXY=localhost,127.0.0.1,10.96.0.0/12,192.168.99.0/24,192.168.39.0/24 </code></pre> <p>But I saw these messages:</p> <pre class="lang-sh prettyprint-override"><code>😄 minikube v1.21.0 on Darwin 11.2.3 ✨ Using the hyperkit driver based on user configuration ❗ Local proxy ignored: not passing HTTP_PROXY=http://127.0.0.1:1087 to docker env. ❗ Local proxy ignored: not passing HTTPS_PROXY=https://127.0.0.1:1087 to docker env. 👍 Starting control plane node minikube in cluster minikube 🔥 Creating hyperkit VM (CPUs=2, Memory=6000MB, Disk=20000MB) ... ❗ Local proxy ignored: not passing HTTP_PROXY=http://127.0.0.1:1087 to docker env. ❗ Local proxy ignored: not passing HTTPS_PROXY=https://127.0.0.1:1087 to docker env. </code></pre> <p>and</p> <pre class="lang-sh prettyprint-override"><code>😄 minikube v1.21.0 on Darwin 11.2.3 ✨ Using the virtualbox driver based on existing profile ❗ Local proxy ignored: not passing HTTP_PROXY=http://127.0.0.1:1087 to docker env. ❗ Local proxy ignored: not passing HTTPS_PROXY=https://127.0.0.1:1087 to docker env. </code></pre> <p>Seems this &quot;user configuration&quot; overwrite my proxy config. But where is this &quot;user configuration&quot;?</p> <p>What is the correct way to set proxy for minikube when the drive <code>hyperkit</code> or <code>virtualbox</code>? Thanks!</p>
<p>My guess is 127.0.0.1 conflicts with the VM's internal 127.0.0.1 address, and that's why it's ignored. You might need to configure your proxy to be your host's network IP instead of 127.0.0.1? You might not even need to configure a proxy? Also, the Virtualbox driver gives me problems with VPN. I have the best luck with the VMware driver, and can also get the HyperKit driver to work if I update the VM's DNS to my host's DNS.</p> <pre><code>minikube start --driver hyperkit minikube ssh sudo resolvectl dns eth0 192.168.0.53 minikube ssh sudo resolvectl domain eth0 example.com </code></pre> <p>I also get the <code>unable to access k8s.gcr.io</code> error when creating the VM, but it doesn't seem to affect things.</p>
<h3>Summary</h3> <p>trying to get <code>minikube-test-ifs.com</code> to map to my deployment using minikube.</p> <h3>What I Did</h3> <p><code>minikube start</code><br> <code>minikube addons enable ingress</code><br> <code>kubectl apply -f &lt;path-to-yaml-below&gt;</code><br> <code>kubectl get ingress</code><br> Added ingress ip mapping to /etc/hosts file in form <code>&lt;ip&gt; minikube-test-ifs.com</code><br> I go to chrome and enter <code>minikube-test-ifs.com</code> and it doesn't load.<br> I get &quot;site can't be reached, took too long to respond&quot;</p> <h4>yaml file</h4> <p>note - it's all in the default namespace, I don't know if that's a problem.<br> There may be a problem in this yaml, but I checked and double checled and see no potential error... unless I'm missing something</p> <pre><code>apiVersion: apps/v1 kind: Deployment metadata: name: test-deployment labels: app: test spec: replicas: 1 selector: matchLabels: app: test template: metadata: labels: app: test spec: containers: - name: test image: nginx ports: - name: client containerPort: 3000 --- apiVersion: v1 kind: Service metadata: name: test-service spec: selector: app: test ports: - name: client protocol: TCP port: 3000 targetPort: 3000 --- apiVersion: networking.k8s.io/v1 kind: Ingress metadata: name: test-ingress annotations: nginx.ingress.kubernetes.io/rewrite-target: / spec: rules: - host: minikube-test-ifs.com http: paths: - path: / pathType: Prefix backend: service: name: test-service port: number: 3000 </code></pre> <h3>OS</h3> <p>Windows 10</p> <h3>Other Stuff</h3> <p>I checked <a href="https://stackoverflow.com/questions/58561682/minikube-with-ingress-example-not-working">Minikube with ingress example not working</a> but I already added to my /etc/hosts and I also tried removing the <code>spec.host</code> but that still doesn't work... <br> also checked <a href="https://stackoverflow.com/questions/64143984/minikube-ingress-nginx-controller-not-working">Minikube Ingress (Nginx Controller) not working</a> but that person has his page already loading so not really relevent to me from what I can tell</p> <h3>Any Ideas?</h3> <p>I watched so many Youtube tutorials on this and I follow everything perfectly. I'm still new to this but I don't see a reason for it not working?</p> <h1>Edit</h1> <p>When I run <code>kubectl describe ingress &lt;ingress&gt;</code> I get:</p> <pre><code> Type Reason Age From Message ---- ------ ---- ---- ------- Normal Sync 8s (x5 over 19m) nginx-ingress-controller Scheduled for sync </code></pre> <p>How do I get it to sync? Is there a problem since it's been &quot;Scheduled for sync&quot; for a long time</p>
<p><strong>Overview</strong></p> <ul> <li>Ingress addon for Minikube using docker driver only works on linux</li> <li>Docker for Windows uses Hyper-V, therefore, if the Docker daemon is running, you will <b>not be able</b> to use VM platforms such as VirtualBox or VMware</li> <li>If you have Windows Pro, Enterprise or Education, you may be able to get it working if you use Hyper-V as your minikube cluster (see Solution 1)</li> <li>If you don't want to upgrade Windows, you can open a minikube cluster on a Linux Virtual Machine and run all your tests there. This will require you to configure some Windows VM settings in order to get your VM's to run (see Solution 2). Note that you can only run <b>either</b> Docker or a VM platform (other than Hyper-V) but <b>not both</b> (See The Second Problem for why this is the case).</li> </ul> <p><strong>The Problem</strong></p> <p>For those of you who are in the same situation as I was, the problem lies in the fact that the minikube ingress addon only works for Linux OS <b>when using the docker driver</b> (Thanks to @rriovall for showing me this <a href="https://minikube.sigs.k8s.io/docs/drivers/docker/#known-issues" rel="nofollow noreferrer">documentation</a>).</p> <p><strong>The Second Problem</strong></p> <p>So the solution should be simple, right? Just use a different driver and it should work. The problem here is, when Docker is intalled on Windows, it uses the built in Hyper-V virtualization technology which by default seems to disable all other virtualizatioin tech.</p> <p>I have tested this hypothesis and this seems to be the case. When the Docker daeomon is running, I am unable to boot any virtual machine that I have. For instance, I get an error when I tried to run my VM's on VirtualBox and on VMWare.</p> <p>Furthermore, when I attemt to start a minikube cluster using the virtualbox driver, it gets stuck &quot;booting the kernel&quot; and then I get a <code>This computer doesn't have VT-X/AMD-v enabled</code> error. This error is false as I do have VT-X enabled (I checked my BIOS). This is most likely due to the fact that when Hyper-V is enabled, all other types of virtualization tech <b>seems</b> to be disabled.</p> <p>For my personal machine, when I do a search for &quot;turn windows features on or off&quot; the Docker daemon enabled &quot;Virtual Machine Platform&quot; and then asked me to restart my computer. This happened when I installed Docker. As a test, I turned off both &quot;Virtual Machine Platform&quot; and &quot;Windows Hypervsor Platform&quot; features and restarted my computer.</p> <p>What happened when I did that? The Docker daemon stopped running and I could no longer work with docker, however, I was able to open my VM's <b>and</b> I was able to start my minikube cluster with virtualbox as the driver. The problem? Well, Docker doesn't work so when my cluster tries to pull the docker image I am using, it won't be able to.</p> <p>So here lies the problem. Either you have VM tech enables and Docker disabled, or you have VM tech (other than Hyper-V, I'll touch on that soon) disabled and Docker enabled. But you can't have both.</p> <p><strong>Solution 1</strong> (Untested)</p> <p>The simplest solution would probably be upgrading to Windows Pro, Enterpriseor or Education. The Hyper-V platform is not accessable on normal Windows. Once you have upgraded, you should be able to use Hyper-V as your driver concurrently with the Docker daemon. This, in theory, should make the ingress work.</p> <p><strong>Solution 2</strong> (Tested)</p> <p>If you're like me and don't want to do a system upgrade for something so miniscule, there's another solution.</p> <p>First, search your computer for the &quot;turn windows features on or off&quot; section and disable &quot;Virtual Machine Platform&quot; and &quot;Windows Hypervisor Platform&quot; and restart your computer. (See you in a bit :D)</p> <p>After that, install a virtual machine platform on your computer. I prefer <a href="https://www.virtualbox.org/wiki/Downloads" rel="nofollow noreferrer">VirtualBox</a> but you can also use others such as <a href="https://www.vmware.com/products/workstation-player/workstation-player-evaluation.html" rel="nofollow noreferrer">VMware</a>.</p> <p>Once you have a VM platform installed, add a new Linux VM. I would recommend either <a href="https://www.debian.org/" rel="nofollow noreferrer">Debian</a> or <a href="https://ubuntu.com/download/desktop" rel="nofollow noreferrer">Ubuntu</a>. If you are unfamiliar with how to set up a VM, <a href="https://www.youtube.com/watch?v=cx8GzudB6uE" rel="nofollow noreferrer">this</a> video will show you how to do so. This will be the general set up for most iso images.</p> <p>After you have your VM up and running, download <a href="https://minikube.sigs.k8s.io/docs/start/" rel="nofollow noreferrer">minikube</a> and <a href="https://docs.docker.com/engine/install/debian/" rel="nofollow noreferrer">Docker</a> on it. Be sure to install the correct version for your VM (for Debian, install Debian versions, for Ubuntu, install Ubuntu versions. Some downlaods may just be general Linux wich should work on most Linux versions).</p> <p>Once you have everything installed, create a minikube cluster with docker as the driver, apply your Kubernetes configurations (deployment, service and ingress). Configure your <code>/etc/hosts</code> file and go to your browser and it should work. If you don't know how to set up an ingress, you can watch <a href="https://www.youtube.com/watch?v=80Ew_fsV4rM" rel="nofollow noreferrer">this</a> video for an explanation on what an ingress is, how it works, and an example of how to set it up.</p>
<p>I want to use execute helm on a gitlab-runner on my kubernetes in gitlab pipelines.</p> <p>My gitlab.ci.yaml:</p> <pre><code># Deployment step deploy: stage: deploy image: alpine/helm:latest script: - helm --namespace gitlab upgrade initial ./iot/ tags: - k8s - dev </code></pre> <p>What i have done so far:</p> <ol> <li>Installed the gitlab-runner on my kubernetes with helm (<a href="https://docs.gitlab.com/runner/install/kubernetes.html" rel="nofollow noreferrer">https://docs.gitlab.com/runner/install/kubernetes.html</a>)</li> </ol> <p>My values.yaml:</p> <pre><code>image: gitlab/gitlab-runner:alpine-v11.6.0 imagePullPolicy: IfNotPresent gitlabUrl: https://gitlab.com/ runnerRegistrationToken: "mytoken" unregisterRunners: true terminationGracePeriodSeconds: 3600 concurrent: 10 checkInterval: 30 ## For RBAC support: rbac: create: true ## Define specific rbac permissions. # resources: ["pods", "pods/exec", "secrets"] # verbs: ["get", "list", "watch", "create", "patch", "delete"] ## Run the gitlab-bastion container with the ability to deploy/manage containers of jobs cluster-wide or only within namespace clusterWideAccess: false metrics: enabled: true ## Configuration for the Pods that that the runner launches for each new job ## runners: ## Default container image to use for builds when none is specified ## image: ubuntu:16.04 locked: false tags: "k8s,dev" privileged: true namespace: gitlab pollTimeout: 180 outputLimit: 4096 cache: {} ## Build Container specific configuration ## builds: {} # cpuLimit: 200m memoryLimit: 256Mi cpuRequests: 100m memoryRequests: 128Mi ## Service Container specific configuration ## services: {} # cpuLimit: 200m memoryLimit: 256Mi cpuRequests: 100m memoryRequests: 128Mi ## Helper Container specific configuration ## helpers: {} securityContext: fsGroup: 65533 runAsUser: 100 ## Configure resource requests and limits ref: http://kubernetes.io/docs/user-guide/compute-resources/ ## resources: {} affinity: {} nodeSelector: {} tolerations: [] envVars: name: RUNNER_EXECUTOR value: kubernetes ## list of hosts and IPs that will be injected into the pod's hosts file hostAliases: [] podAnnotations: {} podLabels: {} </code></pre> <ol start="3"> <li>gitlab-runner is succesfully connected with gitlab.com</li> </ol> <p>But i get the following message on gitlab when executing the deployment step:</p> <pre><code> Error: UPGRADE FAILED: query: failed to query with labels: secrets is forbidden: User "system:serviceaccount:gitlab:default" cannot list resource "secrets" in API group "" in the namespace "gitlab" </code></pre> <p>I've checked my RBAC ClusterRules and they are all per default set to a wildcard on verbs and ressources but i have also tried to set the needed rights:</p> <pre><code> resources: ["pods", "pods/exec", "secrets"] verbs: ["get", "list", "watch", "create", "patch", "delete"] </code></pre> <p>Nothing worked :-( When i have done wrong?</p>
<p>Here's my step to address this issue:</p> <p>First, create service account and custom role for your Gitlab Runner:</p> <pre><code>kubectl create sa sa-runner -n gitlab kubectl create role sa-runner-role -n gitlab --verb=get,list,watch,create,delete,patch --resource=pods,secret,pods/exec kubectl create rolebinding sa-runner-rolebinding -n gitlab --role=sa-runner-role --serviceaccount=gitlab:sa-runner kubectl create clusterrole deploy-default --verb=get,list,watch,patch --resource=deployment kubectl create clusterrolebinding deploy-default-binding --clusterrole=deploy-default --serviceaccount=gitlab:default </code></pre> <p>Then, add serviceAccountName: sa-runner to your values.yaml file</p> <pre><code>## Use the following Kubernetes Service Account name if RBAC is disabled in this Helm chart (see rbac.create) serviceAccountName: &quot;sa-runner&quot; </code></pre> <p>One you done with it, don't forget to do upgrade in your Helm</p>
<p>For an application deployed in Kubernetes would there be any suggested guidance documentation for SAML integration? My search foo is deserting me.</p> <p>Most documentation are for the Kubernetes itself and not the application. The application would not be aware of Kubernetes RBAC etc.</p>
<p>In the <a href="https://kubernetes.io/docs/reference/access-authn-authz/authentication/#authentication-strategies" rel="nofollow noreferrer">official documentation</a> you can find the following section:</p> <blockquote> <p>Kubernetes uses client certificates, bearer tokens, or an authenticating proxy to authenticate API requests through authentication plugins. As HTTP requests are made to the API server, plugins attempt to associate the following attributes with the request:</p> <ul> <li>Username: a string which identifies the end user. Common values might be <code>kube-admin</code> or <code>jane@example.com</code>.</li> <li>UID: a string which identifies the end user and attempts to be more consistent and unique than username.</li> <li>Groups: a set of strings, each of which indicates the user's membership in a named logical collection of users. Common values might be <code>system:masters</code> or <code>devops-team</code>.</li> <li>Extra fields: a map of strings to list of strings which holds additional information authorizers may find useful.</li> </ul> <p>All values are opaque to the authentication system and only hold significance when interpreted by an <a href="https://kubernetes.io/docs/reference/access-authn-authz/authorization/" rel="nofollow noreferrer">authorizer</a>.</p> <p>You can enable multiple authentication methods at once. You should usually use at least two methods:</p> <ul> <li>service account tokens for service accounts</li> <li>at least one other method for user authentication.</li> </ul> <p>When multiple authenticator modules are enabled, the first module to successfully authenticate the request short-circuits evaluation. The API server does not guarantee the order authenticators run in.</p> <p>The <code>system:authenticated</code> group is included in the list of groups for all authenticated users.</p> <p><strong>Integrations with other authentication protocols (LDAP, SAML, Kerberos, alternate x509 schemes, etc) can be accomplished using an <a href="https://kubernetes.io/docs/reference/access-authn-authz/authentication/#authenticating-proxy" rel="nofollow noreferrer">authenticating proxy</a> or the <a href="https://kubernetes.io/docs/reference/access-authn-authz/authentication/#webhook-token-authentication" rel="nofollow noreferrer">authentication webhook</a>.</strong></p> </blockquote> <p>As you can see to add SAML to your configuration you can use <a href="https://kubernetes.io/docs/reference/access-authn-authz/authentication/#authenticating-proxy" rel="nofollow noreferrer">authenticating proxy</a> or the <a href="https://kubernetes.io/docs/reference/access-authn-authz/authentication/#webhook-token-authentication" rel="nofollow noreferrer">authentication webhook</a>.</p> <p>If you search an example how to set SAML in Kubernetes, you can read <a href="https://goteleport.com/blog/kubernetes-sso-saml/" rel="nofollow noreferrer">this article</a>.</p> <p>However, in the vast majority of cases, SAML will extend (rather than replace) the RBAC functionality. See also article <a href="https://goteleport.com/blog/how-saml-authentication-works/" rel="nofollow noreferrer">How SAML 2.0 Authentication Works?</a></p>
<p>For various reasons I want to be able to use a proxied data table and replaceData while client side processing is being used i.e. <code>DT::renderDataTable(..., server = FALSE)</code>.</p> <h2>Context</h2> <p>I have a shiny application/dashboard that communicates to a database and presents information to a user. The user is able to fill out a form in the application which will be added to the database and then the shiny app updates the data by making a query to the database to fetch the new information.</p> <p>The application is currently being deployed via kubernetes using a <code>LoadBalancer</code> with the intention to use multiple replicas to scale up the application as needed. The application is not being run through shinyproxy.</p> <h2>Caveats</h2> <p>Currently, when the application is being run by a single replica (process) the application will behave perfectly fine and is able to use <code>server=TRUE</code>. However when I increase the number of processes/replicas to run, the data is not able to be presented to users unless <code>server=FALSE</code> is specified in <code>renderDataTable</code>. For a currently unknown reason but I suspect it might be due to the sessions not being sticky to IPs</p> <p>While the code is able to function fine when <code>server = TRUE</code> if I want to allow multiple users to application they all cannot share a single process as the application will become very slow once multiple connections are made. As a result I likely need to use <code>server=FALSE</code> so each user is able to see the data at the cost of a very important functional detail (<code>replaceData</code> stops working). The product owner of the application is insistent that this behaviour remains intact as the data present is often large and requires some column sorting and paging to find a piece of information you want to look at. And when submitting a form, if I do not use <code>replaceData</code> and reconstruct the table from scratch the users previous table state is lost.</p> <p>So while I could tear down the datatable and regenerate it within an <code>observeEvent</code></p> <pre><code>observeEvent(input$button, { ... output$table = renderDataTable({DT::datatable(df(), selection = 'single', callback = JS(&quot;$.fn.dataTable.ext.errMode = 'none';&quot;))}, server = FALSE) ... }) </code></pre> <p>this would provide a solution that would yield unfavourable behaviour even though it will update the table accordingly.</p> <h2>Repoducible Example</h2> <p>This will create an application with a button and a table. Select a row on the table and then click the button. The expected behaviour would be that the table updates with 'new_content' on the row that is selected. This will only work when <code>server=TRUE</code>, nothing will happen when <code>server=FALSE</code>.</p> <pre><code>library(shiny) library(DT) data(iris) server &lt;- function(input, output, session) { iris$new_col = '' df = reactive({iris}) output$table = renderDataTable({ DT::datatable(df(), selection = 'single', callback = JS(&quot;$.fn.dataTable.ext.errMode = 'none';&quot;))}, server = FALSE) # When TRUE code works fine,,, proxy = dataTableProxy('table') observeEvent(input$button, { # This line would be replacing the write to a db iris[input$table_rows_selected, 'new_col'] &lt;- 'changed' # This line would be replacing the query to the db to reflect changes the user (and potentially other users have made between loading the data previously. df &lt;- reactive({iris}) proxy %&gt;% replaceData(df(), rownames = TRUE, resetPaging = FALSE) }) } ui &lt;- fluidPage( actionButton('button', 'Press Me'), DT::DTOutput('table') ) shinyApp(ui, server) </code></pre> <p>I have done a fairly extensive search on SO and this was the closest question I could find: <a href="https://stackoverflow.com/questions/52519367/dt-editing-in-shiny-application-with-client-side-processing-server-f-throws">DT Editing in Shiny application with client-side processing (server = F) throws JSON Error</a> however this isn't actually answered and provides an answer of &quot;it just does not work&quot;.</p> <h3>kubernetes.yaml (only look if you are a wizard)</h3> <p>I am including the yaml file incase there are some kubernetes boffins that know how to specifically solve the above issue with some clever trickery. The described problem might stem from sessions being swapped between replicas thus the data gets miscommunicated but I am honestly not the best at kubernetes... If that is the case and I would then be able to use server=TRUE within the shiny application then this would also solve the problem.</p> <pre><code>apiVersion: apps/v1 kind: Deployment metadata: name: deployment-appname spec: replicas: 5 selector: matchLabels: app: appname template: metadata: labels: app: appname spec: containers: - name: appname securityContext: privileged: false image: appname:latest ports: - name: http containerPort: 3838 --- apiVersion: v1 kind: Service metadata: name: servive-appname spec: ports: - name: http port: 3838 protocol: TCP targetPort: 3838 selector: app: appname type: LoadBalancer --- apiVersion: networking.k8s.io/v1beta1 kind: Ingress metadata: name: ingress-appname annotations: nginx.org/websocket-services: &quot;service-appname&quot; spec: tls: - hosts: - appname.url.com rules: - host: appname.url.com http: paths: - path: / backend: serviceName: service-appname servicePort: 3838 </code></pre>
<p>Here is a client-side approach, building up on @jpdugo17's answer and @TJGorrie's initial example, using the <code>stateSave</code> option to maintain the table state on re-rendering. <code>selectPage</code> and <code>updateSearch</code> can be used along with <code>dataTableProxy</code> - the state of <code>input$table_state$order</code> needs to be passed as an option:</p> <pre><code>library(shiny) library(DT) data(iris) iris$new_col &lt;- '' server &lt;- function(input, output, session) { DF = reactiveValues(iris = iris) output$table &lt;- DT::renderDataTable(expr = { if (is.null(isolate(input$table_state))) { DT::datatable( DF$iris, selection = 'single', callback = JS(&quot;$.fn.dataTable.ext.errMode = 'none';&quot;), options = list(stateSave = TRUE) ) } else { # print(isolate(input$table_state$order)) DT::datatable( DF$iris, selection = 'single', callback = JS(&quot;$.fn.dataTable.ext.errMode = 'none';&quot;), options = list( stateSave = TRUE, order = isolate(input$table_state$order), paging = TRUE, pageLength = isolate(input$table_state$length) ) ) } }, server = FALSE) proxy &lt;- dataTableProxy('table') observeEvent(input$button, { DF$iris[input$table_rows_selected, c('new_col')] &lt;- 'changed!' }) observeEvent(DF$iris, { updateSearch(proxy, keywords = list(global = input$table_state$search$search, columns = NULL)) # see input$table_state$columns if needed selectPage(proxy, page = input$table_state$start/input$table_state$length+1) }, ignoreInit = TRUE, priority = -1) } ui &lt;- fluidPage( actionButton('button', 'Press Me'), DT::DTOutput('table') ) shinyApp(ui, server) </code></pre> <p>Here is a <a href="https://rstudio.github.io/DT/shiny.html" rel="nofollow noreferrer">related article</a>.</p>
<p>I have a pod that has both node affinity and pod affinity. could some help me understand how would things behave in such a scenario?</p> <p>Node 1:</p> <pre><code> label: schedule-on : gpu </code></pre> <p>Node 2:</p> <pre><code> label: schedule-on : gpu </code></pre> <p>Node 3:</p> <pre><code> label: schedule-on : non-gpu </code></pre> <p>Manifest</p> <pre><code>apiVersion: apps/v1 kind: Deployment metadata: name: test spec: progressDeadlineSeconds: 600 replicas: 2 revisionHistoryLimit: 10 selector: matchLabels: app.kubernetes.io/name: test strategy: rollingUpdate: maxSurge: 25% maxUnavailable: 25% type: RollingUpdate template: metadata: labels: app.kubernetes.io/name: test spec: affinity: nodeAffinity: requiredDuringSchedulingIgnoredDuringExecution: nodeSelectorTerms: - matchExpressions: - key: schedule-on operator: In values: - gpu podAffinity: requiredDuringSchedulingIgnoredDuringExecution: - labelSelector: matchExpressions: - key: app.kubernetes.io/name operator: In values: - test topologyKey: schedule-on </code></pre> <p>the output of the above is: Pods are getting scheduled on a different node [node1,node2]</p> <p>ideal output: Pod needs to be scheduled on the same node [node1]</p> <p>Here is my finding.</p> <p>Finding 1: I believe node affinity is taking precedence and pod affinity is getting ignored</p>
<p>It's the union of node affinity and pod affinity. since both the pod has the same topology key domain . hence making them in the same colocation the pods can get scheduled in different nodes but in same colocation .</p> <p>When matching the topology key and placing the pod. Value of the key is also considered</p>
<p>There is an official manifest for the deployment of the daemonset <a href="https://raw.githubusercontent.com/fluent/fluent-bit-kubernetes-logging/master/output/elasticsearch/fluent-bit-ds.yaml" rel="nofollow noreferrer">https://raw.githubusercontent.com/fluent/fluent-bit-kubernetes-logging/master/output/elasticsearch/fluent-bit-ds.yaml</a></p> <p>Line 49 defines the volume <code>varlibdockercontainers</code>.</p> <p>I don't understand why the Fluent-bit needs to read data from the folder <code>/var/lib/docker/containers</code>.</p>
<blockquote> <p>I don't understand why the Fluent-bit needs to read data from the folder <code>/var/lib/docker/containers</code>.</p> </blockquote> <p>Because that is where docker stores its <code>${container_id}-json.log</code> file when using the <a href="https://docs.docker.com/config/containers/logging/json-file/" rel="nofollow noreferrer"><code>json-file</code> logging driver</a>, which is (AFAIK) the default. There are more details <a href="https://stackoverflow.com/questions/44579227/where-is-the-docker-json-file-logging-driver-writing-files-to">in this related question</a></p> <p>Therefore, in order for fluent to transmit logs, it does (effectively) <code>tail -f $the_log_filename | jq -r .log</code> and those are the container's logs. If you want to see the <em>actual</em> implementation, it seems to be in <a href="https://github.com/fluent/fluent-bit/blob/v1.8.10/plugins/in_docker/docker.h#L40" rel="nofollow noreferrer"><code>docker.h</code></a> and its <code>docker.c</code> peer</p>
<p>I’ve a PVC in RWX. 2 pods use this PVC. I want to know which pods ask volume to the PVC and when. How can I manage that?</p>
<p>As far as i know there is no direct way to figure out a PVC is used by which pod To get that info possible workaround is grep through all the pods for the respective pvc :</p> <pre><code>Ex: - To display all the pods and their respective pvcs: kubectl get pods -o jsonpath='{&quot;POD&quot;}{&quot;\t&quot;}{&quot;PVC Name&quot;}{&quot;\n&quot;}{range .items[*]}{.metadata.name}{&quot;\t&quot;}{range .spec.volumes[*]}{.persistentVolumeClaim.claimName}{&quot;\t&quot;}{end}{&quot;\n&quot;}{end}' POD PVC Name web1-0 www1-web1-0 web16-0 www16-web16-0 - To get information about a particular PVC (in this case:www16-web16-0 ) Using grep : kubectl get pods -o jsonpath='{&quot;POD&quot;}{&quot;\t&quot;}{&quot;PVC Name&quot;}{&quot;\n&quot;}{range .items[*]}{.metadata.name}{&quot;\t&quot;}{range .spec.volumes[*]}{.persistentVolumeClaim.claimName}{&quot;\t&quot;}{end}{&quot;\n&quot;}{end}' | grep 'POD\|www16-web16-0' POD PVC Name web16-0 www16-web16-0 </code></pre>
<p>My organization manages systems where each client is provisioned a VPS and then their tech stack is spun up on that system via Docker Compose.</p> <p>Data is stored on-system, using Docker Compose volumes. None of the fancy named storage - just good old direct path volumes.</p> <p>While this solution is workable, the problem is that this method does not scale. We can always give the VPS more CPU/Memory but that does not fix the underlying issues.</p> <p>Staging / development environments must be brought up manually - and there is no service redundancy. Hot swapping is impossible with our current system.</p> <p>Kubernetes has been pitched to me to solve our problems, but honestly I have no idea where to begin - most of the documentation is obtuse and I have failed to find somebody with our particular predicament.</p> <p>The end goal would be to have just a few high-spec machines running Kubernetes - with redundancy, staging, and the ability to spin up new clients as necessary (without having to provision additional machines or external IPs).</p> <p>What specific tools would my organization need to use to achieve this goal?</p> <p>Are there any tools that would allow us to bring over our existing Docker Compose stacks into Kubernetes?</p>
<p>Where to begin: given what you're telling us, I would first look into my options to implement some SDS.</p> <p>You're currently using local volumes, which you probably won't be able to do with Kubernetes - or at least shouldn't, if you don't want to bind your containers to a unique node.</p> <p>The most easy way - while not necessarily the one I would recommend - would be to use some NFS servers. Even better: with some DRBD, pacemaker / corosync, using a VIP for failover -- or the FreeBSD way: hastd, carp, ifstated, maybe some zfs. You would probably have to deploy distinct systems scaling your Kubernetes cluster, distributing IOs, ... a single NFS server doesn't last long without its load going over 50 and iowaits spiking ...</p> <p>A better way would be to look into actual SDS solutions. One I could recommend is Ceph, though there's a lot of new solutions I'm less familiar with ... and there's GlusterFS I would definitely avoid. An easy way to deploy Ceph would be to use ceph-ansible.</p> <p>Given what corporate hardware you have at your disposal, maybe you would have some NetApp or equivalent, something that can implement NFS shares, and/or some iSCSI gateways.</p> <p>Now, those are all solutions you could run on the side, although note that you would also find &quot;CNS&quot; solutions (container native), which are meant to be deployed on top of Kubernetes. Ceph clusters can be managed using Rook. These can be interesting, though in terms of maintenance and operations, it requires good knowledge of both the solution you operate and kubernetes/containers in general: troubleshooting issues and fixing outages may not be as easy as a good-old bare-meta/VM setup. For a first Kubernetes experience: I would refrain myself. When you'll feel comfortable enough, go ahead.</p> <p>In any cases, another critical consideration before deploying your cluster would be the network that would host your installation. Consider that Kubernetes should not be directly deployed on public instances: you would probably want to have some private VLAN, maybe an internal DNS, a local resitry (could be Kubernetes-hosted), or other tools such as an LDAP server, some SMTP relay, HTTP cache/proxies, loadbalancers to put in front of your API, ...</p> <p>Once you've made up your mind regarding those issues, you can look into deploying a Kubernetes cluster using tools such as Kubespray (ansible) or Kops (uses Terraform, and thus requires some cloud API, eg: aws). Both projects are part of the Kubernetes project and maintained by its community. Kubespray would cover all scenarios (IAAS &amp; bare-metal), integrate with popular SDS out of the box, can ship with various ingress controllers, ... overall offers good defaults, and lots of variables to customize your installation.</p> <p>Start with a 3-master 2-workers cluster, make sure the resulting cluster matches what you would expect.</p> <p>Before going to prod, take your time to properly translate your existing configurations. Sometime, refactoring code or images could be worth it.</p> <p>Going to prod, consider adding a group of &quot;infra&quot; nodes: if you want to host some logging solution or other internal services that are somewhat critical to users and shouldn't suffer outages caused by end-users workloads (eg: ingress routers, monitoring, logging, integrated registry, ...).</p> <ul> <li>Kubespray: <a href="https://github.com/kubernetes-sigs/kubespray/" rel="nofollow noreferrer">https://github.com/kubernetes-sigs/kubespray/</a></li> <li>Kops: <a href="https://github.com/kubernetes/kops" rel="nofollow noreferrer">https://github.com/kubernetes/kops</a></li> <li>Ceph: <a href="https://ceph.com/en/discover/" rel="nofollow noreferrer">https://ceph.com/en/discover/</a></li> <li>Ceph Ansible: <a href="https://github.com/ceph/ceph-ansible" rel="nofollow noreferrer">https://github.com/ceph/ceph-ansible</a></li> <li>Rook (Ceph CNS): <a href="https://github.com/rook/rook" rel="nofollow noreferrer">https://github.com/rook/rook</a></li> </ul>
<p>This is my <a href="https://kafka.js.org/docs/getting-started" rel="nofollow noreferrer">KafkaJs</a> based publisher client. I created a container image and submitted a <code>Pod</code> YAML to Strimzi broker.</p> <pre class="lang-js prettyprint-override"><code>const { Kafka } = require('kafkajs') async function clients() { const kafka = new Kafka({ clientId: 'my-app', brokers: ['test-kafka-bootstrap.strimzi.svc.cluster.local:9092'] }) const producer = kafka.producer() await producer.connect() await producer.send({ topic: 'clients', messages: [ { value: 'Hello KafkaJS user!' }, ], }) await producer.disconnect() } clients() </code></pre> <p>My <code>Dockerfile</code>.</p> <pre><code>FROM node:14 as build_app WORKDIR / WORKDIR /app COPY app . COPY package.json . COPY package-lock.json . RUN npm i CMD [&quot;node&quot;, &quot;index.js&quot;] </code></pre> <p>My <code>pod</code> YAML.</p> <pre class="lang-yaml prettyprint-override"><code>apiVersion: v1 kind: Pod metadata: name: clients spec: containers: - name: clients image: ghcr.io/org/clients:v0.0.0 imagePullPolicy: Always </code></pre> <p>The <code>Pod</code> keeps crashing and <code>kubectl logs</code> does not show anything - its empty. A <code>kubectl describe</code> didnt' reveal anything either.</p> <p>What am I missing?</p>
<p>The logs show nothing because 1) Your code has no log output 2) Your code only send a single record, and then stops, so the container exits cleanly; it is not a long-running service. You'd have the same issues with a simple <code>docker run</code> command.</p> <p>If you wanted a long-running service, you'd need to wrap your code in a web-service (NextJS, Express, Hapi, etc), and then add a health check probe for the k8s Service.</p>
<p>This is my <a href="https://kafka.js.org/docs/getting-started" rel="nofollow noreferrer">KafkaJs</a> based publisher client. I created a container image and submitted a <code>Pod</code> YAML to Strimzi broker.</p> <pre class="lang-js prettyprint-override"><code>const { Kafka } = require('kafkajs') async function clients() { const kafka = new Kafka({ clientId: 'my-app', brokers: ['test-kafka-bootstrap.strimzi.svc.cluster.local:9092'] }) const producer = kafka.producer() await producer.connect() await producer.send({ topic: 'clients', messages: [ { value: 'Hello KafkaJS user!' }, ], }) await producer.disconnect() } clients() </code></pre> <p>My <code>Dockerfile</code>.</p> <pre><code>FROM node:14 as build_app WORKDIR / WORKDIR /app COPY app . COPY package.json . COPY package-lock.json . RUN npm i CMD [&quot;node&quot;, &quot;index.js&quot;] </code></pre> <p>My <code>pod</code> YAML.</p> <pre class="lang-yaml prettyprint-override"><code>apiVersion: v1 kind: Pod metadata: name: clients spec: containers: - name: clients image: ghcr.io/org/clients:v0.0.0 imagePullPolicy: Always </code></pre> <p>The <code>Pod</code> keeps crashing and <code>kubectl logs</code> does not show anything - its empty. A <code>kubectl describe</code> didnt' reveal anything either.</p> <p>What am I missing?</p>
<p>you can bring up the pod in sleep mode and from there you can debug, use below yaml</p> <pre><code>apiVersion: v1 kind: Pod metadata: name: clients spec: containers: - name: clients image: ghcr.io/org/clients:v0.0.0 imagePullPolicy: Always command: [&quot;sleep&quot; , &quot;100000000&quot;] </code></pre> <p>Now exec into the pod</p> <pre><code>kubectl exec -it &lt;pod&gt; -- bash </code></pre> <p>now execute</p> <pre><code>node index.js </code></pre>
<p>Good morning. I am doing some tests with the new Google Cloud Kubernetes Engine's Autopilot mode. I know that it automates a lot of the machine resources' management, but I am not sure about what it automates. Does it only cares about provisioning the hardware resources that I set inside my PodSpec? Or does it also cares about scaling up and down the number of containers that I have based on traffic intensity?</p> <p>I am coming from Cloud Run, so, after all, my main question is: Now, with GKE Autopilot, do I need to do something for it to create new container instances when the traffic intensity increases or is it all automatically managed? Do I need to set HPA, VPA and other autoscaler technologies when using autopilot?</p>
<p>For GKE autopilot you need to create the <strong>HPA</strong> and <strong>VPA</strong> configuration</p> <p>GKE autopilot will the scaling of <strong>Node</strong> by default</p> <p>You can read more at : <a href="https://cloud.google.com/kubernetes-engine/docs/concepts/autopilot-overview#comparison" rel="nofollow noreferrer">https://cloud.google.com/kubernetes-engine/docs/concepts/autopilot-overview#comparison</a></p> <blockquote> <p>Scaling Pre-configured: Autopilot handles all the scaling and configuring of your nodes.</p> <p>Default: You configure Horizontal pod autoscaling (HPA) You configure Vertical Pod autoscaling (VPA)</p> <p>Do I need to set HPA, VPA and other autoscaler technologies when using autopilot?</p> </blockquote> <p><strong>Autoscaler</strong> is not required as it will be by default managed by GKE and will scale the Node as per requirement.</p>
<p>In Spring Boot 2.6.0 using Log4J2. I want to use env variables from external to log4j.propeties but it is always taking local <code>application.propeties</code> file instead of real docker or Kubernetes env variables</p> <p>File <code>application.properties</code></p> <pre><code>spring.application.name=myapp #Logger FilePath log.file.path=logs/dev/my-app </code></pre> <p>Docker Composer File</p> <pre><code> version: &quot;3&quot; services: spring-app-log4j2: build: ./log4j2 ports: - &quot;8080:80&quot; environment: - SERVER_PORT=80 - LOG_FILE_PATH=logs/prod/my-app </code></pre> <p>File <code>log4j2.properties</code></p> <pre><code>name=config #Read Properties values from application properties property.filename = ${bundle:application:log.file.path} property.layoutPattern = %d{MMM dd yyyy HH:mm:ss.SSS z} | ${hostName} | %-5p | %c{1}:%L | %M() - %m%n appenders=console, rolling #log to console appender.console.type=Console appender.console.name=STDOUT appender.console.layout.type=PatternLayout appender.console.layout.pattern=${layoutPattern} #log to file and daily rolling appender.rolling.type = RollingFile appender.rolling.name = roll appender.rolling.fileName = ${filename}.log appender.rolling.filePattern = ${filename}.%d{dd-MMM-yyyy}.log.gz appender.rolling.layout.type = PatternLayout appender.rolling.layout.pattern = ${layoutPattern} appender.rolling.policies.type = Policies appender.rolling.policies.time.type = TimeBasedTriggeringPolicy appender.rolling.policies.time.interval = 2 appender.rolling.policies.time.modulate = true appender.rolling.policies.size.type = SizeBasedTriggeringPolicy appender.rolling.policies.size.size=100MB appender.rolling.strategy.type = DefaultRolloverStrategy appender.rolling.strategy.max = 5 loggers = rolling logger.rolling.name = org.apache.logging.log4j.core.appender.rolling logger.rolling.level = info logger.rolling.additivity = true logger.rolling.appenderRefs = rolling logger.rolling.appenderRef.rolling.ref = roll rootLogger.level=info rootLogger.appenderRefs=stdout,rolling rootLogger.appenderRef.stdout.ref=STDOUT rootLogger.appenderRef.rolling.ref = roll </code></pre> <p>Output Tried</p> <pre><code> property.filename = ${bundle:application:logpath} #Output - logs/dev/app #(Taking values from application Properties only, not taking from Docker pod environment varibales) property.filename = ${sys:logpath} #Output - ${sys:logpath} property.filename = ${env:logpath} # Not Working #Output - ${env:logpath} #use filename variable appender.rolling.fileName = ${filename}.log </code></pre> <p>When Printing inside Java code</p> <pre class="lang-java prettyprint-override"><code>@Value(&quot;${logpath}&quot;) String logpath; #Output -logs/prod/app # Working with Docker env </code></pre> <p>Problem : When log4j initiated it is not finding the file path from environment , so by default reading from application.propeties</p> <p>How can i read from Docker environment or Kubernetes Environment</p> <p>i need log file should &quot;logs/prod/my-app&quot; instead of &quot;logs/dev/my-app&quot;</p> <p>Src Code : <a href="https://github.com/jeebendu/log4j2" rel="nofollow noreferrer">https://github.com/jeebendu/log4j2</a></p>
<p>In all your attempts you use a single source for the <code>filename</code> property. You need to use one of the <em>fallback</em> features of variable substitution:</p> <ul> <li><p>You can add a default value to your variable substitution using the syntax <code>${variable:-default}</code>:</p> <pre><code>property.filename = ${env:LOG_FILE_PATH:-${bundle:application:log.file.path}} appender.rolling.fileName = ${filename}.log </code></pre> </li> <li><p>or you can exploit the fact that every <code>${prefix:variable}</code> falls back to <code>${variable}</code>:</p> <pre><code>property.LOG_FILE_PATH = ${bundle:application:log.file.path} appender.rolling.fileName = ${env:LOG_FILE_PATH} </code></pre> </li> </ul>
<p>I'm trying to expose a website inside my Kubernetes Cluster. Therefor I created an Ingress that links to my Service and so to my Pod. Till this point, everything works perfectly fine. But now when I start navigating on my Page the URL changes, but the shown site stays the “Homepage”. How is it possible to navigate on the page and access all the subpages properly?</p> <p>My Deployment:</p> <pre class="lang-yaml prettyprint-override"><code>apiVersion: apps/v1 kind: Deployment metadata: name: wichteln-deployment spec: replicas: 1 selector: matchLabels: app: wichteln template: metadata: labels: app: wichteln spec: containers: - image: jonasgoetz01/website:V1.0 name: wichteln-container command: [&quot;/bin/sh&quot;] args: - -c - &gt;- apt update </code></pre> <p>My Service:</p> <pre class="lang-yaml prettyprint-override"><code>apiVersion: v1 kind: Service metadata: name: wichteln-service spec: selector: app: wichteln ports: - protocol: TCP port: 5000 targetPort: 5000 </code></pre> <p>My Ingress:</p> <pre class="lang-yaml prettyprint-override"><code>apiVersion: networking.k8s.io/v1 kind: Ingress metadata: name: wichteln-ingress annotations: nginx.ingress.kubernetes.io/rewrite-target: / spec: ingressClassName: public rules: - http: paths: - path: /wichteln/* pathType: Prefix backend: service: name: wichteln-service port: number: 5000 </code></pre> <p>The Webpage is a NodeJS express Webpage. Here is my routes.js file for reference (If you need more files, please let me know):</p> <pre class="lang-js prettyprint-override"><code>const express = require('express'); const router = express.Router(); const controller = require('../controllers/controller'); // Routes router.get('/', controller.home); router.get('/usermanagement/', controller.viewuser); router.post('/usermanagement/', controller.finduser); router.get('/usermanagement/adduser', controller.formuser); router.post('/usermanagement/adduser', controller.createuser); router.get('/usermanagement/edituser/:id', controller.edituser); router.post('/usermanagement/edituser/:id', controller.updateuser); router.get('/usermanagement/viewuser/:id', controller.viewalluser); router.get('/usermanagement/:id',controller.deleteuser); module.exports = router; </code></pre> <p>Every time I try to access the page, I start at the homepage. When I click on some buttons that normally would redirect me to a subpage, I stay at the homepage even if the URL changes correctly. For example, the home URL is: <code>www.mydomain.com/wichteln</code> → I can see the homepage. <code>www.mydomain.com/wichteln/usermanagement</code> → I can still see the homepage but want to see the subpage “usermanagement”.</p> <p>Thank you for your help.</p>
<p>The issue is most likely coming from the rewrite that you have in your ingress manifest.</p> <pre><code> nginx.ingress.kubernetes.io/rewrite-target: / </code></pre> <p>this means that when the ingress receives the request from the client it takes the <code>path</code> portion of the url and rewrites it to be <code>/</code>, before passing it down to your backend, which in turn results in backend returning the root page of your website.</p>
<p>I recently hosted Jupyterhub in our K8s cluster. We set memory limits to 1GB so now all Jupyter notebook are with this configuration. But we have notebooks which are resource(memory and cpu) intensive and some notebooks are not resource intensive</p> <p>So , is there anyway to assign different resource for multiple jupyter pods ?</p> <p>I am using helm chart to deploy jupyterhub <a href="https://zero-to-jupyterhub.readthedocs.io/en/latest/jupyterhub/installation.html" rel="nofollow noreferrer">https://zero-to-jupyterhub.readthedocs.io/en/latest/jupyterhub/installation.html</a></p>
<p>We use <a href="https://zero-to-jupyterhub.readthedocs.io/en/latest/jupyterhub/customizing/user-environment.html#using-multiple-profiles-to-let-users-select-their-environment" rel="nofollow noreferrer">profiles</a> to allow users to select from pods of different sizes. The pods are all deployed on large nodes, but users can select whether they get a half- or full-node pod.</p> <p>As an example, we build off the daskhub configuration (full spec <a href="https://github.com/RhodiumGroup/daskhub-rhg-config/blob/main/daskhub-rhg/values.yaml" rel="nofollow noreferrer">here</a>):</p> <pre class="lang-yaml prettyprint-override"><code>daskhub: jupyterhub: singleuser: image: cpu: limit: 3.5 guarantee: 3.5 memory: limit: 22.5G guarantee: 22.5G profileList: - display_name: &quot;default&quot; description: &quot;Default notebook size&quot; default: true - display_name: &quot;large&quot; description: &quot;Larger notebook allowance&quot; kubespawner_override: cpu_limit: 7.0 cpu_guarantee: 7.0 mem_limit: 45G mem_guarantee: 45G </code></pre> <p>These are both spawned on 8CPU / 52GB nodes, but two of the smaller pods will go on the same node (assuming 2 users selecting &quot;default&quot;).</p>
<p>I have created a spring boot project which connects with Cloud SQL(MySQL). I have deployed this in google cloud (cloudrun) and it is working in it.</p> <p>now, I am trying to deploy the same container image of spring boot app in kubernates enigne GKE and i am expecting this will connect with mysql cloud sql instance. however, i am getting below errors in application POD logs.</p> <hr /> <pre><code> &quot;method&quot; : &quot;google.cloud.sql.v1beta4.SqlInstancesService.CreateEphemeral&quot; &quot;service&quot; : &quot;sqladmin.googleapis.com&quot;, &quot;metadata&quot; : { &quot;domain&quot; : &quot;googleapis.com&quot;, &quot;reason&quot; : &quot;ACCESS_TOKEN_SCOPE_INSUFFICIENT&quot;, &quot;@type&quot; : &quot;type.googleapis.com/google.rpc.ErrorInfo&quot;, &quot;details&quot; : [ { &quot;status&quot; : &quot;PERMISSION_DENIED&quot;, &quot;message&quot; : &quot;Request had insufficient authentication scopes.&quot;, } ], &quot;reason&quot; : &quot;insufficientPermissions&quot; &quot;message&quot; : &quot;Insufficient Permission&quot;, &quot;domain&quot; : &quot;global&quot;, &quot;errors&quot; : [ { &quot;code&quot; : 403, Failed to create ephemeral certificate for the Cloud SQL instance. </code></pre> <hr /> <p>please help on this...what could be the solution</p>
<p>Not sure how you are passing the service account file but you can pass it using the <strong>Kubernetes</strong> secret or use the <strong>Service account</strong> and attach it to deployment.</p> <pre><code>kubectl create secret generic google-application-credentials --from-file=./application-credentials.json </code></pre> <p>Deployment volume in which secret get attached</p> <pre><code>volumes: - name: google-application-credentials-volume secret: secretName: google-application-credentials items: - key: application-credentials.json # default name created by the create secret from-file command path: application-credentials.json </code></pre> <p>Mount secret at the path</p> <pre><code>spec: containers: - name: my-service volumeMounts: - name: google-application-credentials-volume mountPath: /etc/gcp readOnly: true </code></pre> <p>At last, you can pass the environment variables which will point to this file and cred</p> <pre><code>spec: containers: - name: my-service env: - name: GOOGLE_APPLICATION_CREDENTIALS value: /etc/gcp/application-credentials.json </code></pre> <p>Make sure your service account has sufficient role to update Cloud SQL.</p>
<p>I've deployed pgadmin on Kubernetes and I'm trying to enable oauth2 as per the <a href="https://www.pgadmin.org/docs/pgadmin4/5.5/oauth2.html" rel="nofollow noreferrer">pgadmin docs</a></p> <p>This is the oauth config which I've passed in:</p> <pre class="lang-py prettyprint-override"><code>AUTHENTICATION_SOURCES = ['oauth2', 'internal'] OAUTH2_CONFIG = [ { # The name of the of the oauth provider, ex: github, google 'OAUTH2_NAME': 'gitlab', # The display name, ex: Google 'OAUTH2_DISPLAY_NAME': 'Gitlab', # Oauth client id 'OAUTH2_CLIENT_ID': 'my-client-id-here', # Oauth secret 'OAUTH2_CLIENT_SECRET': 'my-client-secret-here', # URL to generate a token, # Ex: https://github.com/login/oauth/access_token 'OAUTH2_TOKEN_URL': 'https://gitlab.com/oauth/token', # URL is used for authentication, # Ex: https://github.com/login/oauth/authorize 'OAUTH2_AUTHORIZATION_URL': &quot;https://gitlab.com/oauth/authorize&quot;, # Oauth base url, ex: https://api.github.com/ 'OAUTH2_API_BASE_URL': 'https://gitlab.com/api/v4/', # Name of the Endpoint, ex: user 'OAUTH2_USERINFO_ENDPOINT': 'user', # Font-awesome icon, ex: fa-github 'OAUTH2_ICON': 'fa-gitlab', # UI button colour, ex: #0000ff 'OAUTH2_BUTTON_COLOR': '#E24329', } ] OAUTH2_AUTO_CREATE_USER = True </code></pre> <p>I've added the application on Gitlab. The redirect URIs are:</p> <pre><code>https://pgadmin.nonprod.example.io/oauth2/authorize http://pgadmin.nonprod.example.io/oauth2/authorize </code></pre> <p>I've give the application the following scopes:</p> <ul> <li>api</li> <li>openid</li> <li>profile</li> <li>email</li> </ul> <p>I'm testing it locally with the pgadmin ingress and my local minikube cluster. I keep getting the following error when I click the 'Sign in with Gitlab' button:</p> <pre><code>{ success: 0, errormsg: &quot;403 Client Error: Forbidden for url: https://gitlab.com/api/v4/user&quot;, info: &quot;&quot;, result: null, data: null } </code></pre> <p>I believe I have all the necessary gitlab permissions and can't figure out what I'm doing wrong.</p>
<p>I think that in this case we can just use the OIDC endpoint to fetch userinfo. For gitlab it is: ttps://gitlab.com/oauth/userinfo. Therefore, you do not need <code>api</code> scope, just <code>openid email profile</code></p> <p>So the following configuration actually works for me:</p> <pre class="lang-py prettyprint-override"><code>AUTHENTICATION_SOURCES = ['oauth2', 'internal'] OAUTH2_CONFIG = [ { 'OAUTH2_NAME': 'gitlab', 'OAUTH2_DISPLAY_NAME': 'Gitlab', 'OAUTH2_CLIENT_ID': 'my-client-id-here', 'OAUTH2_CLIENT_SECRET': 'my-client-secret-here', 'OAUTH2_TOKEN_URL': 'https://gitlab.com/oauth/token', 'OAUTH2_AUTHORIZATION_URL': &quot;https://gitlab.com/oauth/authorize&quot;, 'OAUTH2_API_BASE_URL': 'https://gitlab.com/oauth/', 'OAUTH2_USERINFO_ENDPOINT': 'userinfo', 'OAUTH2_SCOPE': 'openid email profile', 'OAUTH2_ICON': 'fa-gitlab', 'OAUTH2_BUTTON_COLOR': '#E24329', } ] OAUTH2_AUTO_CREATE_USER = True </code></pre>
<p>I am new to Kubernetes, and trying to get apache airflow working using helm charts. After almost a week of struggling, I am nowhere - even to get the one provided in the apache airflow documentation working. I use Pop OS 20.04 and microk8s.</p> <p>When I run these commands:</p> <pre><code>kubectl create namespace airflow helm repo add apache-airflow https://airflow.apache.org helm install airflow apache-airflow/airflow --namespace airflow </code></pre> <p>The helm installation times out after five minutes.</p> <pre><code>kubectl get pods -n airflow </code></pre> <p>shows this list:</p> <pre><code>NAME READY STATUS RESTARTS AGE airflow-postgresql-0 0/1 Pending 0 4m8s airflow-redis-0 0/1 Pending 0 4m8s airflow-worker-0 0/2 Pending 0 4m8s airflow-scheduler-565d8587fd-vm8h7 0/2 Init:0/1 0 4m8s airflow-triggerer-7f4477dcb6-nlhg8 0/1 Init:0/1 0 4m8s airflow-webserver-684c5d94d9-qhhv2 0/1 Init:0/1 0 4m8s airflow-run-airflow-migrations-rzm59 1/1 Running 0 4m8s airflow-statsd-84f4f9898-sltw9 1/1 Running 0 4m8s airflow-flower-7c87f95f46-qqqqx 0/1 Running 4 4m8s </code></pre> <p>Then when I run the below command:</p> <pre><code>kubectl describe pod airflow-postgresql-0 -n airflow </code></pre> <p>I get the below (trimmed up to the events):</p> <pre><code>Events: Type Reason Age From Message ---- ------ ---- ---- ------- Warning FailedScheduling 58s (x2 over 58s) default-scheduler 0/1 nodes are available: 1 pod has unbound immediate PersistentVolumeClaims. </code></pre> <p>Then I deleted the namespace using the following commands</p> <pre><code>kubectl delete ns airflow </code></pre> <p>At this point, the termination of the pods gets stuck. Then I bring up the proxy in another terminal:</p> <pre><code>kubectl proxy </code></pre> <p>Then issue the following command to force deleting the namespace and all it's pods and resources:</p> <pre><code>kubectl get ns airflow -o json | jq '.spec.finalizers=[]' | curl -X PUT http://localhost:8001/api/v1/namespaces/airflow/finalize -H &quot;Content-Type: application/json&quot; --data @- </code></pre> <p>Then I deleted the PVC's using the following command:</p> <pre><code>kubectl delete pvc --force --grace-period=0 --all -n airflow </code></pre> <p>You get stuck again, so I had to issue another command to force this deletion:</p> <pre><code>kubectl patch pvc data-airflow-postgresql-0 -p '{&quot;metadata&quot;:{&quot;finalizers&quot;:null}}' -n airflow </code></pre> <p>The PVC's gets terminated at this point and these two commands return nothing:</p> <pre><code>kubectl get pvc -n airflow kubectl get all -n airflow </code></pre> <p>Then I restarted the machine and executed the helm install again (using first and last commands in the first section of this question), but the same result.</p> <p>I executed the following command then (using the suggestions I found here):</p> <pre><code>kubectl describe pvc -n airflow </code></pre> <p>I got the following output (I am posting the event portion of PostgreSQL):</p> <pre><code>Type Reason Age From Message ---- ------ ---- ---- ------- Normal FailedBinding 2m58s (x42 over 13m) persistentvolume-controller no persistent volumes available for this claim and no storage class is set </code></pre> <p>So my assumption is that I need to provide storage class as part of the values.yaml</p> <p>Is my understanding right? How do I provide the required (and what values) in the values.yaml?</p>
<p>If you installed with helm, you can uninstall with <code>helm delete airflow -n airflow</code>.</p> <p>Here's a way to install airflow for <strong>testing</strong> purposes using default values:</p> <p>Generate the manifest <code>helm template airflow apache-airflow/airflow -n airflow &gt; airflow.yaml</code></p> <p>Open the &quot;airflow.yaml&quot; with your favorite editor, replace all &quot;volumeClaimTemplates&quot; with emptyDir. Example:</p> <p><a href="https://i.stack.imgur.com/klKsT.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/klKsT.png" alt="enter image description here" /></a></p> <p>Create the namespace and install:</p> <pre><code>kubectl create namespace airflow kubectl apply -f airflow.yaml --namespace airflow </code></pre> <p><a href="https://i.stack.imgur.com/VqyEd.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/VqyEd.png" alt="enter image description here" /></a></p> <p>You can <a href="https://stackoverflow.com/a/70163535/14704799">copy</a> files out from the pods if needed.</p> <p>To delete <code>kubectl delete -f airflow.yaml --namespace airflow</code>.</p>
<p>I am in the learning phase of kubernetes and able to set up deployments, services etc. However I have got stuck on how to manage secrets.</p> <p>Context</p> <ol> <li><p>I am using GKE for Kubernetes cluster</p> </li> <li><p>I am using helm charts for managing all deployment operations</p> </li> <li><p>I have created a google service account that has access to say google cloud storage.</p> </li> </ol> <p>My application uses the helm to create deployments and services, however, how do I manage the google service account creds I have created in an automated way like</p> <ol> <li><p>I do not want to create the secrets manually like this - <code>kubectl create secret generic pubsub-key --from-file=key.json=PATH-TO-KEY-FILE.json</code> , I want to do it through helm because say tomorrow if I move to another k8s cluster then I have do it manually again</p> </li> <li><p>Is there anyway to push my helm charts to repos without concerning of exposing my secrets as plain objects.</p> </li> </ol> <p>Apart from this, any other guidelines and best practices would be really helpful.</p>
<blockquote> <p>I do not want to create the secrets manually like this - kubectl create secret generic pubsub-key --from-file=key.json=PATH-TO-KEY-FILE.json , I want to do it through helm because say tomorrow if I move to another k8s cluster then I have do it manually again</p> </blockquote> <p>You can create the <strong>secret</strong> template to helm which will create the secret for you, at run time of helm time.</p> <p>You helm will find the <code>service account.json</code> and create the secret based on that.</p> <p>For example <strong>service-account.yaml</strong></p> <pre><code>{{- $all := . -}} {{ range $name, $secret := .Values.serviceAccountSecrets }} apiVersion: v1 kind: Secret metadata: name: {{ $name }} labels: app: {{ $name }} chart: {{ template &quot;atlantis.chart&quot; $all }} component: service-account-secret heritage: {{ $all.Release.Service }} release: {{ $all.Release.Name }} data: service-account.json: {{ $secret }} --- {{ end }} </code></pre> <p><strong>values.yaml</strong></p> <pre><code>serviceAccountSecrets: # credentials: &lt;json file as base64 encoded string&gt; # credentials-staging: &lt;json file as base64 encoded string&gt; </code></pre> <p>Or else you can use this GCP service account controller which creates the <strong>Serviceaccount</strong> and the <strong>secret</strong> for you.</p> <p><a href="https://github.com/kiwigrid/gcp-serviceaccount-controller" rel="nofollow noreferrer">https://github.com/kiwigrid/gcp-serviceaccount-controller</a></p> <blockquote> <p>Is there anyway to push my helm charts to repos without concerning of exposing my secrets as plain objects.</p> </blockquote> <p>For committing issues you can use the <code>.helmignore</code> file.</p> <p>Read more at : <a href="https://helm.sh/docs/chart_template_guide/helm_ignore_file/" rel="nofollow noreferrer">https://helm.sh/docs/chart_template_guide/helm_ignore_file/</a></p> <p>So inside the GIT, you have to commit only <code>values.yaml</code> not <code>values-dev.yaml</code>, <code>values-stag.yaml</code></p>
<p>After almost 1 year without a problem, I realized that cert-manager can't produce certificates anymore.</p> <p>I started seeing this error:</p> <blockquote> <p>Error from server: conversion webhook for cert-manager.io/v1alpha2, Kind=Certificate failed: Post &quot;https://cert-manager-webhook.cert-manager.svc:443/convert?timeout=30s&quot;: x509: certificate has expired or is not yet valid: current time 2021-12-05T01:02:15Z is after 2021-12-03T14:15:56Z</p> </blockquote> <p>I do NOT have a problem with the existing certificates/domains. But, it can't create certs for new domains.</p> <p>Also,</p> <pre><code>kubectl get cert </code></pre> <p>has the same error output.</p> <p>What is the recommended solution?</p>
<p>I would suggest updating the version of <strong>Cert-manager</strong> you are running.</p> <pre><code>helm install \ cert-manager jetstack/cert-manager \ --namespace mynamespace \ --version v0.15.1 \ --set installCRDs=true </code></pre> <p>do not forget to install the CRD.</p> <p><code>Cert-manager</code> supports the latest two releases only which are currently <strong>1.5</strong> and <strong>1.6</strong> while <strong>1.7</strong> is an upcoming release.</p> <p>Refer to the Release document <a href="https://cert-manager.io/docs/installation/supported-releases/" rel="nofollow noreferrer">here</a> and you can also refer to the reported <a href="https://github.com/jetstack/cert-manager/issues/2752" rel="nofollow noreferrer">issue</a> for more information.</p>
<p>I have configured 1 master 2 workers. after installation successfully kubernetes. It is OK with worker1 joining cluster but I can not join worker2 to the cluster because kubelet service is not running. <strong>It seems like the kubelet isn't running or healthy</strong></p> <p><strong>sudo kubectl get nodes:</strong></p> <blockquote> <p>NAME STATUS ROLES AGE VERSION<br /> master1 Ready control-plane,master 23m v1.22.2<br /> node1 NotReady 4m13s v1.22.2</p> </blockquote> <p>I want to know why the kubelet service is not running.</p> <p><strong>Here kubelet logs.</strong></p> <pre><code>The start-up result is RESULT. Dec 04 20:21:26 node2 kubelet[25435]: Flag --network-plugin has been deprecated, will be removed along with dockershim. Dec 04 20:21:26 node2 kubelet[25435]: Flag --network-plugin has been deprecated, will be removed along with dockershim. Dec 04 20:21:26 node2 kubelet[25435]: I1204 20:21:26.659131 25435 server.go:440] &quot;Kubelet version&quot; kubeletVersion=&quot;v1.22.2&quot; Dec 04 20:21:26 node2 kubelet[25435]: I1204 20:21:26.659587 25435 server.go:868] &quot;Client rotation is on, will bootstrap in background&quot; Dec 04 20:21:26 node2 kubelet[25435]: I1204 20:21:26.678863 25435 certificate_store.go:130] Loading cert/key pair from &quot;/var/lib/kubelet/pki/kubelet-client-current.pem&quot;. Dec 04 20:21:26 node2 kubelet[25435]: I1204 20:21:26.684321 25435 dynamic_cafile_content.go:155] &quot;Starting controller&quot; name=&quot;client-ca-bundle::/etc/kubernetes/pki/ca.crt&quot; Dec 04 20:21:26 node2 kubelet[25435]: I1204 20:21:26.728096 25435 server.go:687] &quot;--cgroups-per-qos enabled, but --cgroup-root was not specified. defaulting to /&quot; Dec 04 20:21:26 node2 kubelet[25435]: I1204 20:21:26.728320 25435 container_manager_linux.go:280] &quot;Container manager verified user specified cgroup-root exists&quot; cgroupRoot=[] Dec 04 20:21:26 node2 kubelet[25435]: I1204 20:21:26.728388 25435 container_manager_linux.go:285] &quot;Creating Container Manager object based on Node Config&quot; nodeConfig={RuntimeCgroupsName: Dec 04 20:21:26 node2 kubelet[25435]: I1204 20:21:26.729329 25435 topology_manager.go:133] &quot;Creating topology manager with policy per scope&quot; topologyPolicyName=&quot;none&quot; topologyScopeName=&quot;c Dec 04 20:21:26 node2 kubelet[25435]: I1204 20:21:26.729345 25435 container_manager_linux.go:320] &quot;Creating device plugin manager&quot; devicePluginEnabled=true Dec 04 20:21:26 node2 kubelet[25435]: I1204 20:21:26.729367 25435 state_mem.go:36] &quot;Initialized new in-memory state store&quot; Dec 04 20:21:26 node2 kubelet[25435]: I1204 20:21:26.729408 25435 kubelet.go:314] &quot;Using dockershim is deprecated, please consider using a full-fledged CRI implementation&quot; Dec 04 20:21:26 node2 kubelet[25435]: I1204 20:21:26.729430 25435 client.go:78] &quot;Connecting to docker on the dockerEndpoint&quot; endpoint=&quot;unix:///var/run/docker.sock&quot; Dec 04 20:21:26 node2 kubelet[25435]: I1204 20:21:26.729441 25435 client.go:97] &quot;Start docker client with request timeout&quot; timeout=&quot;2m0s&quot; Dec 04 20:21:26 node2 kubelet[25435]: I1204 20:21:26.744324 25435 docker_service.go:566] &quot;Hairpin mode is set but kubenet is not enabled, falling back to HairpinVeth&quot; hairpinMode=promiscu Dec 04 20:21:26 node2 kubelet[25435]: I1204 20:21:26.744354 25435 docker_service.go:242] &quot;Hairpin mode is set&quot; hairpinMode=hairpin-veth Dec 04 20:21:26 node2 kubelet[25435]: I1204 20:21:26.744554 25435 cni.go:239] &quot;Unable to update cni config&quot; err=&quot;no networks found in /etc/cni/net.d&quot; Dec 04 20:21:26 node2 kubelet[25435]: I1204 20:21:26.750011 25435 cni.go:239] &quot;Unable to update cni config&quot; err=&quot;no networks found in /etc/cni/net.d&quot; Dec 04 20:21:26 node2 kubelet[25435]: I1204 20:21:26.750260 25435 docker_service.go:257] &quot;Docker cri networking managed by the network plugin&quot; networkPluginName=&quot;cni&quot; Dec 04 20:21:26 node2 kubelet[25435]: I1204 20:21:26.753050 25435 cni.go:239] &quot;Unable to update cni config&quot; err=&quot;no networks found in /etc/cni/net.d&quot; Dec 04 20:21:26 node2 kubelet[25435]: I1204 20:21:26.764080 25435 docker_service.go:264] &quot;Docker Info&quot; dockerInfo=&amp;{ID:4UUR:AFJU:SXYE:5IRP:6G6B:SFDY:H3AA:D5ZB:JSDO:GXVQ:UYNG:POJY Containe Dec 04 20:21:26 node2 kubelet[25435]: E1204 20:21:26.765777 25435 server.go:294] &quot;Failed to run kubelet&quot; err=&quot;failed to run Kubelet: misconfiguration: kubelet cgroup driver: \&quot;systemd\&quot; i Dec 04 20:21:26 node2 systemd[1]: kubelet.service: Main process exited, code=exited, status=1/FAILURE Dec 04 20:21:26 node2 systemd[1]: kubelet.service: Failed with result 'exit-code'. </code></pre> <p><strong>kubeadm join logs:</strong></p> <pre><code>I1204 20:27:56.222794 29796 join.go:405] [preflight] found NodeName empty; using OS hostname as NodeName I1204 20:27:56.223032 29796 initconfiguration.go:116] detected and using CRI socket: /var/run/dockershim.sock [preflight] Running pre-flight checks I1204 20:27:56.223834 29796 preflight.go:92] [preflight] Running general checks I1204 20:27:56.225983 29796 checks.go:245] validating the existence and emptiness of directory /etc/kubernetes/manifests I1204 20:27:56.226133 29796 checks.go:282] validating the existence of file /etc/kubernetes/kubelet.conf I1204 20:27:56.226271 29796 checks.go:282] validating the existence of file /etc/kubernetes/bootstrap-kubelet.conf I1204 20:27:56.226408 29796 checks.go:106] validating the container runtime I1204 20:27:56.282374 29796 checks.go:132] validating if the &quot;docker&quot; service is enabled and active I1204 20:27:56.300100 29796 checks.go:331] validating the contents of file /proc/sys/net/bridge/bridge-nf-call-iptables I1204 20:27:56.300279 29796 checks.go:331] validating the contents of file /proc/sys/net/ipv4/ip_forward I1204 20:27:56.300580 29796 checks.go:649] validating whether swap is enabled or not I1204 20:27:56.300738 29796 checks.go:372] validating the presence of executable conntrack I1204 20:27:56.301009 29796 checks.go:372] validating the presence of executable ip I1204 20:27:56.301613 29796 checks.go:372] validating the presence of executable iptables I1204 20:27:56.301801 29796 checks.go:372] validating the presence of executable mount I1204 20:27:56.302057 29796 checks.go:372] validating the presence of executable nsenter I1204 20:27:56.302384 29796 checks.go:372] validating the presence of executable ebtables I1204 20:27:56.302473 29796 checks.go:372] validating the presence of executable ethtool I1204 20:27:56.302569 29796 checks.go:372] validating the presence of executable socat I1204 20:27:56.302610 29796 checks.go:372] validating the presence of executable tc I1204 20:27:56.303072 29796 checks.go:372] validating the presence of executable touch I1204 20:27:56.303472 29796 checks.go:520] running all checks I1204 20:27:56.372402 29796 checks.go:403] checking whether the given node name is valid and reachable using net.LookupHost I1204 20:27:56.373211 29796 checks.go:618] validating kubelet version I1204 20:27:56.467792 29796 checks.go:132] validating if the &quot;kubelet&quot; service is enabled and active I1204 20:27:56.485715 29796 checks.go:205] validating availability of port 10250 I1204 20:27:56.486624 29796 checks.go:282] validating the existence of file /etc/kubernetes/pki/ca.crt I1204 20:27:56.487016 29796 checks.go:432] validating if the connectivity type is via proxy or direct I1204 20:27:56.487841 29796 join.go:475] [preflight] Discovering cluster-info I1204 20:27:56.488260 29796 token.go:80] [discovery] Created cluster-info discovery client, requesting info from &quot;192.168.1.53:6443&quot; I1204 20:27:56.520182 29796 token.go:118] [discovery] Requesting info from &quot;192.168.1.53:6443&quot; again to validate TLS against the pinned public key I1204 20:27:56.530589 29796 token.go:135] [discovery] Cluster info signature and contents are valid and TLS certificate validates against pinned roots, will use API Server &quot;192.168.1.53:6443&quot; I1204 20:27:56.530702 29796 discovery.go:52] [discovery] Using provided TLSBootstrapToken as authentication credentials for the join process I1204 20:27:56.530924 29796 join.go:489] [preflight] Fetching init configuration I1204 20:27:56.531171 29796 join.go:534] [preflight] Retrieving KubeConfig objects [preflight] Reading configuration from the cluster... [preflight] FYI: You can look at this config file with 'kubectl -n kube-system get cm kubeadm-config -o yaml' I1204 20:27:56.549808 29796 interface.go:431] Looking for default routes with IPv4 addresses I1204 20:27:56.549913 29796 interface.go:436] Default route transits interface &quot;enp0s3&quot; I1204 20:27:56.550259 29796 interface.go:208] Interface enp0s3 is up I1204 20:27:56.550564 29796 interface.go:256] Interface &quot;enp0s3&quot; has 2 addresses :[192.168.1.50/24 fe80::a00:27ff:fe7e:db8b/64]. I1204 20:27:56.550644 29796 interface.go:223] Checking addr 192.168.1.50/24. I1204 20:27:56.550887 29796 interface.go:230] IP found 192.168.1.50 I1204 20:27:56.550955 29796 interface.go:262] Found valid IPv4 address 192.168.1.50 for interface &quot;enp0s3&quot;. I1204 20:27:56.551237 29796 interface.go:442] Found active IP 192.168.1.50 I1204 20:27:56.563573 29796 preflight.go:103] [preflight] Running configuration dependant checks I1204 20:27:56.563872 29796 controlplaneprepare.go:219] [download-certs] Skipping certs download I1204 20:27:56.565399 29796 kubelet.go:112] [kubelet-start] writing bootstrap kubelet config file at /etc/kubernetes/bootstrap-kubelet.conf I1204 20:27:56.569613 29796 kubelet.go:120] [kubelet-start] writing CA certificate at /etc/kubernetes/pki/ca.crt I1204 20:27:56.572216 29796 kubelet.go:141] [kubelet-start] Checking for an existing Node in the cluster with name &quot;node2&quot; and status &quot;Ready&quot; I1204 20:27:56.576685 29796 kubelet.go:155] [kubelet-start] Stopping the kubelet [kubelet-start] Writing kubelet configuration to file &quot;/var/lib/kubelet/config.yaml&quot; [kubelet-start] Writing kubelet environment file with flags to file &quot;/var/lib/kubelet/kubeadm-flags.env&quot; [kubelet-start] Starting the kubelet [kubelet-start] Waiting for the kubelet to perform the TLS Bootstrap... I1204 20:28:01.956734 29796 kubelet.go:190] [kubelet-start] preserving the crisocket information for the node I1204 20:28:01.956911 29796 patchnode.go:31] [patchnode] Uploading the CRI Socket information &quot;/var/run/dockershim.sock&quot; to the Node API object &quot;node2&quot; as an annotation I1204 20:28:01.957066 29796 cert_rotation.go:137] Starting client certificate rotation controller [kubelet-check] Initial timeout of 40s passed. [kubelet-check] It seems like the kubelet isn't running or healthy. [kubelet-check] The HTTP call equal to 'curl -sSL http://localhost:10248/healthz' failed with error: Get &quot;http://localhost:10248/healthz&quot;: dial tcp 127.0.0.1:10248: connect: connection refused. [kubelet-check] It seems like the kubelet isn't running or healthy. [kubelet-check] The HTTP call equal to 'curl -sSL http://localhost:10248/healthz' failed with error: Get &quot;http://localhost:10248/healthz&quot;: dial tcp 127.0.0.1:10248: connect: connection refused. [kubelet-check] It seems like the kubelet isn't running or healthy. [kubelet-check] The HTTP call equal to 'curl -sSL http://localhost:10248/healthz' failed with error: Get &quot;http://localhost:10248/healthz&quot;: dial tcp 127.0.0.1:10248: connect: connection refused. [kubelet-check] It seems like the kubelet isn't running or healthy. [kubelet-check] The HTTP call equal to 'curl -sSL http://localhost:10248/healthz' failed with error: Get &quot;http://localhost:10248/healthz&quot;: dial tcp 127.0.0.1:10248: connect: connection refused. </code></pre>
<p>First, check if swap is diabled on your node as you MUST disable swap in order for the kubelet to work properly.</p> <pre class="lang-sh prettyprint-override"><code>sudo swapoff -a sudo sed -i '/ swap / s/^/#/' /etc/fstab </code></pre> <p>Also check out if kubernetes and docker cgroup driver is set to same. From <a href="https://kubernetes.io/docs/setup/production-environment/tools/kubeadm/install-kubeadm/#configuring-a-cgroup-driver" rel="noreferrer">kubernetes documentation</a>:</p> <blockquote> <p>Both the container runtime and the kubelet have a property called &quot;cgroup driver&quot;, which is important for the management of cgroups on Linux machines.<br /> Warning: Matching the container runtime and kubelet cgroup drivers is required or otherwise the kubelet process will fail.</p> </blockquote> <p>The <a href="https://kubernetes.io/docs/setup/production-environment/container-runtimes/" rel="noreferrer">Container runtimes</a> page explains that the systemd driver is recommended for kubeadm based setups instead of the cgroupfs driver, because kubeadm manages the kubelet as a systemd service.</p> <p>For docker:</p> <pre><code>docker info |grep -i cgroup </code></pre> <p>You can add this to <code>/etc/docker/daemon.json</code> to set the docker cgroup driver to systemd:</p> <pre><code>{ &quot;exec-opts&quot;: [&quot;native.cgroupdriver=systemd&quot;] } </code></pre> <p>Restart your docker service after making any changes with</p> <pre><code>sudo systemctl daemon-reload sudo systemctl restart docker sudo systemctl restart kubelet </code></pre> <p>You can try to execute <code>kubeadm join</code> after performing the above steps.</p>
<p>I want to get the last time a secret was modified via the kube api. I cannot seem to find a way to access this information. I had a look at events but I cannot find any for Secrets.</p> <p>An example would be I create a secret called my-secret, I then update this the next day but I want to know what time it was updated and not the creation time.</p> <p>Any help would be great thanks.</p>
<p>The following command will give you the secret chronological history:</p> <p><code>kubectl get secret &lt;name&gt; --namespace &lt;namespace&gt; --show-managed-fields -o jsonpath='{range .metadata.managedFields[*]}{.manager}{&quot; did &quot;}{.operation}{&quot; at &quot;}{.time}{&quot;\n&quot;}{end}'</code></p> <p>Example, create a secret: <code>kubectl create secret generic test --from-literal user=$(echo 'somebody' | base64)</code></p> <p>Run the above command:</p> <blockquote> <p>kubectl-create did Update at <strong>2021-12-06T01:12:17Z</strong></p> </blockquote> <p>Retrieve the created secret <code>kubectl get secret test -o yaml &gt; test.yaml</code>. Replace the value for &quot;user&quot; in the yaml with <code>echo 'nobody' | base64</code> output and re-apply <code>kubectl apply -f test.yaml</code>.</p> <p>Run the above command and it reports the last update action and timestamp:</p> <blockquote> <p>kubectl-create did Update at <strong>2021-12-06T01:12:17Z</strong></p> <p>kubectl-client-side-apply did Update at <strong>2021-12-06T01:13:33Z</strong></p> </blockquote> <p>Now do a replace <code>kubectl patch secret test --type='json' -p='[{&quot;op&quot; : &quot;replace&quot; ,&quot;path&quot; : &quot;/data/user&quot; ,&quot;value&quot; : &quot;aGVsbG93b3JsZAo=&quot;}]'</code></p> <p>Run the above command again:</p> <blockquote> <p>kubectl-create did Update at <strong>2021-12-06T01:12:17Z</strong></p> <p>kubectl-client-side-apply did Update at <strong>2021-12-06T01:13:33Z</strong></p> <p>kubectl-patch did Update at <strong>2021-12-06T01:21:57Z</strong></p> </blockquote> <p>The command correctly reports all the changes made to the secret.</p>
<p>How to implement memory state/session replications with K8S? For instance, a web shopping cart system replicates the user HTTP sessions among cluster nodes over the network so that if a node is down, a process in another node can take over the user sessions.</p> <p>K8S has StatefulSet which uses the disk storages to assure the state persistency, I think. If a pod is down, the restarted pod takes over the state form the disk. However, the overhead of persisting in-memory user sessions to disk is high and may not be fast enough.</p> <p>I suppose the solution could be using memory cache server or etcd like systems. Is it the established practice? In my understanding, K8S is good for stateless processing in scale, and StatefulSet had been introduced to address stateful situation but not sure it is good fit for situation where fast stateful handover is required.</p> <p>Please advise.</p>
<blockquote> <p>How to implement memory state/session replications with K8S? For instance, a web shopping cart system replicates the user HTTP sessions among cluster nodes over the network so that if a node is down, a process in another node can take over the user sessions.</p> </blockquote> <p>To store the state it's best to use the Redis or in-memory database.</p> <blockquote> <p>K8S has StatefulSet which uses the disk storages to assure the state persistency, I think. If a pod is down, the restarted pod takes over the state form the disk. However, the overhead of persisting in-memory user sessions to disk is high and may not be fast enough.</p> </blockquote> <p>You are right but maybe you have not tried it before, i been using the Redis for Production in K8s with million of users but never faced issues. Redis has two options for backup the keys if you deploy on K8s.</p> <p><strong>RDB</strong> and Append <strong>only-AOF</strong>, till now never faced <strong>Redis</strong> crashed or so, but only get crashed due to <strong>Out of Memory</strong>, so make sure your <strong>Key policy</strong> is set properly like <strong>LRU</strong> or so.</p> <blockquote> <p>In my understanding, K8S is good for stateless processing in scale</p> </blockquote> <p>You are right but people have been using the Deployment and Statefulsets for running Redis cluster and Elasticsearch clusters in K8s also with all backup and scaling options.</p> <p>It's easy to configure &amp; manage the <strong>DB</strong> with K8s while with <strong>VM</strong> not much scalability there.</p> <p>We have been running stateful sets with <strong>Redis</strong>, <strong>Elasticsearch</strong>, <strong>RabbitMQ</strong> since long in <strong>Prod</strong> and have not seen many issues. Make sure you attach the SSD high IOPS disk to POD and you are good to go.</p> <p>Nice example : <a href="https://github.com/loopbackio/loopback4-example-shopping/blob/master/kubernetes/README.md" rel="nofollow noreferrer">https://github.com/loopbackio/loopback4-example-shopping/blob/master/kubernetes/README.md</a></p>
<p>I took a course a while ago on Kubernetes. I used my Ubuntu 20.04.3 LTS laptop to set up the environment for educational purposes.</p> <p>I used microk8s as my Kubernetes distribution.</p> <p>I recently noticed that there were the following processes using about 1/2 GB of memory:</p> <pre><code>kube-apiserver kube-controller kubelet </code></pre> <p>They are all running as root.</p> <p>This is their specific version information.</p> <pre><code>Client Version: version.Info{Major:&quot;1&quot;, Minor:&quot;20+&quot;, GitVersion:&quot;v1.20.13-35+005120472f128e&quot;, GitCommit:&quot;005120472f128ee37994ebbe34eb340d4a580a95&quot;, GitTreeState:&quot;clean&quot;, BuildDate:&quot;2021-11-18T08:25:58Z&quot;, GoVersion:&quot;go1.15.15&quot;, Compiler:&quot;gc&quot;, Platform:&quot;linux/amd64&quot;} Server Version: version.Info{Major:&quot;1&quot;, Minor:&quot;20+&quot;, GitVersion:&quot;v1.20.13-35+005120472f128e&quot;, GitCommit:&quot;005120472f128ee37994ebbe34eb340d4a580a95&quot;, GitTreeState:&quot;clean&quot;, BuildDate:&quot;2021-11-18T08:26:57Z&quot;, GoVersion:&quot;go1.15.15&quot;, Compiler:&quot;gc&quot;, Platform:&quot;linux/amd64&quot;} </code></pre> <p>I tried to kill the processes by using the following method:</p> <pre><code>sudo kill -9 {pid} </code></pre> <p>However, the processes came back!</p> <p>How do I kill a microk8s kubernetes cluster? I do not care about retaining any data and I do not want the cluster to restart on boot.</p>
<p>You can remove the microk8s using following command in ubuntu:</p> <pre><code>sudo snap remove microk8s </code></pre> <p>The above command should remove all the services from your laptop.</p>
<p>I would like to run a pod on one of my IoT devices. Each one of those devices contains an environment variable I want this pod to use. Is there any way to inject this env variable into the pod using build-in templating of <code>helm</code>/<code>kubectl</code>? I was trying the following on my <code>deployment.yaml</code> file:</p> <pre><code>env: - name: XXX value: $ENV_FROM_HOST </code></pre> <p>but when executing the pod and trying the get <code>XXX</code> value, I get the string <code>$ENV_FROM_HOST</code> instead of its value from the host:</p> <pre><code>$ echo $XXX $ENV_FROM_HOST </code></pre> <p>Thanks.</p>
<p>It's not possible to directly pass the host's env vars to the pods. I often do that by creating a ConfigMap.</p> <ol> <li><p>Create a ConfigMap with <code>from-lireral</code> option:</p> <pre><code>kubectl create configmap testcm --from-literal=hostname=$HOSTNAME </code></pre> </li> <li><p>Refer to that in the Pod's manifest:</p> <pre class="lang-yaml prettyprint-override"><code>- name: TEST valueFrom: configMapKeyRef: name: testcm key: hostname </code></pre> </li> </ol> <p>This will inject the host's $HOSTNAME into the Pod's $TEST.</p> <p>If it's sensitive information, you can use Secrets instead of using ConfigMap.</p>
<p>I have bunch of cron jobs that sit in an EKS cluster and would like to trigger them via HTTP call. Does such API exist from Kubernetes? If not, what else can be done?</p>
<p>Every action in Kubernetes ca be invoked via rest API call. This is also stated as such in the <a href="https://kubernetes.io/docs/concepts/overview/kubernetes-api/" rel="nofollow noreferrer">docs</a>.</p> <p>There is a full <a href="https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.23/#-strong-api-overview-strong-" rel="nofollow noreferrer">API reference</a> for the Kubernetes API you can review.</p> <p>In fact, <a href="https://kubernetes.io/docs/reference/kubectl/overview/" rel="nofollow noreferrer">kubectl</a> is using http under the hood. You can see those http calls by using the <code>v</code> flag with some <a href="https://goglides.io/kubectl-http-request-to-formulate-rbac/123/" rel="nofollow noreferrer">verbosity level</a>. For example:</p> <pre class="lang-sh prettyprint-override"><code>$ kubectl get pods -v=6 I1206 00:06:33.591871 19308 loader.go:372] Config loaded from file: /home/blue/.kube/config I1206 00:06:33.826009 19308 round_trippers.go:454] GET https://mycluster.azmk8s.io:443/api?timeout=32s 200 OK in 233 milliseconds ... </code></pre> <p>So you could check out the command you need by looking how kubectl does it. But given the fact that kubectl does use http, it's maybe easier to just use kubectl directly.</p>
<p>After almost 1 year without a problem, I realized that cert-manager can't produce certificates anymore.</p> <p>I started seeing this error:</p> <blockquote> <p>Error from server: conversion webhook for cert-manager.io/v1alpha2, Kind=Certificate failed: Post &quot;https://cert-manager-webhook.cert-manager.svc:443/convert?timeout=30s&quot;: x509: certificate has expired or is not yet valid: current time 2021-12-05T01:02:15Z is after 2021-12-03T14:15:56Z</p> </blockquote> <p>I do NOT have a problem with the existing certificates/domains. But, it can't create certs for new domains.</p> <p>Also,</p> <pre><code>kubectl get cert </code></pre> <p>has the same error output.</p> <p>What is the recommended solution?</p>
<p>Manually deleting secrets <code>cert-manager-webhook-ca</code> and <code>cert-manager-webhook-tls</code> may work in this case. Cert-manager controller will automatically create the deleted secrets afterwards.</p>
<p>I deployed a K8s <strong>StatefulSet</strong> with 30 replicas (or N replicas, where N is multiple of 3) in EKS Cluster.</p> <p>EKS cluster is with 3 nodes, one node for one AZ, and I want to <em>guarantee</em> with Kubernetes Affinity/AntiAffinity the <strong>equal</strong> distribution of pods across different AZ.</p> <pre><code>us-west-2a (n nodes) -&gt; N/3 pods us-west-2b (m nodes) -&gt; N/3 pods us-west-2c (o nodes) -&gt; N/3 pods </code></pre> <p>Thanks</p>
<p>While this is too possible with node affinity, a straight forward way is the use of topologySpreadContraints, here's the k8s <a href="https://kubernetes.io/docs/concepts/workloads/pods/pod-topology-spread-constraints/#api" rel="nofollow noreferrer">documentation, diagrams and examples</a> to see it in action.</p>
<p>I need to test a scenario to see how my app deals with latency. My application is in K8S on Azure (AKS) and its connecting to a Postgres DB in Azure. Anyone know of any good tools that aren't too tricky to implement?</p>
<p>I ended up created a haproxy VM and directing my db traffic through it. Then on the haproxy I used the network emulator linux tool to delay the traffic . It works really well</p> <p><a href="https://wiki.linuxfoundation.org/networking/netem" rel="nofollow noreferrer">https://wiki.linuxfoundation.org/networking/netem</a></p>
<p>I deployed a K8s <strong>StatefulSet</strong> with 30 replicas (or N replicas, where N is multiple of 3) in EKS Cluster.</p> <p>EKS cluster is with 3 nodes, one node for one AZ, and I want to <em>guarantee</em> with Kubernetes Affinity/AntiAffinity the <strong>equal</strong> distribution of pods across different AZ.</p> <pre><code>us-west-2a (n nodes) -&gt; N/3 pods us-west-2b (m nodes) -&gt; N/3 pods us-west-2c (o nodes) -&gt; N/3 pods </code></pre> <p>Thanks</p>
<p>You can always use selectors and default labels which you get from AWS. A simple pod spec example is here</p> <pre><code>topologySpreadConstraints: - maxSkew: 1 topologyKey: &quot;topology.kubernetes.io/zone&quot; whenUnsatisfiable: DoNotSchedule labelSelector: matchLabels: app: myapp </code></pre> <p>You can include skew and other options based on the need as described here: <a href="https://kubernetes.io/docs/concepts/workloads/pods/pod-topology-spread-constraints/" rel="nofollow noreferrer">https://kubernetes.io/docs/concepts/workloads/pods/pod-topology-spread-constraints/</a></p>
<p>We are using GridGain Community edition : 8.8.10 and have created Ignite Cluster in Kubernetes using the Apache Ignite operator. We have enabled native persistence also.</p> <p><a href="https://ignite.apache.org/docs/latest/installation/kubernetes/gke-deployment" rel="nofollow noreferrer">https://ignite.apache.org/docs/latest/installation/kubernetes/gke-deployment</a></p> <p>In the development environment we shutdown our cluster during the night and bring it up during morning hours. When the cluster comes up it contains the data which was stored earlier. If we search the cache using key then it returns the result, but if we use the Query API for partial search then it is not returning results. We checked the cache size and it matches the datasource record size. Also after we search the Cache using the cache key, then that entry is available in the Query search results.</p> <p>If we shut-down one of the nodes of the Ignite Cluster or client nodes. The TextSearch still works. TextSearch doesn't works only when all the nodes of the cluster are scaled-down and then scaled up using the existing disk.</p> <p>Is there any configuration required to enable Query search after cold restart of the Ignite cluster ?</p> <pre><code>&lt;bean id=&quot;ignite.cfg&quot; class=&quot;org.apache.ignite.configuration.IgniteConfiguration&quot;&gt; &lt;property name=&quot;metricsLogFrequency&quot; value=&quot;300000&quot;/&gt; &lt;property name=&quot;peerClassLoadingEnabled&quot; value=&quot;true&quot;/&gt; &lt;property name=&quot;clientMode&quot; value=&quot;true&quot;/&gt; &lt;property name=&quot;sqlConfiguration&quot;&gt; &lt;bean class=&quot;org.apache.ignite.configuration.SqlConfiguration&quot;&gt; &lt;property name=&quot;sqlGlobalMemoryQuota&quot; value=&quot;300M&quot;/&gt; &lt;property name=&quot;sqlQueryMemoryQuota&quot; value=&quot;30M&quot;/&gt; &lt;property name=&quot;sqlOffloadingEnabled&quot; value=&quot;true&quot;/&gt; &lt;/bean&gt; &lt;/property&gt; &lt;property name=&quot;workDirectory&quot; value=&quot;/gridgain/work&quot;/&gt; &lt;property name=&quot;dataStorageConfiguration&quot;&gt; &lt;bean class=&quot;org.apache.ignite.configuration.DataStorageConfiguration&quot;&gt; &lt;!-- set the size of wal segments to 128MB --&gt; &lt;property name=&quot;walSegmentSize&quot; value=&quot;#{128 * 1024 * 1024}&quot;/&gt; &lt;!-- Set the page size to 8 KB --&gt; &lt;property name=&quot;pageSize&quot; value=&quot;#{8 * 1024}&quot;/&gt; &lt;property name=&quot;defaultDataRegionConfiguration&quot;&gt; &lt;bean class=&quot;org.apache.ignite.configuration.DataRegionConfiguration&quot;&gt; &lt;property name=&quot;name&quot; value=&quot;Default_Region&quot;/&gt; &lt;!-- Memory region of 20 MB initial size. --&gt; &lt;property name=&quot;initialSize&quot; value=&quot;#{20 * 1024 * 1024}&quot;/&gt; &lt;!-- Memory region of 8 GB max size. --&gt; &lt;property name=&quot;maxSize&quot; value=&quot;#{8L * 1024 * 1024 * 1024}&quot;/&gt; &lt;!-- Enabling eviction for this memory region. --&gt; &lt;property name=&quot;pageEvictionMode&quot; value=&quot;RANDOM_2_LRU&quot;/&gt; &lt;property name=&quot;persistenceEnabled&quot; value=&quot;true&quot;/&gt; &lt;property name=&quot;warmUpConfiguration&quot;&gt; &lt;bean class=&quot;org.apache.ignite.configuration.LoadAllWarmUpConfiguration&quot;/&gt; &lt;/property&gt; &lt;!-- Increasing the buffer size to 1 GB. --&gt; &lt;property name=&quot;checkpointPageBufferSize&quot; value=&quot;#{1024L * 1024 * 1024}&quot;/&gt; &lt;/bean&gt; &lt;/property&gt; &lt;property name=&quot;walPath&quot; value=&quot;/gridgain/wal&quot;/&gt; &lt;property name=&quot;walArchivePath&quot; value=&quot;/gridgain/wal&quot;/&gt; &lt;/bean&gt; &lt;/property&gt; &lt;property name=&quot;discoverySpi&quot;&gt; &lt;bean class=&quot;org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi&quot;&gt; &lt;property name=&quot;ipFinder&quot;&gt; &lt;bean class=&quot;org.apache.ignite.spi.discovery.tcp.ipfinder.kubernetes.TcpDiscoveryKubernetesIpFinder&quot;&gt; &lt;property name=&quot;namespace&quot; value=&quot;cache&quot;/&gt; &lt;property name=&quot;serviceName&quot; value=&quot;cache-service&quot;/&gt; &lt;/bean&gt; &lt;/property&gt; &lt;property name=&quot;NetworkTimeout&quot; value=&quot;30000&quot;/&gt; &lt;/bean&gt; &lt;/property&gt; &lt;property name=&quot;communicationSpi&quot;&gt; &lt;bean class=&quot;org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi&quot;&gt; &lt;property name=&quot;slowClientQueueLimit&quot; value=&quot;2000&quot;/&gt; &lt;/bean&gt; &lt;/property&gt; &lt;property name=&quot;cacheConfiguration&quot; ref=&quot;igniteCacheDefinition&quot;/&gt; &lt;/bean&gt; </code></pre>
<p><strong>Apache Ignite</strong> uses <strong>Apache Lucene</strong> (currently it's 7.4.0) for text queries under the hood. In general Lucene-based indexes leverage various implementations of <a href="https://lucene.apache.org/core/7_4_0/core/org/apache/lucene/store/Directory.html" rel="nofollow noreferrer">org.apache.lucene.store.Directory</a>. In <strong>Apache Ignite</strong> it's a custom <a href="https://github.com/apache/ignite/blob/master/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridLuceneDirectory.java" rel="nofollow noreferrer">one</a>. In turn it uses RAM-based <a href="https://github.com/apache/ignite/blob/master/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridLuceneOutputStream.java#L69" rel="nofollow noreferrer">GridLuceneOutputStream</a>. Basically it means that Ignite native persistence doesn't come into play for those kinds of indexes at the moment.</p> <p>UPD: in case of configured backups for a partitioned cache it should work as a regular index. For example if you add an additional node to the baseline topology you would see a <a href="https://ignite.apache.org/docs/latest/data-rebalancing#data-rebalancing" rel="nofollow noreferrer">rebalance</a> happening. Rebalance uses regular cache operations to insert entries. Lucene index would be <a href="https://github.com/apache/ignite/blob/master/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java#L388" rel="nofollow noreferrer">built</a> on the new node. On the contrary if you remove a node from a cluster you would still have a full copy of data including text indexes.</p>
<p>I've created a cluster using terraform with:</p> <pre><code>provider "google" { credentials = "${file("gcp.json")}" project = "${var.gcp_project}" region = "us-central1" zone = "us-central1-c" } resource "google_container_cluster" "primary" { name = "${var.k8s_cluster_name}" location = "us-central1-a" project = "${var.gcp_project}" # We can't create a cluster with no node pool defined, but we want to only use # separately managed node pools. So we create the smallest possible default # node pool and immediately delete it. remove_default_node_pool = true initial_node_count = 1 master_auth { username = "" password = "" client_certificate_config { issue_client_certificate = false } } } resource "google_container_node_pool" "primary_preemptible_nodes" { project = "${var.gcp_project}" name = "my-node-pool" location = "us-central1-a" cluster = "${google_container_cluster.primary.name}" # node_count = 3 autoscaling { min_node_count = 3 max_node_count = 5 } node_config { # preemptible = true machine_type = "g1-small" metadata = { disable-legacy-endpoints = "true" } oauth_scopes = [ "https://www.googleapis.com/auth/logging.write", "https://www.googleapis.com/auth/monitoring", "https://www.googleapis.com/auth/devstorage.read_only" ] } } </code></pre> <p>Surprisingly this node pool seems to be 'stuck' at 0 instances? Why? How can I diagnose this?</p> <p><a href="https://i.stack.imgur.com/YZa7D.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/YZa7D.jpg" alt="enter image description here"></a></p>
<p>you should add &quot;initial_node_count&quot; (like <code>initial_node_count = 3</code>) to &quot;google_container_node_pool&quot; resourse. <a href="https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/container_node_pool#node_count" rel="nofollow noreferrer">Official documentation</a> says you should not to use &quot;node_count&quot; with &quot;autoscaling&quot;.</p>
<p>I have a haproxy as a load balancer running in k8s with a route to a service with two running pods. I want the server naming inside haproxy to correspond to the pod names behind my service. If I'm not mistaken the following configmap / annotation value should do exactly this: <code>https://haproxy-ingress.github.io/docs/configuration/keys/#backend-server-naming</code>. But for me it doesn't and for the life of me I can't find out why. The relevant parts of my configuration look like this:</p> <p>controller deployment:</p> <pre><code>kind: Deployment metadata: labels: run: haproxy-ingress name: haproxy-ingress namespace: haproxy-controller spec: replicas: 2 selector: matchLabels: run: haproxy-ingress template: metadata: labels: run: haproxy-ingress spec: serviceAccountName: haproxy-ingress-service-account containers: - name: haproxy-ingress image: haproxytech/kubernetes-ingress args: - --configmap=haproxy-controller/haproxy-ingress - --configmap-errorfiles=haproxy-controller/errorfile-conf - --default-ssl-certificate=haproxy-controller/haproxy-tls - --ingress.class=haproxy </code></pre> <p>controller service:</p> <pre><code>kind: Service metadata: labels: run: haproxy-ingress name: haproxy-ingress namespace: haproxy-controller spec: selector: run: haproxy-ingress type: ClusterIP ports: - name: https port: 443 protocol: TCP targetPort: 443 </code></pre> <p>controller configmap:</p> <pre><code>kind: ConfigMap metadata: name: haproxy-ingress namespace: haproxy-controller data: server-ssl: &quot;true&quot; scale-server-slots: &quot;2&quot; cookie-persistence: &quot;LFR_SRV&quot; backend-server-naming: &quot;pod&quot; backend-config-snippet: | cookie LFR_SRV indirect nocache insert maxidle 10m httponly secure </code></pre> <p>backend server ingress:</p> <pre><code>kind: Ingress metadata: name: liferay-dxp namespace: backend annotations: kubernetes.io/ingress.class: &quot;haproxy&quot; spec: tls: - secretName: backend-tls rules: - http: paths: - path: / pathType: Prefix backend: service: name: backend port: number: 443 </code></pre> <p>The generated backend part of the haproxy.conf looks like this:</p> <pre><code> mode http balance roundrobin option forwardfor cookie LFR_SRV indirect nocache insert ###_config-snippet_### BEGIN cookie LFR_SRV indirect nocache insert maxidle 10m httponly secure ###_config-snippet_### END server SRV_1 10.xx.xx.xx:443 check ssl alpn h2,http/1.1 weight 128 cookie SRV_1 verify none server SRV_2 10.xx.xx.xx:443 check ssl alpn h2,http/1.1 weight 128 cookie SRV_2 verify none </code></pre> <p>Everything works fine except <code>backend-server-naming: &quot;pod&quot;</code>. I also can't get any of the session-cookie-* properties from <a href="https://haproxy-ingress.github.io/docs/configuration/keys/#affinity" rel="nofollow noreferrer">here</a> to work. Because of that I used the <code>backend-config-snippet</code> to overwrite the cookie line in the generated haproxy.conf with my custom one (I added <code>maxidle 10m httponly secure</code>). What am I doing wrong?</p>
<p>Here are a few hints to help you out solving your issue.</p> <h2>Be sure you know the exact version of your haproxy-ingress controller:</h2> <p>Looking at the manifest files you shared, it's hard to tell which exact version of <code>haproxy-ingress-controller</code> container you are running in your cluster (btw, it's against best practices in production envs to leave it w/o tag, read more on it <a href="https://kubernetes.io/docs/concepts/containers/images/#image-pull-policy" rel="nofollow noreferrer">here</a>).</p> <p>For <code>backend-server-naming</code> configuration key to be working, minimum the <code>v0.8.1</code> is required <a href="https://github.com/jcmoraisjr/haproxy-ingress/issues/469#issuecomment-583339894" rel="nofollow noreferrer">(it was backported)</a>.</p> <p>Before you move on in troubleshooting, firstly please double check your ingress deployment for compatibility.</p> <h2>My observations of &quot;backend-server-naming=pod&quot; behavior</h2> <h3>Configuration dynamic updates:</h3> <p>If I understand correctly the official documentation on this <a href="https://haproxy-ingress.github.io/docs/configuration/keys/#backend-server-naming" rel="nofollow noreferrer">configuration key</a>, setting a server naming of backends to pod names (<code>backend-server-naming=pod</code>) instead of <code>sequences</code>, does support a dynamic re-load of haproxy configuration, but does <strong>NOT</strong> support as of now dynamic updates to haproxy run-time configuration to server names at backend section (it was explained by haproxy-ingress author <a href="https://github.com/jcmoraisjr/haproxy-ingress/issues/469#issuecomment-560022371" rel="nofollow noreferrer">here</a>, and <a href="https://github.com/jcmoraisjr/haproxy-ingress/issues/759#issuecomment-803169441" rel="nofollow noreferrer">here</a>)</p> <p>It means you need to restart your haproxy-ingress controller instance first, to be able to see changes in backend's server names reflected at haproxy configuration, e.g. situations when new Pod replicas appear or POD_IP changed due the Pod crash (expect addition/updates of server entries based on sequence naming).</p> <h3>Ingress Class:</h3> <p>I have tested successfully (see test below) the <code>backend-server-naming=pod</code> setting on <code>v0.13.4</code> with <a href="https://haproxy-ingress.github.io/docs/configuration/keys/#class-matter" rel="nofollow noreferrer">classified</a> Ingress type, based on <code>ingressClassName</code> field , rather than deprecated annotation <code>kubernetes.io/ingress.class</code>, as in your case:</p> <p>I'm not claiming your configuration won't work (it should too), but it's important to know, that dynamic updates to configuration (this includes changes to backend configs) won't happen on unclassified Ingress resource or wrongly classified one, unless you're really running <code>v0.12</code> or newer version.</p> <h2>Testing:</h2> <pre><code># Ingress class apiVersion: networking.k8s.io/v1 kind: IngressClass metadata: name: my-class annotations: ingressclass.kubernetes.io/is-default-class: &quot;true&quot; spec: controller: haproxy-ingress.github.io/controller # Demo Ingress resource apiVersion: networking.k8s.io/v1 kind: Ingress metadata: annotations: haproxy-ingress.github.io/backend-server-naming: &quot;pod&quot; name: echoserver spec: ingressClassName: my-class rules: - http: paths: - backend: service: name: echoserver port: number: 8080 path: / pathType: Prefix </code></pre> <p>HA proxy configuration with comment:</p> <pre><code>backend default_echoserver_8080 mode http balance roundrobin acl https-request ssl_fc http-request set-header X-Original-Forwarded-For %[hdr(x-forwarded-for)] if { hdr(x-forwarded-for) -m found } http-request del-header x-forwarded-for option forwardfor http-response set-header Strict-Transport-Security &quot;max-age=15768000&quot; if https-request # pod name start server echoserver-75d6f584bb-jlwb8 172.17.0.2:8080 weight 1 check inter 2s # pod name end server srv002 127.0.0.1:1023 disabled weight 1 check inter 2s server srv003 127.0.0.1:1023 disabled weight 1 check inter 2s server srv004 127.0.0.1:1023 disabled weight 1 check inter 2s ... </code></pre>
<p><strong>The context</strong></p> <p>Let me know if I've gone down a rabbit hole here.</p> <p>I have a simple web app with a frontend and backend component, deployed using Docker/Helm inside a Kubernetes cluster. The frontend is servable via nginx, and the backend component will be running a NodeJS microservice.</p> <p>I had been thinking to have both run on the same pod inside Docker, but ran into some problems getting both nginx and Node to run in the background. I could try having a startup script that runs both, but <a href="https://runnable.com/docker/rails/run-multiple-processes-in-a-container" rel="nofollow noreferrer">the Internet</a> says it's a best practice to have different containers each be responsible for only running one service - so one container to run nginx and another to run the microservice.</p> <p><strong>The problem</strong></p> <p>That's fine, but then say the nginx server's HTML pages need to know what to send a POST request to in the backend - how can the HTML pages know what IP to hit for the backend's Docker container? Articles like <a href="https://levelup.gitconnected.com/how-to-access-a-docker-container-from-another-container-656398c93576" rel="nofollow noreferrer">this one</a> come up talking about manually creating a Docker network for the two containers to speak to one another, but how can I configure this with Helm so that the frontend container knows how to hit the backend container each time a new container is deployed, without having to manually configure any network service each time? I want the deployments to be automated.</p>
<p>You mention that your frontend is based on Nginx.</p> <p>Accordingly,Frontend must hit the <strong>public</strong> URL of backend.</p> <p>Thus, backend must be exposed by choosing the service type, whether:</p> <ul> <li><strong>NodePort</strong> -&gt; Frontend will communicate to backend with <code>http://&lt;any-node-ip&gt;:&lt;node-port&gt;</code></li> <li>or <strong>LoadBalancer</strong> -&gt; Frontend will communicate to backend with the <code>http://loadbalancer-external-IP:service-port</code> of the service.</li> <li>or, keep it <strong>ClusterIP</strong>, but add <strong>Ingress</strong> resource on top of it -&gt; Frontend will communicate to backend with its ingress host <code>http://ingress.host.com</code>.</li> </ul> <p>We recommended the last way, but it requires to have ingress controller.</p> <p>Once you tested one of them and it works, then, you can extend your helm chart to update the service and add the ingress resource if needed</p>
<p>I created a nginx ingress using <a href="https://kubernetes.github.io/ingress-nginx/deploy/#quick-start" rel="nofollow noreferrer">this link</a> using docker-desktop.</p> <pre class="lang-sh prettyprint-override"><code>kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/controller-v1.1.0/deploy/static/provider/cloud/deploy.yaml </code></pre> <p>My service:</p> <pre class="lang-yaml prettyprint-override"><code>apiVersion: apps/v1 kind: Deployment metadata: name: be-assinaturas namespace: apps-space labels: tier: backend app: assinaturas spec: selector: matchLabels: name: be-assinaturas app: assinaturas strategy: type: Recreate replicas: 2 template: metadata: name: be-assinaturas labels: app: assinaturas name: be-assinaturas spec: containers: - name: be-assinaturas image: jedi31/assinaturas:latest imagePullPolicy: Always --- kind: Service apiVersion: v1 metadata: name: svc-assinaturas namespace: apps-space spec: selector: name: be-assinaturas app: assinaturas type: ClusterIP ports: - name: be-assinaturas-http port: 80 targetPort: 80 </code></pre> <p>My ingress resource is defined as:</p> <pre class="lang-yaml prettyprint-override"><code>apiVersion: networking.k8s.io/v1 kind: Ingress metadata: name: ingress-be-assinaturas namespace: apps-space annotations: kubernetes.io/ingress.class: &quot;nginx&quot; spec: rules: - http: paths: - path: /assinaturas pathType: Prefix backend: service: name: svc-assinaturas port: number: 80 </code></pre> <p>Running a <code>kubectl get services --all-namespaces</code> I get</p> <pre class="lang-sh prettyprint-override"><code>NAMESPACE NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE apps-space svc-assinaturas ClusterIP 10.107.188.28 &lt;none&gt; 80/TCP 12m default kubernetes ClusterIP 10.96.0.1 &lt;none&gt; 443/TCP 66d ingress-nginx ingress-nginx-controller LoadBalancer 10.102.238.173 localhost 80:32028/TCP,443:30397/TCP 5h45m ingress-nginx ingress-nginx-controller-admission ClusterIP 10.98.148.190 &lt;none&gt; 443/TCP 5h45m kube-system kube-dns ClusterIP 10.96.0.10 &lt;none&gt; 53/UDP,53/TCP,9153/TCP 66d </code></pre> <p>If I do a port forward on service, like this: <code>kubectl port-forward -n apps-space service/svc-assinaturas 5274:80</code></p> <p>I can acess my app using curl, like this: <code>curl -v http://localhost:5274/hc/alive</code></p> <p>and the response is:</p> <pre class="lang-sh prettyprint-override"><code>* Trying 127.0.0.1:5274... * TCP_NODELAY set * Connected to localhost (127.0.0.1) port 5274 (#0) &gt; GET /hc/alive HTTP/1.1 &gt; Host: localhost:5274 &gt; User-Agent: curl/7.68.0 &gt; Accept: */* &gt; * Mark bundle as not supporting multiuse &lt; HTTP/1.1 200 OK &lt; Content-Type: application/json; charset=utf-8 &lt; Date: Mon, 06 Dec 2021 23:22:40 GMT &lt; Server: Kestrel &lt; Transfer-Encoding: chunked &lt; * Connection #0 to host localhost left intact {&quot;service&quot;:&quot;Catalogo&quot;,&quot;status&quot;:&quot;Alive&quot;,&quot;version&quot;:&quot;bab4653&quot;} </code></pre> <p>But if I try access the service using Ingress, it returns a 404. <code>curl -v http://localhost/assinaturas/hc/alive</code></p> <pre class="lang-sh prettyprint-override"><code>* Trying 127.0.0.1:80... * TCP_NODELAY set * Connected to localhost (127.0.0.1) port 80 (#0) &gt; GET /assinaturas/hc/alive HTTP/1.1 &gt; Host: localhost &gt; User-Agent: curl/7.68.0 &gt; Accept: */* &gt; * Mark bundle as not supporting multiuse &lt; HTTP/1.1 404 Not Found &lt; Date: Mon, 06 Dec 2021 23:22:51 GMT &lt; Content-Length: 0 &lt; Connection: keep-alive &lt; * Connection #0 to host localhost left intact </code></pre> <p>What I'm doing wrong here? Why I can acess the service, but the ingress do not find it?</p>
<p>this is because the prefix <code>/assinaturas</code> need to be omitted by an Nginx <strong>rewrite</strong>.. And that's explain why you got 404 (not found):</p> <pre><code>apiVersion: networking.k8s.io/v1 kind: Ingress metadata: name: ingress-be-assinaturas namespace: apps-space annotations: kubernetes.io/ingress.class: &quot;nginx&quot; nginx.ingress.kubernetes.io/rewrite-target: /$1 # &lt;- 🔴 rewrite here spec: rules: - http: paths: - path: /assinaturas/(.*) # &lt;-- 🔴 Match the path to be rewritten pathType: Prefix backend: service: name: svc-assinaturas port: number: 80 </code></pre>
<p>I have installed ingress controller via helm as a daemonset. I have configured the ingress as follows:</p> <pre><code>apiVersion: networking.k8s.io/v1 kind: Ingress metadata: name: webapp-ingress namespace: rcc annotations: haproxy.org/check: 'true' haproxy.org/check-http: /serviceCheck haproxy.org/check-interval: 5s haproxy.org/cookie-persistence: SERVERID haproxy.org/forwarded-for: 'true' haproxy.org/load-balance: leastconn kubernetes.io/ingress.class: haproxy spec: rules: - host: example.com http: paths: - path: / pathType: Prefix backend: service: name: webapp-frontend port: number: 8080 </code></pre> <pre><code>kubectl get ingress -n rcc Warning: extensions/v1beta1 Ingress is deprecated in v1.14+, unavailable in v1.22+; use networking.k8s.io/v1 Ingress NAME CLASS HOSTS ADDRESS PORTS AGE webapp-ingress &lt;none&gt; example.com 10.110.186.170 80 11h </code></pre> <p>The type chosen was loadbalancer. I can ping from any node the ip address of the ingress on port 80 also can curl it just fine. I can also browse any of the ingress pods ip address from the node just fine. But when I browse the node ip o port 80 I get connection refused. Anything that I am missing here?</p>
<p>I installed last <code>haproxy ingress</code> which is <code>0.13.4</code> version using helm.</p> <p>By default it's installed with <code>LoadBalancer</code> service type:</p> <pre><code>$ kubectl get svc -n ingress-haproxy NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE haproxy-ingress LoadBalancer 10.102.166.149 &lt;pending&gt; 80:30312/TCP,443:32524/TCP 3m45s </code></pre> <p>Since I have the same <code>kubeadm</code> cluster, <code>EXTERNAL-IP</code> will be pending. And as you correctly mentioned in question, <code>CLUSTER-IP</code> is accessible on the nodes when cluster is set up using <code>kubeadm</code>.</p> <hr /> <p>There are two options how to access your ingress:</p> <ol> <li>Using <code>NodePort</code>:</li> </ol> <p>From output above there's a <code>NodePort 30312</code> for internally exposed port <code>80</code>. Therefore from outside the cluster it should be accessed by <code>Node_IP:NodePort</code>:</p> <pre><code>curl NODE_IP:30312 -IH &quot;Host: example.com&quot; HTTP/1.1 200 OK </code></pre> <ol start="2"> <li>Set up <a href="https://metallb.universe.tf/installation/" rel="nofollow noreferrer"><code>metallb</code></a>:</li> </ol> <p>Follow <a href="https://metallb.universe.tf/installation/" rel="nofollow noreferrer">installation guide</a> and second step is to configure <code>metallb</code>. I use <a href="https://metallb.universe.tf/configuration/#layer-2-configuration" rel="nofollow noreferrer">layer 2</a>. Be careful to assign not used ip range!</p> <p>After I installed and set up the <code>metallb</code>, my haproxy has <code>EXTERNAL-IP</code> now:</p> <pre><code>$ kubectl get svc -n ingress-haproxy NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE haproxy-ingress LoadBalancer 10.102.166.149 172.16.1.241 80:30312/TCP,443:32524/TCP 10m </code></pre> <p>And now I can access ingress by <code>EXTERNAL-IP</code> on port <code>80</code>:</p> <pre><code>curl 172.16.1.241 -IH &quot;Host: example.com&quot; HTTP/1.1 200 OK </code></pre> <hr /> <p>Useful to read:</p> <ul> <li><a href="https://kubernetes.io/docs/concepts/services-networking/service/#publishing-services-service-types" rel="nofollow noreferrer">Kubernetes service types</a></li> </ul>
<p>When I launch a pod with the following limits/request:</p> <pre><code> resources: limits: cpu: &quot;3500m&quot; memory: &quot;8192Mi&quot; ephemeral-storage: &quot;5Gi&quot; requests: cpu: &quot;500m&quot; memory: &quot;512Mi&quot; ephemeral-storage: &quot;2Gi&quot; </code></pre> <hr /> <p>Autopilot modifies the resources limits and set them equals to the request ones:</p> <blockquote> <p>autopilot.gke.io/resource-adjustment: {&quot;input&quot;:{&quot;containers&quot;:[<strong>{&quot;limits&quot;:{&quot;cpu&quot;:&quot;3500m&quot;,&quot;ephemeral-storage&quot;:&quot;5Gi&quot;,&quot;memory&quot;:&quot;8Gi&quot;}</strong>,&quot;requests&quot;:{&quot;cpu&quot;:&quot;500m&quot;,&quot;ephemeral-storage&quot;:&quot;2Gi&quot;,&quot;memory&quot;:&quot;512Mi&quot;},&quot;name&quot;:&quot;prueba-init-container&quot;}]},&quot;output&quot;:{&quot;containers&quot;:[<strong>{&quot;limits&quot;:{&quot;cpu&quot;:&quot;500m&quot;,&quot;ephemeral-storage&quot;:&quot;2Gi&quot;,&quot;memory&quot;:&quot;512Mi&quot;}</strong>,&quot;requests&quot;:{&quot;cpu&quot;:&quot;500m&quot;,&quot;ephemeral-storage&quot;:&quot;2Gi&quot;,&quot;memory&quot;:&quot;512Mi&quot;},&quot;name&quot;:&quot;prueba-init-container&quot;}]},&quot;modified&quot;:true} seccomp.security.alpha.kubernetes.io/pod: runtime/default</p> </blockquote>
<p><strong>Resource limits need to be equal to requested resources for GKE autopilot</strong></p> <p>That is the default behavior of the GKE <strong>autopilot</strong>. <a href="https://cloud.google.com/kubernetes-engine/docs/concepts/autopilot-overview#allowable_resource_ranges" rel="nofollow noreferrer">Read More</a></p> <p>Perhaps, this restriction is to make it easier for Google to bill you better, with <strong>GKE</strong> Autopilot, you lose the ability to set a resource limit higher than the requested CPU and memory resources.</p> <p>You need to ensure that you give from the start enough resources to your pod, no less, no more.</p> <p>This is not a mistake. If you try to set a higher limit, <a href="https://cloud.google.com/kubernetes-engine/docs/concepts/autopilot-resource-requests#resource-limits" rel="nofollow noreferrer">GKE Autopilot will just override your limit and make it equal to the requested value</a>.</p> <p><strong>Resource limits</strong></p> <blockquote> <p>In an Autopilot cluster, each Pod is treated as a Guaranteed QoS Class Pod, with limits that are equal to requests. Autopilot automatically sets resource limits equal to requests if you do not have resource limits specified. If you do specify resource limits, your limits will be overridden and set to be equal to the requests.</p> </blockquote>
<p>I tried everything to build a ReactJs app with NPM in a Jenkins pipeline running on Kubernetes.</p> <p>When I try to build my project from Windows or even from Windows subsystem for Linux with an Ubuntu installation, everything work fine and NPM is able to install the packages and build de project from the package.json file.</p> <p>I installed the NodeJS Plugin (available <a href="https://plugins.jenkins.io/nodejs/" rel="nofollow noreferrer">here</a>) And I add this section to my Jenkinsfile</p> <pre><code>stages { stage('Build') { steps { nodejs(nodeJSInstallationName: 'nodeJS_14.15.4') { sh &quot;&quot;&quot; cd ./project-folder npm install npm run-script build &quot;&quot;&quot; } } } } </code></pre> <p>I use the following <strong>package.json</strong></p> <pre><code>{ &quot;name&quot;: &quot;app-react&quot;, &quot;version&quot;: &quot;5.0.0&quot;, &quot;homepage&quot;: &quot;.&quot;, &quot;private&quot;: true, &quot;dependencies&quot;: { &quot;react&quot;: &quot;^17.0.1&quot;, ... &quot;react-scripts&quot;: &quot;4.0.0&quot;, ... }, &quot;scripts&quot;: { &quot;start&quot;: &quot;set HTTPS=true&amp;&amp;react-scripts start&quot;, &quot;build&quot;: &quot;set GENERATE_SOURCEMAP=false&amp;&amp;react-scripts build&quot;, &quot;test&quot;: &quot;react-scripts test&quot;, &quot;eject&quot;: &quot;react-scripts eject&quot;, &quot;sitemap&quot;: &quot;babel-node src/sitemap-generator.js&quot; }, &quot;eslintConfig&quot;: { &quot;extends&quot;: &quot;react-app&quot; }, &quot;browserslist&quot;: [ &quot;&gt;0.2%&quot;, &quot;not dead&quot;, &quot;not ie &lt;= 11&quot;, &quot;not op_mini all&quot; ], &quot;devDependencies&quot;: { &quot;babel-cli&quot;: &quot;^6.26.0&quot;, &quot;babel-preset-es2015&quot;: &quot;^6.24.1&quot;, &quot;babel-preset-react&quot;: &quot;^6.24.1&quot; } } </code></pre> <p>The installation seems to be ok, but then it always fails at the build step. With blue ocean I can see the following error message</p> <pre><code>npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! apollo-react@5.0.1 build: `set GENERATE_SOURCEMAP=false&amp;&amp;./node_modules/react-scripts/bin/react-scripts.js build` npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the apollo-react@5.0.1 build script. npm ERR! This is probably not a problem with npm. There is likely additional logging output above. npm ERR! A complete log of this run can be found in: npm ERR! /root/.npm/_logs/2021-12-04T19_05_34_235Z-debug.log script returned exit code 1 </code></pre> <p>The full logs accessible into /root/.npm/_logs show me this :</p> <pre><code>0 info it worked if it ends with ok 1 verbose cli [ '/usr/local/bin/node', '/usr/local/bin/npm', 'run-script', 'build' ] 2 info using npm@6.14.10 3 info using node@v14.15.4 4 verbose run-script [ 'prebuild', 'build', 'postbuild' ] 5 info lifecycle app-react@5.0.0~prebuild: app-react@5.0.0 6 info lifecycle app-react@5.0.0~build: app-react@5.0.0 7 verbose lifecycle app-react@5.0.0~build: unsafe-perm in lifecycle true 8 verbose lifecycle app-react@5.0.0~build: PATH: /usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/home/jenkins/agent/workspace/client/app-react/node_modules/.bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin 9 verbose lifecycle app-react@5.0.0~build: CWD: /home/jenkins/agent/workspace/client/app-react 10 silly lifecycle app-react@5.0.0~build: Args: [ '-c', 'set GENERATE_SOURCEMAP=false&amp;&amp;react-scripts build' ] 11 silly lifecycle app-react@5.0.0~build: Returned: code: 1 signal: null 12 info lifecycle app-react@5.0.0~build: Failed to exec build script 13 verbose stack Error: app-react@5.0.0 build: `set GENERATE_SOURCEMAP=false&amp;&amp;react-scripts build` 13 verbose stack Exit status 1 13 verbose stack at EventEmitter.&lt;anonymous&gt; (/usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/index.js:332:16) 13 verbose stack at EventEmitter.emit (events.js:315:20) 13 verbose stack at ChildProcess.&lt;anonymous&gt; (/usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:55:14) 13 verbose stack at ChildProcess.emit (events.js:315:20) 13 verbose stack at maybeClose (internal/child_process.js:1048:16) 13 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:288:5) 14 verbose pkgid app-react@5.0.0 15 verbose cwd /home/jenkins/agent/workspace/client/app-react 16 verbose Linux 4.15.0-135-generic 17 verbose argv &quot;/usr/local/bin/node&quot; &quot;/usr/local/bin/npm&quot; &quot;run-script&quot; &quot;build&quot; 18 verbose node v14.15.4 19 verbose npm v6.14.10 20 error code ELIFECYCLE 21 error errno 1 22 error app-react@5.0.0 build: `set GENERATE_SOURCEMAP=false&amp;&amp;react-scripts build` 22 error Exit status 1 23 error Failed at the app-react@5.0.0 build script. 23 error This is probably not a problem with npm. There is likely additional logging output above. 24 verbose exit [ 1, true ] </code></pre> <p>Before that I also tried to build my project with other agents, actually in my script before that test with the NodeJs plugin, I used Kubernetes plugin that can run any agent into a temporary pod. So I tried with a Nodejs image, even with an Ubuntu image in which one I installed NodeJs manually. The result is always the same then before.</p> <p>I don't know what is the source of the problem: the access to the installed packages? A resource problem?</p>
<p>I finally found a workaround. The build fail not because of errors but warnings.</p> <p>The workaround is to remove the eslint configuration part</p> <pre><code>&quot;eslintConfig&quot;: { &quot;extends&quot;: &quot;react-app&quot; } </code></pre> <p>When eslint is not active the result of the build is <strong>Compiled successfully</strong>.</p> <p>But when it is active the result is <strong>Compiled with warnings</strong> and all the warnings appear in the logs, and the jenkins job fail.</p>
<p>A word of warning, this is my first posting, and I am new to docker and Kubernetes with enough knowledge to get me into trouble. I am confused about where docker container images are being stored and listing images.</p> <p>To illustrate my confusion I start with the confirmation that &quot;docker images&quot; indicates no image for nginx is present. Next I create a pod running nginx.</p> <p><code>kubectl run nginx --image=nginx</code> is succesful in pulling image &quot;nginx&quot; from github (or that's my assumption):</p> <pre><code> Events: Type Reason Age From Message ---- ------ ---- ---- ------- Normal Scheduled 8s default-scheduler Successfully assigned default/nginx to minikube Normal Pulling 8s kubelet Pulling image &quot;nginx&quot; Normal Pulled 7s kubelet Successfully pulled image &quot;nginx&quot; in 833.30993ms Normal Created 7s kubelet Created container nginx Normal Started 7s kubelet Started container nginx </code></pre> <p>Even though the above output indicates the image is pulled, issuing &quot;docker images&quot; does not include <code>nginx</code> the output.</p> <p>If I understand correctly, when an image is pulled, it is being stored on my local disk. In my case (Linux) in <code>/var/lib/docker</code>.</p> <p>So my first question is, why doesn't <code>docker images</code> list it in the output, or is the better question where does <code>docker images</code> look for images?</p> <p>Next if I issue a <code>docker pull</code> for <code>nginx</code> it is pulled from what I assume to be Github. <code>docker images</code> now includes it in it's output.</p> <p>Just for my clarification, nothing up to this point involves a private local registry, correct?</p> <p>I purposefully create a basic local Docker Registry using the docker registry container thinking it would be clearer since that will allow me to explicitly specify a registry but this only results in another issue:</p> <pre class="lang-shell prettyprint-override"><code>docker run -d \ -p 5000:5000 \ --restart=always \ --name registry \ -v /registry:/var/lib/registry \ registry </code></pre> <p>I tag and push the <code>nginx</code> image to my newly created local registry:</p> <pre class="lang-shell prettyprint-override"><code>docker tag nginx localhost:5000/nginx:latest docker push localhost:5000/nginx:latest The push refers to repository [localhost:5000/nginx] 2bed47a66c07: Pushed 82caad489ad7: Pushed d3e1dca44e82: Pushed c9fcd9c6ced8: Pushed 0664b7821b60: Pushed 9321ff862abb: Pushed latest: digest: sha256:4424e31f2c366108433ecca7890ad527b243361577180dfd9a5bb36e828abf47 size: 1570 </code></pre> <p>I now delete the original <code>nginx</code> image:</p> <pre><code>docker rmi nginx Untagged: nginx:latest Untagged: nginx@sha256:9522864dd661dcadfd9958f9e0de192a1fdda2c162a35668ab6ac42b465f0603 </code></pre> <p>... and the newely tagged one:</p> <pre><code>docker rmi localhost:5000/nginx Untagged: localhost:5000/nginx:latest Untagged: localhost:5000/nginx@sha256:4424e31f2c366108433ecca7890ad527b243361577180dfd9a5bb36e828abf47 Deleted: sha256:f652ca386ed135a4cbe356333e08ef0816f81b2ac8d0619af01e2b256837ed3e </code></pre> <p>... but from where are they being deleted? Now the image <code>nginx</code> should only be present in localhost:5000/? But <code>docker images</code> doesn't show it in it's output.</p> <p>Moving on, I try to create the nginx pod once more using the image pushed to <code>localhost:5000/nginx:latest</code>.</p> <pre><code>kubectl run nginx --image=localhost:5000/nginx:latest --image-pull-policy=IfNotPresent </code></pre> <p>This is the new issue. The connection to localhost:5000 is refused.</p> <pre><code> Events: Type Reason Age From Message ---- ------ ---- ---- ------- Normal Pulling 1s kubelet Pulling image &quot;localhost:5000/nginx:latest&quot; Warning Failed 1s kubelet Failed to pull image &quot;localhost:5000/nginx:latest&quot;: rpc error: code = Unknown desc = Error response from daemon: Get &quot;http://localhost:5000/v2/&quot;: dial tcp 127.0.0.1:5000: connect: connection refused Warning Failed 1s kubelet Error: ErrImagePull Normal BackOff 0s kubelet Back-off pulling image &quot;localhost:5000/nginx:latest&quot; </code></pre> <p>Why is it I can pull and push to localhost:5000, but pod creation fails with what appears to be an authorization issue? I try logging into the registry but no matter what I use for the username and user password, login is successful. This confuses me more. I would try creating/specifying <code>imagePullSecret</code>, but based on docker login outcome, it doesn't make sense.</p> <p>Clearly I not getting it. Someone please have pity on me and show where I have lost my way.</p>
<p>I will try to bring some clarity to you despite the fact your question already contains about 1000 questions (and you'll probably have 1000 more after my answer :D)</p> <p>Before you can begin to understand any of this, you need to learn a few basic things:</p> <ol> <li><p>Docker produces images which are used by containers - it similar to Virtual Machine, but more lightweight (I'm oversimplifying, but the TL;DR is pretty much that).</p> </li> <li><p>Kubernetes is an orchestration tool - it is responsible for starting containers (by using already built images) and tracking their state (i.e. if this container has crashed it should be restarted, or if it's not started it should be started, etc)</p> </li> </ol> <p>Docker can run on any machine. To be able to start a <code>container</code> you need to build an image first. The image is essentially a lightweight mini OS (i.e. alpine, ubuntu, windows, etc) which is configured with only those dependencies you need to run your application. This image is then pushed to a public repository/registry (hub.docker.com) or to a private one. And afterwards it's used for starting containers.</p> <p>Kubernetes builds on top of this and adds the &quot;automation&quot; layer which is responsible for scheduling and monitoring the containers. For example, you have a group of 10 servers all running <code>nginx</code>. One of those servers restarts - the <code>nginx</code> container will be automatically started by k8s.</p> <p>A kubernetes cluster is the group of physical machines that are dedicated to the mentioned logical cluster. These machines have <code>labels</code> or <code>tags</code> which define the purpose of physical node and work as a constraint for where a container will be scheduled.</p> <p>Now that I have explained the minimum basics in an oversimplified way I can move with answering your questions.</p> <ol> <li><p>When you do <code>docker run nginx</code> - you are instructing docker to pull the <code>nginx</code> image from <a href="https://hub.docker.com/_/nginx" rel="nofollow noreferrer">https://hub.docker.com/_/nginx</a> and then start it on the machine you executed the command on (usually your local machine).</p> </li> <li><p>When you do <code>kubectl run nginx --image=nginx</code> - you are instructing Kubernetes to do something similar to <code>1.</code> but in a cluster. The container will be deployed to a <code>random</code> machine somewhere in the cluster unless you put a <a href="https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/#nodeselector" rel="nofollow noreferrer">nodeSelector</a> or configure <a href="https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/" rel="nofollow noreferrer">affinity</a>. If you put a <code>nodeSelector</code> this container (called Pod in K8S) will be placed on that specific <code>node</code>.</p> </li> <li><p>You have started a <code>private registry</code> server on your local machine. It is crucial to know that <code>localhost</code> inside a <code>container</code> will point to the <code>container</code> itself.</p> </li> <li><p>It is worth mentioning that some of the <code>kubernetes</code> commands will create their own <code>container</code> for the execution phase of the command. (remember this!)</p> </li> <li><p>When you run <code>kubectl run nginx --image=nginx</code> everything works fine, because it is downloading the image from <code>https://hub.docker.com/_/nginx</code>.</p> </li> <li><p>When you run <code>kubectl run nginx --image=localhost:5000/nginx</code> you are telling kubernetes to instruct docker to look for the image at <code>localhost</code> which is ambiguous because you have multiple layers of <code>containers</code> running (check 4.). This means the command that will do <code>docker pull localhost:5000/nginx</code> also runs in a docker container -- so there is no service running at port <code>:5000</code> (the registry is running in a completely different isolated container!) :D</p> </li> <li><p>And this is why you are getting <code>Error: ErrImagePull</code> - it can't resolve <code>localhost</code> as it points to itslef.</p> </li> <li><p>As for the <code>docker rmi nginx</code> and <code>docker rmi localhost:5000/nginx</code> commands - by running them you removed your <code>local copy</code> of the <code>nginx</code> images.</p> </li> <li><p>If you run <code>docker run localhost:5000/nginx</code> on the machine where you started <code>docker run registry</code> you should get a running nginx container.</p> </li> </ol> <p>You should definitely read the <a href="https://docs.docker.com/get-docker/" rel="nofollow noreferrer">Docker Guide</a> <strong>BEFORE</strong> you try to dig into Kubernetes or nothing will ever make sense.</p> <p>Your head will stop hurting after that I promise... :D</p>
<p>Conditions: I have a <em>3 tier application</em> to deploy using Kubernetes. I have created <strong>two namespaces</strong> for <em>backend</em> and <em>frontend</em> respectively.</p> <p>Problem: I want to know how would my <strong>backend</strong> talk to the <strong>frontend</strong> or vice versa.</p> <p>In simple words, how do backend and frontend communicate if they are in different namespaces?</p>
<p>applications can communicate with other services outside their namespace , just use the correct <a href="https://kubernetes.io/docs/concepts/services-networking/dns-pod-service/" rel="nofollow noreferrer">dns name</a></p> <pre><code>&lt;Service Aame&gt;.&lt;Namespace Name&gt;.svc.cluster.local </code></pre>
<p>Conditions: I have a <em>3 tier application</em> to deploy using Kubernetes. I have created <strong>two namespaces</strong> for <em>backend</em> and <em>frontend</em> respectively.</p> <p>Problem: I want to know how would my <strong>backend</strong> talk to the <strong>frontend</strong> or vice versa.</p> <p>In simple words, how do backend and frontend communicate if they are in different namespaces?</p>
<p>There's two ways: internal-only and external.</p> <p>For both, create a kubernetes service for the front and back end services.</p> <p>For external, the service type must <code>LoadBalancer</code>. You install the <a href="https://github.com/kubernetes-sigs/external-dns" rel="nofollow noreferrer">External DNS</a> plugin which will let you create an external DNS name that you can access by the other service. This will also allow you to access the service outside the cluster if you wish.</p> <p>For internal, you make the service type <code>ClusterIP</code> or <code>NodePort</code>. When you create the service, you can then access them using the format: <code>service-name.namespace.svc.cluster.local</code></p> <p>For example, an <code>nginx</code> service running on the namespace <code>internal</code> would be accessed as the DNS name <code>nginx.internal.svc.cluster.local</code></p> <p>This service cannot be accessed outside of the cluster.</p> <p>You can sometimes drop the <code>cluster.local</code> part, but I include it as habit.</p>
<p>I have asp.net core web api app where I have implemented health checks when we deployed the app to Azure Kubernetes Services and the startup probe gets failed.</p> <blockquote> <p>startupProbe: httpGet: path: /health/startup port: 32243 failureThreshold: 25 periodSeconds: 10</p> </blockquote> <p>I can see that internally it's hit the endpoint with <strong>IP address</strong> overs http.</p> <p>Startup probe failed: Get &quot;http://10.22.148.185:32243/health/startup&quot;: dial tcp 10.22.148.185:32243: connect: connection refused</p> <p>When I <strong>removed</strong> startup probe from YAML definition, then the startup endpoint is working as expected, here I am checking with <strong>FQDN over IP</strong> address</p> <p><a href="https://my-dns.com:32243/health/startup" rel="nofollow noreferrer">https://my-dns.com:32243/health/startup</a></p> <p>What I am missing here? Thanks.</p>
<p>You can use <code>https</code> instead of <code>http</code> for the <code>httpGet.scheme</code> value of the <code>startupProbe</code>.</p>
<p>I try to run Prefect flow in IBM Cloud Kubernetes cluster. So I am setting up the Kubernetes Agent. I see errors when I do:</p> <pre><code>kubectl apply -f prefect_agent.yaml kubectl logs prefect-agent-778f997b7-hnsk2 [2021-12-07 12:34:14,399] INFO - agent | Registering agent... Traceback (most recent call last): File &quot;/usr/local/bin/prefect&quot;, line 8, in &lt;module&gt; sys.exit(cli()) File &quot;/usr/local/lib/python3.6/site-packages/click/core.py&quot;, line 829, in __call__ return self.main(*args, **kwargs) File &quot;/usr/local/lib/python3.6/site-packages/click/core.py&quot;, line 782, in main rv = self.invoke(ctx) File &quot;/usr/local/lib/python3.6/site-packages/click/core.py&quot;, line 1259, in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) File &quot;/usr/local/lib/python3.6/site-packages/click/core.py&quot;, line 1259, in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) File &quot;/usr/local/lib/python3.6/site-packages/click/core.py&quot;, line 1259, in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) File &quot;/usr/local/lib/python3.6/site-packages/click/core.py&quot;, line 1066, in invoke return ctx.invoke(self.callback, **ctx.params) File &quot;/usr/local/lib/python3.6/site-packages/click/core.py&quot;, line 610, in invoke return callback(*args, **kwargs) File &quot;/usr/local/lib/python3.6/site-packages/prefect/cli/agent.py&quot;, line 331, in start start_agent(KubernetesAgent, image_pull_secrets=image_pull_secrets, **kwargs) File &quot;/usr/local/lib/python3.6/site-packages/prefect/cli/agent.py&quot;, line 140, in start_agent agent.start() File &quot;/usr/local/lib/python3.6/site-packages/prefect/agent/agent.py&quot;, line 189, in start self._setup_api_connection() File &quot;/usr/local/lib/python3.6/site-packages/prefect/agent/agent.py&quot;, line 910, in _setup_api_connection self.client.attach_headers({&quot;X-PREFECT-AGENT-ID&quot;: self._register_agent()}) File &quot;/usr/local/lib/python3.6/site-packages/prefect/agent/agent.py&quot;, line 858, in _register_agent agent_config_id=self.agent_config_id, File &quot;/usr/local/lib/python3.6/site-packages/prefect/client/client.py&quot;, line 2101, in register_agent tenant_id=self.tenant_id, File &quot;/usr/local/lib/python3.6/site-packages/prefect/client/client.py&quot;, line 329, in tenant_id self._tenant_id = self._get_auth_tenant() File &quot;/usr/local/lib/python3.6/site-packages/prefect/client/client.py&quot;, line 214, in _get_auth_tenant response = self.graphql({&quot;query&quot;: {&quot;auth_info&quot;: &quot;tenant_id&quot;}}) File &quot;/usr/local/lib/python3.6/site-packages/prefect/client/client.py&quot;, line 561, in graphql raise AuthorizationError(result[&quot;errors&quot;]) prefect.exceptions.AuthorizationError: [{'path': ['auth_info'], 'message': 'AuthenticationError: Forbidden', 'extensions': {'code': 'UNAUTHENTICATED'}}] </code></pre> <p>Attach the prefect_agent.yaml</p> <pre><code>--- apiVersion: apps/v1 kind: Deployment metadata: labels: app: prefect-agent name: prefect-agent spec: replicas: 1 selector: matchLabels: app: prefect-agent template: metadata: labels: app: prefect-agent spec: containers: - args: - prefect agent kubernetes start command: - /bin/bash - -c env: - name: PREFECT__CLOUD__AGENT__AUTH_TOKEN value: '' - name: PREFECT__CLOUD__API value: https://api.prefect.io - name: NAMESPACE value: prefect - name: IMAGE_PULL_SECRETS value: '' - name: PREFECT__CLOUD__AGENT__LABELS value: '[&quot;k8s&quot;]' - name: JOB_MEM_REQUEST value: '' - name: JOB_MEM_LIMIT value: '' - name: JOB_CPU_REQUEST value: '' - name: JOB_CPU_LIMIT value: '' - name: IMAGE_PULL_POLICY value: '' - name: SERVICE_ACCOUNT_NAME value: '' - name: PREFECT__BACKEND value: cloud - name: PREFECT__CLOUD__AGENT__AGENT_ADDRESS value: http://:8080 - name: PREFECT__CLOUD__API_KEY value: {myapikey} - name: PREFECT__CLOUD__TENANT_ID value: '' image: prefecthq/prefect:0.15.6-python3.6 imagePullPolicy: Always livenessProbe: failureThreshold: 2 httpGet: path: /api/health port: 8080 initialDelaySeconds: 40 periodSeconds: 40 name: agent --- apiVersion: rbac.authorization.k8s.io/v1 kind: Role metadata: name: prefect-agent-rbac namespace: prefect rules: - apiGroups: - batch - extensions resources: - jobs verbs: - '*' - apiGroups: - '' resources: - events - pods verbs: - '*' --- apiVersion: rbac.authorization.k8s.io/v1beta1 kind: RoleBinding metadata: name: prefect-agent-rbac namespace: prefect roleRef: apiGroup: rbac.authorization.k8s.io kind: Role name: prefect-agent-rbac subjects: - kind: ServiceAccount name: default </code></pre> <p>I can see the roles and rolebindings are created:</p> <pre><code>(venv) xxxtorage % kubectl get roles NAME CREATED AT prefect-agent-rbac 2021-12-07T12:34:57Z (venv) xxxtorage % kubectl get rolebindings NAME ROLE AGE prefect-agent-rbac Role/prefect-agent-rbac 22m </code></pre> <p>Before running commands, I have sent the default namespace to &quot;prefect&quot;. I created the &quot;prefect&quot; namespace to organize all the Prefect related resources.</p>
<p>I found that the <code>- name: PREFECT__CLOUD__API_KEY value: {myapikey}</code> this is generated by: <a href="https://docs.prefect.io/orchestration/concepts/api.html#authentication" rel="nofollow noreferrer">https://docs.prefect.io/orchestration/concepts/api.html#authentication</a></p> <p>I used the Kubernetes cluster API key. Thus the error.</p>
<p>I am fairly new to <code>Kubernetes</code> and have just deployed my first cluster to <code>IBM Cloud</code>. When I created the cluster, I get a dedicated ingress subdomain, which I will be referring to as <code>&lt;long-k8subdomain&gt;.cloud</code> for the scope of this post. Now, this subdomain works for my app. For example: <code>&lt;long-k8subdomain&gt;.cloud/ping</code> works from my browser/curl just fine- I get the expected JSON response back. But, if I add this subdomain to a CNAME record on my domain provider's DNS settings (I have used <code>Bluehost</code> and <code>IBM Cloud's Internet Services</code>), I get a <code>404</code> response back from all routes. However this response is the default <code>nginx</code> 404 response (it says &quot;nginx&quot; under &quot;404 Not Found&quot;). I believe this means that this means the ingress load balancer is being reached, but the request does not get routed right. I am using <code>Kubernetes version 1.20.12_1561 on VPC gen 2</code> and this is my ingress-config.yaml file:</p> <pre><code>apiVersion: networking.k8s.io/v1 kind: Ingress metadata: name: my-ingress-resource annotations: kubernetes.io/ingress.class: &quot;public-iks-k8s-nginx&quot; nginx.ingress.kubernetes.io/configuration-snippet: | more_set_headers &quot;Host: &lt;long-k8subdomain&gt;.cloud&quot;; spec: rules: - host: &lt;long-k8subdomain&gt;.cloud http: paths: - path: / pathType: Prefix backend: service: name: my-service-name port: number: 80 </code></pre> <p>I am pretty sure this problem is due to the annotations. Maybe I am using the wrong ones or I do not have enough. Ideally, I would like something like this: api..com/ to route correctly. I have also read a little bit about default backends, but I have not dove too much into that just yet. Any help would be greatly appreciated, as I have spent multiple hours trying to fix this.</p> <p>Some sources I have used:</p> <ul> <li><a href="https://cloud.ibm.com/docs/containers?topic=containers-cs_network_planning" rel="nofollow noreferrer">https://cloud.ibm.com/docs/containers?topic=containers-cs_network_planning</a></li> <li><a href="https://cloud.ibm.com/docs/containers?topic=containers-ingress-types" rel="nofollow noreferrer">https://cloud.ibm.com/docs/containers?topic=containers-ingress-types</a></li> <li><a href="https://cloud.ibm.com/docs/containers?topic=containers-comm-ingress-annotations#annotations" rel="nofollow noreferrer">https://cloud.ibm.com/docs/containers?topic=containers-comm-ingress-annotations#annotations</a></li> </ul> <p><strong>Note</strong>: The reason why I have the second annotation is because for some reason, requests without that header were not being routed directly. So that was part of my debugging process and I just ended up leaving it as I am not sure if that annotation solves that, so I left it for now.</p>
<p>For the NGINX ingress controller to route requests for your own domain's CNAME record to the service instead of the IBM Cloud one, you need a rule in the ingress where the <code>host</code> identifies your domain.</p> <p>For instance, if your domain's DNS entry is <code>api.example.com</code>, then change the resource YAML to:</p> <pre class="lang-yaml prettyprint-override"><code>apiVersion: networking.k8s.io/v1 kind: Ingress metadata: name: my-ingress-resource annotations: kubernetes.io/ingress.class: &quot;public-iks-k8s-nginx&quot; spec: rules: - host: api.example.com http: paths: - path: / pathType: Prefix backend: service: name: my-service-name port: number: 80 </code></pre> <p>You should not need the second annotation for this to work.</p> <p>If you want both of the hosts to work, then you could add a second rule instead of replacing host in the existing one.</p>
<p>I want to change ndots default value from 5 to 3 in all pods in Kubernetes. for example, this is the current resolv.conf output from one of my pods. How can I change the value of ndots from 5 to 3 in all current and future pods:</p> <pre><code>[root@master01 ~]# kubectl exec test-7c9b9bc678-kfcsj -- cat /etc/resolv.conf nameserver 10.96.0.10 search default.svc.cluster.local svc.cluster.local cluster.local options ndots:5 </code></pre> <p>Kubernetes version: 1.18. Install on bare metal servers. Thank you in advanced</p>
<p>You can adjust this configuration in the pod's <code>dnsConfig</code> section. See more details <a href="https://kubernetes.io/docs/concepts/services-networking/dns-pod-service/#pod-dns-config" rel="nofollow noreferrer">here</a>.</p> <p>We are doing the same in the helm chart responsible for deploying applications into our cluster, like so -</p> <pre><code>dnsConfig: options: - name: ndots value: &quot;3&quot; </code></pre>
<p>I have some Helm value files.</p> <p>There are <code>value.yaml</code>, <code>value.dev.yaml</code>, <code>value.test.yaml</code>, ... file.</p> <p>In <code>value.dev.yaml</code>:</p> <pre><code>env: &quot;Environment&quot; &quot;development&quot; </code></pre> <p>For some parameters in <code>value.yaml</code> file, I expected they override or insert them into pod parameters while deployment.</p> <p>If I set up them into each <code>value.dev.yaml</code>, <code>value.test.yaml</code>,... it works with <code>helm upgrade --install --set env.parameter=$variable</code></p> <p>Now I want to define all variables in <code>value.yaml</code> file and expect them insert (override) them in to pods while deployment.</p> <p>In <code>value.yaml</code> file :</p> <pre><code>env: &quot;Appconfig&quot;: &quot;dev&quot; </code></pre> <p>I'd like to combine them while deployment:</p> <pre><code>env: &quot;Environment&quot;: &quot;development&quot; &quot;Appconfig&quot;: &quot;dev&quot; </code></pre> <p>Apreciate your help !</p>
<p>You can specify the <code>--values</code>/<code>-f</code> flag multiple times. The priority will be given to the <strong>last</strong> (right-most) file specified. For example, if both <code>myvalues.yaml</code> and <code>override.yaml</code> contained a key called 'Test', the value set in <code>override.yaml</code> would take precedence:</p> <pre><code>$ helm install -f myvalues.yaml -f override.yaml myredis ./redis </code></pre> <ul> <li>Ref <a href="https://helm.sh/docs/helm/helm_install/" rel="nofollow noreferrer">Helm Install Doc</a></li> </ul>
<p>I've an application running on k8s and would like to updated the java heapsize . I've updated the JAVA_OPTS environnement variable and set it in the deployment file as below</p> <pre><code>- name: JAVA_OPTS value: &quot;-Xmx768m -XX:MaxMetaspaceSize=256m&quot; </code></pre> <p>but when i run the below command it looks like my changes does not takes effect</p> <pre><code> java -XX:+PrintFlagsFinal -version | grep -iE 'HeapSize|PermSize|ThreadStackSize' intx CompilerThreadStackSize = 0 {pd product} uintx ErgoHeapSizeLimit = 0 {product} uintx HeapSizePerGCThread = 87241520 {product} uintx InitialHeapSize := 33554432 {product} uintx LargePageHeapSizeThreshold = 134217728 {product} uintx MaxHeapSize := 536870912 {product} intx ThreadStackSize = 1024 {pd product} intx VMThreadStackSize = 1024 {pd product} openjdk version &quot;1.8.0_212&quot; OpenJDK Runtime Environment (IcedTea 3.12.0) (Alpine 8.212.04-r0) OpenJDK 64-Bit Server VM (build 25.212-b04, mixed mode) </code></pre> <p>I'm i wrong can someone help me and explain how to set hose values ?</p>
<p>I see that you used OpenJDK Alpine to deploy a JAVA application, so you need to use this environment &quot;<strong>JAVA_TOOL_OPTIONS</strong>&quot; instead of &quot;<strong>JAVA_OPTS</strong>&quot;, something like:</p> <pre><code>spec: containers: - name: jvm_options image: xxx:xxx env: - name: JAVA_TOOL_OPTIONS value: &quot;-Xmx768m -XX:MaxMetaspaceSize=256m&quot; </code></pre> <p>Once your application is running, you can check the application log and you will find the log below:</p> <pre><code>Picked up JAVA_TOOL_OPTIONS: -Xmx768m -XX:MaxMetaspaceSize=256m </code></pre>
<p>I have a web scraping app that is deployed on a kubernetes cluster on GCP and this app uses a proxy to connect to multiple browsers. So I need to assign a static ip address so that the proxy can do its job, but the problem here is that I can't figure out which address to give to the proxy server. I tried to give the ingress and egress static address but it always shows &quot;Connection refused with the proxy&quot; error.</p> <p>PS: The proxy works like magic on my local machine as I'm using a dns server to fix the dynamic IP addresses situation.</p> <p>How should I do the same when the environment is actually on GKE.</p>
<p>As your traffic comes into the cluster from single point you should be diverting the traffic from single point also which is Egress point.</p> <p>I am not sure what you mean when you say egress but it will be Node IP mostly if you are running GKE default.</p> <p>Kubernetes uses the Node IP as outgoing IP on which POD is scheduled.</p> <p>I would suggest setting up <strong>NAT</strong> <strong>gateway</strong> in front of the <strong>GKE</strong> cluster. So all your traffic goes from a single point and you can Whitelist this IP into your Proxy and it will work.</p> <p>Now if you are not much into GKE and NAT set up just this Terraform which will do all the work for you. Terraform will set up the NAT gateway.</p> <p>Terraform NAT GKE : <a href="https://registry.terraform.io/modules/GoogleCloudPlatform/nat-gateway/google/latest/examples/gke-nat-gateway" rel="nofollow noreferrer">https://registry.terraform.io/modules/GoogleCloudPlatform/nat-gateway/google/latest/examples/gke-nat-gateway</a></p> <p>Github Repo : <a href="https://github.com/GoogleCloudPlatform/terraform-google-nat-gateway/tree/v1.2.3" rel="nofollow noreferrer">https://github.com/GoogleCloudPlatform/terraform-google-nat-gateway/tree/v1.2.3</a></p> <p><a href="https://i.stack.imgur.com/yvwbe.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/yvwbe.png" alt="enter image description here" /></a></p>
<p>I have 1 question regarding migration from Nginx controller to ALB. Does k8s during migration will create a new ingress controller and switch smoothly services to new ingress or will delete an old one and after that will create a new ingress? Why I ask that, because we want to change ingress class and we would like to minimize any downtime. Sorry for newbie question, because I didn't find any answer in doc</p>
<ol> <li>First, when transitioning from one infrastructure to another, it's best to pre-build the new infrastructure ahead of the transition so it will be ready to be changed.</li> <li>In this specific example, you can set up the two IngressClasses to exist in parallel, and create the new ALB ingress with a different domain name.</li> <li>In the transition moment, change the DNS alias record (directly or using annotations) to point at the new ALB ingress and delete the older Nginx ingress.</li> <li>In general, I recommend managing the ALB not as ingress from K8s, but as an AWS resource in Terraform/CloudFormation or similar and using TargetGroupBindings to connect the ALB to the application using its K8s Services. <a href="https://kubernetes-sigs.github.io/aws-load-balancer-controller/v2.3/guide/targetgroupbinding/targetgroupbinding/" rel="nofollow noreferrer">https://kubernetes-sigs.github.io/aws-load-balancer-controller/v2.3/guide/targetgroupbinding/targetgroupbinding/</a></li> </ol>
<p>Conditions: I have a <em>3 tier application</em> to deploy using Kubernetes. I have created <strong>two namespaces</strong> for <em>backend</em> and <em>frontend</em> respectively.</p> <p>Problem: I want to know how would my <strong>backend</strong> talk to the <strong>frontend</strong> or vice versa.</p> <p>In simple words, how do backend and frontend communicate if they are in different namespaces?</p>
<p>You should create <a href="https://kubernetes.io/docs/concepts/services-networking/service/" rel="nofollow noreferrer">services</a> for frontend and backend, and then you can communicate using:</p> <ul> <li>(Recommended) a <strong>DNS names of the services</strong> <code>&lt;service-name&gt;.&lt;namespace-name&gt;.svc.cluster.local</code> which will be always the same</li> <li>(Not recommended) a IP address of the services (but they will be different with each re-creation of the service)</li> </ul> <p>Example and further explanation below.</p> <p>Let's create deployments with 3 replicas - one in <code>default</code> namespace, one in <code>test</code> namespace:</p> <pre><code>kubectl create deployment nginx --image=nginx --replicas=3 kubectl create deployment nginx --image=nginx --replicas=3 -n test </code></pre> <p>For each deployment we will <a href="https://kubernetes.io/docs/reference/generated/kubectl/kubectl-commands#expose" rel="nofollow noreferrer">create service type ClusterIP using <code>kubectl expose</code></a>(It's the same if I had created a service from a yaml file:):</p> <pre><code>kubectl expose deployment nginx --name=my-service --port=80 kubectl expose deployment nginx --name=my-service-test --port=80 -n test </code></pre> <p>Time to get IP addresses of the services:</p> <pre><code>user@shell:~$ kubectl get svc NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE kubernetes ClusterIP 10.96.0.1 &lt;none&gt; 443/TCP 64d my-service ClusterIP 10.107.224.54 &lt;none&gt; 80/TCP 12m </code></pre> <p>And in <code>test</code> namespace:</p> <pre><code>user@shell:~$ kubectl get svc -n test NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE my-service-test ClusterIP 10.110.51.62 &lt;none&gt; 80/TCP 8s </code></pre> <p>I will exec into pod in default namespace and <code>curl</code> IP address of the <code>my-service-test</code> in second namespace:</p> <pre><code>user@shell:~$ kubectl exec -it nginx-6799fc88d8-w5q8s -- sh # curl 10.110.51.62 &lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt; &lt;title&gt;Welcome to nginx!&lt;/title&gt; &lt;style&gt; </code></pre> <p>Okay, it's working... Let's try with hostname:</p> <pre><code># curl my-service-test curl: (6) Could not resolve host: my-service-test </code></pre> <p>Not working as expected. Let's check <code>/etc/resolv.conf</code> file:</p> <pre><code># cat resolv.conf nameserver 10.96.0.10 search test.svc.cluster.local svc.cluster.local cluster.local options ndots:5 </code></pre> <p>It's looking for <a href="https://kubernetes.io/docs/tasks/debug-application-cluster/debug-service/#does-the-service-work-by-dns-name" rel="nofollow noreferrer">hostnames only in namespace where pod is located</a>.</p> <p>So pod in the <code>test</code> namespace will have something like:</p> <pre><code># cat resolv.conf nameserver 10.96.0.10 search test.svc.cluster.local svc.cluster.local cluster.local options ndots:5 </code></pre> <p>Let's try to curl <code>my-service-test.test.svc.cluster.local</code> from pod in default namespace:</p> <pre><code># curl my-service-test.test.svc.cluster.local &lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt; &lt;title&gt;Welcome to nginx!&lt;/title&gt; </code></pre> <p>It's working.</p> <p>If you have problems, make sure you have a proper <a href="https://kubernetes.io/docs/concepts/extend-kubernetes/compute-storage-net/network-plugins/" rel="nofollow noreferrer">CNI plugin</a> installed for your cluster - also check this article - <a href="https://kubernetes.io/docs/concepts/cluster-administration/networking/" rel="nofollow noreferrer">Cluster Networking</a> for more details. If you are using some cloud provided solution (like AWS EKS or GCP GKE) you should have it by default.</p> <p>Also check these:</p> <ul> <li><a href="https://kubernetes.io/docs/tasks/administer-cluster/access-cluster-services/" rel="nofollow noreferrer">Access Services Running on Clusters | Kubernetes</a></li> <li><a href="https://kubernetes.io/docs/concepts/services-networking/service/" rel="nofollow noreferrer">Service | Kubernetes</a></li> <li><a href="https://kubernetes.io/docs/tasks/debug-application-cluster/debug-service/" rel="nofollow noreferrer">Debug Services | Kubernetes</a></li> <li><a href="https://kubernetes.io/docs/concepts/services-networking/dns-pod-service/" rel="nofollow noreferrer">DNS for Services and Pods | Kubernetes</a></li> </ul>
<p>I am trying create deployment using yaml file in <strong>kubernetes</strong> but facing this specific error:</p> <p><strong>Error from server (BadRequest): error when creating &quot;.\deployment_test.yaml&quot;: Deployment in version &quot;v1&quot; cannot be handled as a Deployment: v1.Deployment.Spec: v1.DeploymentSpec.Template: v1.PodTemplateSpec.ObjectMeta: v1.ObjectMeta.Labels: ReadMapCB: expect { or n, but found &quot;, error found in #10 byte of ...|&quot;labels&quot;:&quot;test&quot;},&quot;sp|...</strong></p> <p>My yaml file is as follows:</p> <pre><code>kind: Deployment metadata: labels: environment: test name: agentstubpod-deployment spec: replicas: 3 selector: matchLabels: enviroment: test minReadySeconds: 10 strategy: rollingUpdate: maxSurge: 1 maxUnavailable: 0 type: RollingUpdate template: metadata: labels: test spec: containers: - name: agentstub image: some-repo:latest --- apiVersion: apps/v1 kind: Deployment metadata: labels: environment: test name: proxystubpod-deployment spec: replicas: 3 selector: matchLabels: enviroment: test minReadySeconds: 10 strategy: rollingUpdate: maxSurge: 1 maxUnavailable: 0 type: RollingUpdate template: metadata: labels: test spec: containers: - name: procyservice image: some-repo:latest </code></pre> <p>What is wrong with this syntax? I am having a really hard time making a deployment</p>
<p>There are some misconfigurations.</p> <ol> <li>apiVersion is missing in the first deployment</li> <li>indentation below <code>metadata</code> is incorrect</li> <li>You must include the <code>metadata.name</code> field</li> <li><code>spec.selector.matchLabels</code> and <code>spec.template.metadata.labels</code> should be matched.</li> </ol> <p>Here is the corrected example:</p> <pre class="lang-yaml prettyprint-override"><code>apiVersion: apps/v1 kind: Deployment metadata: labels: environment: test name: agentstubpod-deployment name: dep1 spec: replicas: 3 selector: matchLabels: environment: test minReadySeconds: 10 strategy: rollingUpdate: maxSurge: 1 maxUnavailable: 0 type: RollingUpdate template: metadata: labels: environment: test spec: containers: - name: agentstub image: some-repo:latest --- apiVersion: apps/v1 kind: Deployment metadata: labels: environment: test name: proxystubpod-deployment name: dep2 spec: replicas: 3 selector: matchLabels: environment: test minReadySeconds: 10 strategy: rollingUpdate: maxSurge: 1 maxUnavailable: 0 type: RollingUpdate template: metadata: labels: environment: test spec: containers: - name: procyservice image: some-repo:latest </code></pre>
<p>Conditions: I have a <em>3 tier application</em> to deploy using Kubernetes. I have created <strong>two namespaces</strong> for <em>backend</em> and <em>frontend</em> respectively.</p> <p>Problem: I want to know how would my <strong>backend</strong> talk to the <strong>frontend</strong> or vice versa.</p> <p>In simple words, how do backend and frontend communicate if they are in different namespaces?</p>
<p>Your application will talk to each other using the <strong>Kubernetes service</strong>.</p> <p>So generally traffic flows moves inside K8s cluster is like</p> <pre><code>Incoming traffic to any specifc application &gt; Kubernetes service &gt; Kubernetes deployment &gt; PODs &gt; Containers </code></pre> <p>So now imagine all your application running inside on Virutal environment. Where they can talk to each other using just the service name. Instead of using IP now you can use service to resolve to IP automatically. Same we do with <code>www.google.com</code> IP managed by DNS automatically.</p> <p>For <strong>cross namespace</strong> also you have to give the service name.</p> <pre><code>service-y.namespace-b.svc.cluster.local </code></pre> <p>The <strong>format</strong> will be something like</p> <pre><code>&lt;servicename&gt;.&lt;namespace&gt;.svc.cluster.local </code></pre> <p>where your <code>.svc.cluster.local</code> will be auto appended if don't use also.</p> <p>Kubernetes service : <a href="https://kubernetes.io/docs/concepts/services-networking/service/" rel="nofollow noreferrer">https://kubernetes.io/docs/concepts/services-networking/service/</a></p> <p>Here is example connecting &amp; deploying the application using different services : <a href="https://kubernetes.io/docs/tutorials/stateful-application/mysql-wordpress-persistent-volume/" rel="nofollow noreferrer">https://kubernetes.io/docs/tutorials/stateful-application/mysql-wordpress-persistent-volume/</a></p> <p><strong>Service 1</strong> will connect to <strong>service 2</strong> using just by name.</p> <p>MySQL service name is : <strong>wordpress-mysql</strong></p> <p>WordPress will get connected to <strong>MySQL</strong> using just service passing to environment.</p> <pre><code> - image: wordpress:4.8-apache name: wordpress env: - name: WORDPRESS_DB_HOST value: wordpress-mysql </code></pre> <p>now if it's another <strong>namespace</strong> you just need to append <strong>namespace</strong> name.</p> <pre><code> - image: wordpress:4.8-apache name: wordpress env: - name: WORDPRESS_DB_HOST value: wordpress-mysql.my-new-namespace.svc.cluster.local </code></pre>
<p>The spring boot application is deployed on openshift 4. This application needs to create a file on the nfs-share. The openshift container has configured a volume mount on the type NFS. The container on openshift creates a pod with random userid as</p> <pre><code>sh-4.2$ id uid=1031290500(1031290500) gid=0(root) groups=0(root),1031290500 </code></pre> <p>The mount point is /nfs/abc</p> <pre><code>sh-4.2$ ls -la /nfs/ ls: cannot access /nfs/abc: Permission denied total 0 drwxr-xr-x. 1 root root 29 Nov 25 09:34 . drwxr-xr-x. 1 root root 50 Nov 25 10:09 .. d?????????? ? ? ? ? ? abc </code></pre> <p>on the docker image I created a user &quot;technical&quot; with uid= gid=48760 as shown below.</p> <pre><code>FROM quay.repository MAINTAINER developer LABEL description=&quot;abc image&quot; \ name=&quot;abc&quot; \ version=&quot;1.0&quot; ARG APP_HOME=/opt/app ARG PORT=8080 ENV JAR=app.jar \ SPRING_PROFILES_ACTIVE=default \ JAVA_OPTS=&quot;&quot; RUN mkdir $APP_HOME ADD $JAR $APP_HOME/ WORKDIR $APP_HOME EXPOSE $PORT ENTRYPOINT java $JAVA_OPTS -Dspring.profiles.active=$SPRING_PROFILES_ACTIVE -jar $JAR </code></pre> <p>my deployment config file is as shown below</p> <pre><code> spec: volumes: - name: bad-import-file persistentVolumeClaim: claimName: nfs-test-pvc containers: - resources: limits: cpu: '1' memory: 1Gi requests: cpu: 500m memory: 512Mi terminationMessagePath: /dev/termination-log name: abc env: - name: SPRING_PROFILES_ACTIVE valueFrom: configMapKeyRef: name: abc-configmap key: spring.profiles.active - name: DB_URL valueFrom: configMapKeyRef: name: abc-configmap key: db.url - name: DB_USERNAME valueFrom: configMapKeyRef: name: abc-configmap key: db.username - name: BAD_IMPORT_PATH valueFrom: configMapKeyRef: name: abc-configmap key: bad.import.path - name: DB_PASSWORD valueFrom: secretKeyRef: name: abc-secret key: db.password ports: - containerPort: 8080 protocol: TCP imagePullPolicy: IfNotPresent volumeMounts: - name: bad-import-file mountPath: /nfs/abc dnsPolicy: ClusterFirst securityContext: runAsGroup: 44337 runAsNonRoot: true supplementalGroups: - 44337 </code></pre> <p>the PV request is as follows</p> <pre><code>apiVersion: v1 kind: PersistentVolume metadata: name: abc-tuc-pv spec: capacity: storage: 10Gi accessModes: - ReadWriteMany persistentVolumeReclaimPolicy: Retain storageClassName: classic-nfs mountOptions: - hard - nfsvers=3 nfs: path: /tm03v06_vol3014 server: tm03v06cl02.jit.abc.com readOnly: false </code></pre> <p>Now the openshift user has id</p> <pre><code>sh-4.2$ id uid=1031290500(1031290500) gid=44337(technical) groups=44337(technical),1031290500 </code></pre> <p><strong>RECENT UPDATE</strong></p> <p>Just to be clear with the problem, Below I have two commands from the same pod terminal,</p> <pre><code>sh-4.2$ cd /nfs/ sh-4.2$ ls -la (The first command I tried immediately after pod creation.) total 8 drwxr-xr-x. 1 root root 29 Nov 29 08:20 . drwxr-xr-x. 1 root root 50 Nov 30 08:19 .. drwxrwx---. 14 technical technical 8192 Nov 28 19:06 abc sh-4.2$ ls -la(few seconds later on the same pod terminal) ls: cannot access abc: Permission denied total 0 drwxr-xr-x. 1 root root 29 Nov 29 08:20 . drwxr-xr-x. 1 root root 50 Nov 30 08:19 .. d?????????? ? ? ? ? ? abc </code></pre> <p>So the problem is that I see these question marks(???) on the mount point. The mounting is working correctly but I cannot access this /nfs/abc directory and I see this ????? for some reason</p> <p>UPDATE</p> <pre><code>sh-4.2$ ls -la /nfs/abc/ ls: cannot open directory /nfs/abc/: Stale file handle sh-4.2$ ls -la /nfs/abc/ (after few seconds on the same pod terminal) ls: cannot access /nfs/abc/: Permission denied </code></pre> <p>Could this STALE FILE HANDLE be the reason for this issue?</p>
<h1>TL;DR</h1> <p>You can use the <code>anyuid</code> security context to run the pod to avoid having OpenShift assign an arbitrary UID, and set the permissions on the volume to the known UID of the user.</p> <hr /> <p><a href="https://cookbook.openshift.org/users-and-role-based-access-control/why-do-my-applications-run-as-a-random-user-id.html" rel="nofollow noreferrer">OpenShift will override the user ID the image itself may specify that it should run as</a>:</p> <blockquote> <p>The user ID isn't actually entirely random, but is an assigned user ID which is unique to your project. In fact, your project is assigned a range of user IDs that applications can be run as. The set of user IDs will not overlap with other projects. You can see what range is assigned to a project by running oc describe on the project.</p> </blockquote> <blockquote> <p>The purpose of assigning each project a distinct range of user IDs is so that in a multitenant environment, applications from different projects never run as the same user ID. When using persistent storage, any files created by applications will also have different ownership in the file system.</p> </blockquote> <p>... this is a blessing and a curse, when using shared persistent volume claims for example (e.g. PVC's mounted in <a href="https://kubernetes.io/docs/concepts/storage/persistent-volumes/#access-modes" rel="nofollow noreferrer"><code>ReadWriteMany</code></a> with multiple pods that read / write data - files created by one pod won't be accessible by the other pod because of the incorrect file ownership and permissions).</p> <p>One way to get around this issue is using the <a href="https://docs.openshift.com/container-platform/4.9/authentication/managing-security-context-constraints.html" rel="nofollow noreferrer"><code>anyuid</code></a> security context which &quot;provides all features of the restricted SCC, but allows users to run with any UID and any GID&quot;.</p> <p>When using the <code>anyuid</code> security context, we know the user and group ID's the pod(s) are going to run as, and we can set the permissions on the shared volume in advance. For example, where all pods run with the <code>restricted</code> security context by default:</p> <p><a href="https://i.stack.imgur.com/aVeaI.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/aVeaI.png" alt="restricted security context" /></a></p> <p>When running the pod with the <code>anyuid</code> security context, OpenShift doesn't assign an arbitrary UID from the range of UID's allocated for the namespace:</p> <p><a href="https://i.stack.imgur.com/VVTVN.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/VVTVN.png" alt="anyuid security context" /></a></p> <p>This is just for example, but an image that is built with a non-root user with a fixed UID and GID (e.g. <code>1000:1000</code>) would run in OpenShift as that user, files would be created with the ownership of that user (e.g. <code>1000:1000</code>), permissions can be set on the PVC to the known UID and GID of the user set to run the service. For example, we can create a new PVC:</p> <pre class="lang-shell prettyprint-override"><code>cat &lt;&lt;EOF |kubectl apply -f - apiVersion: v1 kind: PersistentVolumeClaim metadata: name: data namespace: k8s spec: accessModes: - ReadWriteMany resources: requests: storage: 8Gi storageClassName: portworx-shared-sc EOF </code></pre> <p>... then mount it in a pod:</p> <pre class="lang-shell prettyprint-override"><code>kubectl run -i --rm --tty ansible --image=lazybit/ansible:v4.0.0 --restart=Never -n k8s --overrides=' { &quot;apiVersion&quot;: &quot;v1&quot;, &quot;kind&quot;: &quot;Pod&quot;, &quot;spec&quot;: { &quot;serviceAccountName&quot;: &quot;default&quot;, &quot;containers&quot;: [ { &quot;name&quot;: &quot;nginx&quot;, &quot;imagePullPolicy&quot;: &quot;Always&quot;, &quot;image&quot;: &quot;lazybit/ansible:v4.0.0&quot;, &quot;command&quot;: [&quot;ash&quot;], &quot;stdin&quot;: true, &quot;stdinOnce&quot;: true, &quot;tty&quot;: true, &quot;env&quot;: [ { &quot;name&quot;: &quot;POD_NAME&quot;, &quot;valueFrom&quot;: { &quot;fieldRef&quot;: { &quot;apiVersion&quot;: &quot;v1&quot;, &quot;fieldPath&quot;: &quot;metadata.name&quot; } } } ], &quot;volumeMounts&quot;: [ { &quot;mountPath&quot;: &quot;/data&quot;, &quot;name&quot;: &quot;data&quot; } ] } ], &quot;volumes&quot;: [ { &quot;name&quot;: &quot;data&quot;, &quot;persistentVolumeClaim&quot;: { &quot;claimName&quot;: &quot;data&quot; } } ] } }' </code></pre> <p>... and create files in the PVC as the <a href="https://github.com/lazybit-ch/ansible/blob/master/Dockerfile#L30" rel="nofollow noreferrer"><code>USER</code> set in the Dockerfile</a>.</p> <p><a href="https://i.stack.imgur.com/cJCCW.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/cJCCW.png" alt="example file created as anyuid USER" /></a></p>
<p>I have configMap:</p> <pre><code>apiVersion: v1 kind: ConfigMap metadata: name: my-app data: application.yaml: |- config: property1: 1 property2: 2 property3: 2 my-map-property: a: b c: d e: f g: h </code></pre> <p>now I want to update my map property to:</p> <pre><code> my-map-property: 1: 5 2: 6 3: 7 4: 8 </code></pre> <p>what is the easiest tool to apply this patch to my configMap ?</p> <p>I know there is yq or kustomize but when I tried example with kustomize</p> <pre><code>resources: - my-configMap.yaml patchesStrategicMerge: - patch-configMap.yaml </code></pre> <p>and run: <code>kubectl kustomize ./</code> then output contains just patch now whole configMap. Is there some better tool how to deal with this problem ?</p>
<p>You can use yq + kustomize configMap generators. The downside is that Kustomize will mutate the config map name every time there is a change so you will have to &quot;garbage collect&quot; all unused config maps manually.</p> <p>So you would have the following setup:</p> <pre class="lang-yaml prettyprint-override"><code># application.yaml config: property1: 1 property2: 2 property3: 2 my-map-property: a: b c: d e: f g: h </code></pre> <pre class="lang-yaml prettyprint-override"><code># kustomization.yaml configMapGenerator: - name: my-app files: - application.yaml </code></pre> <p>You would then run some yq commands <code>yq e -i '.config.my-map-property.a = 1' application.yaml</code></p> <p>and finally <code>kubectl kustomize ./</code></p> <p>Wherever you want to use the config, just reference it as <code>my-app</code>, kustomize will propagate and append the unique identifier to all references.</p> <p>You can alternatively do something like <code>kubectl create configmap my-app --from-file=application.yaml --dry-run=true -o yaml</code> after running the yq command to mutate the values if you don't want to use Kustomize in your workflow. But I personally prefer using Kustomize.</p>
<p>I have a tool which is now available to be deployed on Kubernetes. A known person made a document on getithub where he asked to run two power shell files. <a href="https://github.com/tonikautto/qse-kubernetes-minikube" rel="nofollow noreferrer">source</a></p> <p>When I run first file <code>0-install-tools.ps1</code>, it installs tools like <code>virtualbox</code>, <code>minikube</code>, <code>helm</code> and <code>kubernetes-cli</code>.</p> <p>When I run second file <code>1-Deploy-Minikube.ps1</code>, it is getting failed on last step where it is executing:</p> <pre><code>helm install -n qliksense qlik/qliksense -f values.yaml </code></pre> <p>The person who has created the getithub doc on the same has run it successful but am not sure why it is failing at my windows10 machine.</p> <p>Following error I am getting:</p> <blockquote> <p>error validating data: unknown object type "nil" in Secret.data.redis-password</p> </blockquote> <p>Can you please help me to know why it is failing at my side or there is some problem with the version these powershell files are installing ?</p> <p>Hardware: 3 core and 8 GB RAM.</p> <p>I am hoping a positive response from your team.</p> <p>Thanks, Rohit</p> <p>I rerun powershell files several times.</p> <p>Expected result is mentioned in the article I discussed in content</p>
<p>I had same problem. In my case solution is create new function in <strong>_helpers.tpl</strong></p> <pre><code>{{/* Nullable secret value */}} {{- define &quot;secretValue&quot; -}} {{- $value := . }} {{- if $value }} {{- printf &quot;%s&quot; $value | b64enc }} {{- else }} {{- printf &quot;%q&quot; &quot;&quot; }} {{- end }} {{- end }} </code></pre> <p>then in <strong>secret.yaml</strong> past follow</p> <pre><code>apiVersion: v1 kind: Secret metadata: name: common-secret type: Opaque data: REDIS_PASSWORD: {{ include &quot;secretValue&quot; .Values.redisPassword }} </code></pre> <p>result is</p> <pre><code>apiVersion: v1 kind: Secret metadata: name: common-secret type: Opaque data: REDIS_PASSWORD: &quot;&quot; </code></pre>
<p>I intend to add additional error message fields to a custom resource status. The fields are marked as</p> <pre><code>ErrMsg string `json:&quot;errmsg,omitempty&quot;` </code></pre> <p>Does adding these fields require a new API version, or is is safe to just change the managing operator to fill these fields with values?</p>
<p>According to <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md#typical-status-properties" rel="nofollow noreferrer">this</a></p> <blockquote> <p>Additional fields may be added in the future.</p> </blockquote> <p>If your controller is only ever writing to status then you don't need to bump the CRD version.</p> <p>It also depends what sort of validation you have on the CRD - like if the <a href="https://kubernetes.io/docs/tasks/extend-kubernetes/custom-resources/custom-resource-definitions/#validation" rel="nofollow noreferrer">structural schema</a> is validating the status.</p> <p><a href="https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api_changes.md#multiple-api-versions" rel="nofollow noreferrer">Here</a> are conventions for multiple API versions (although there isn't much on <code>status</code>)</p>
<p>I tried multiple syntax including one given below , no luck yet</p> <pre><code>kubectl exec -u root -it testpod -- bash Error: unknown shorthand flag: 'u' in -u See 'kubectl exec --help' for usage. </code></pre> <p>it is version 1.22</p>
<ul> <li>There is no option available in <code>kubectl exec</code> to mention the user</li> <li>Because it is decided at either in the container image or in the pod.spec.containers.securityContext.runAsUser field</li> <li>so to achieve what youy want is on a running container then do just <code>kubectl exec -it testpod -- bash </code> and then issue <code>su - root</code> from inside the container</li> </ul>
<p>I'm trying to apply a terraform resource (helm_release) to k8s and the apply command is failed half way through.</p> <p>I checked the pod issue now I need to update some values in the local chart.</p> <p>Now I'm in a dilemma, where I can't apply the helm_release as the names are in use, and I can't destroy the helm_release since it is not created.</p> <p>Seems to me the only option is to manually delete the k8s resources that were created by the helm_release chart?</p> <p>Here is the terraform for helm_release:</p> <pre><code>cat nginx-arm64.tf resource &quot;helm_release&quot; &quot;nginx-ingress&quot; { name = &quot;nginx-ingress&quot; chart = &quot;/data/terraform/k8s/nginx-ingress-controller-arm64.tgz&quot; } </code></pre> <p>BTW: I need to use the local chart as the official chart does not support the ARM64 architecture. Thanks,</p> <p>Edit #1:</p> <p>Here is the list of helm release -&gt; there is no gninx ingress</p> <pre><code>/data/terraform/k8s$ helm list -A NAME NAMESPACE REVISION UPDATED STATUS CHART APP VERSION cert-manager default 1 2021-12-08 20:57:38.979176622 +0000 UTC deployed cert-manager-v1.5.0 v1.5.0 /data/terraform/k8s$ </code></pre> <p>Here is the describe pod output:</p> <pre><code>$ k describe pod/nginx-ingress-nginx-ingress-controller-99cddc76b-62nsr Name: nginx-ingress-nginx-ingress-controller-99cddc76b-62nsr Namespace: default Priority: 0 Node: ocifreevmalways/10.0.0.189 Start Time: Wed, 08 Dec 2021 11:11:59 +0000 Labels: app.kubernetes.io/component=controller app.kubernetes.io/instance=nginx-ingress app.kubernetes.io/managed-by=Helm app.kubernetes.io/name=nginx-ingress-controller helm.sh/chart=nginx-ingress-controller-9.0.9 pod-template-hash=99cddc76b Annotations: &lt;none&gt; Status: Running IP: 10.244.0.22 IPs: IP: 10.244.0.22 Controlled By: ReplicaSet/nginx-ingress-nginx-ingress-controller-99cddc76b Containers: controller: Container ID: docker://0b75f5f68ef35dfb7dc5b90f9d1c249fad692855159f4e969324fc4e2ee61654 Image: docker.io/rancher/nginx-ingress-controller:nginx-1.1.0-rancher1 Image ID: docker-pullable://rancher/nginx-ingress-controller@sha256:177fb5dc79adcd16cb6c15d6c42cef31988b116cb148845893b6b954d7d593bc Ports: 80/TCP, 443/TCP Host Ports: 0/TCP, 0/TCP Args: /nginx-ingress-controller --default-backend-service=default/nginx-ingress-nginx-ingress-controller-default-backend --election-id=ingress-controller-leader --controller-class=k8s.io/ingress-nginx --configmap=default/nginx-ingress-nginx-ingress-controller State: Waiting Reason: CrashLoopBackOff Last State: Terminated Reason: Error Exit Code: 255 Started: Wed, 08 Dec 2021 22:02:15 +0000 Finished: Wed, 08 Dec 2021 22:02:15 +0000 Ready: False Restart Count: 132 Liveness: http-get http://:10254/healthz delay=10s timeout=1s period=10s #success=1 #failure=3 Readiness: http-get http://:10254/healthz delay=10s timeout=1s period=10s #success=1 #failure=3 Environment: POD_NAME: nginx-ingress-nginx-ingress-controller-99cddc76b-62nsr (v1:metadata.name) POD_NAMESPACE: default (v1:metadata.namespace) Mounts: /var/run/secrets/kubernetes.io/serviceaccount from kube-api-access-wzqqn (ro) Conditions: Type Status Initialized True Ready False ContainersReady False PodScheduled True Volumes: kube-api-access-wzqqn: Type: Projected (a volume that contains injected data from multiple sources) TokenExpirationSeconds: 3607 ConfigMapName: kube-root-ca.crt ConfigMapOptional: &lt;nil&gt; DownwardAPI: true QoS Class: BestEffort Node-Selectors: &lt;none&gt; Tolerations: node.kubernetes.io/not-ready:NoExecute op=Exists for 300s node.kubernetes.io/unreachable:NoExecute op=Exists for 300s Events: Type Reason Age From Message ---- ------ ---- ---- ------- Normal Pulled 8m38s (x132 over 10h) kubelet Container image &quot;docker.io/rancher/nginx-ingress-controller:nginx-1.1.0-rancher1&quot; already present on machine Warning BackOff 3m39s (x3201 over 10h) kubelet Back-off restarting failed container </code></pre> <p>The terraform state list shows nothing:</p> <pre><code>/data/terraform/k8s$ t state list /data/terraform/k8s$ </code></pre> <p>Though the terraform.tfstate.backup shows the nginx ingress (I guess that I did run the destroy command in between?):</p> <pre><code>/data/terraform/k8s$ cat terraform.tfstate.backup { &quot;version&quot;: 4, &quot;terraform_version&quot;: &quot;1.0.11&quot;, &quot;serial&quot;: 28, &quot;lineage&quot;: &quot;30e74aa5-9631-f82f-61a2-7bdbd97c2276&quot;, &quot;outputs&quot;: {}, &quot;resources&quot;: [ { &quot;mode&quot;: &quot;managed&quot;, &quot;type&quot;: &quot;helm_release&quot;, &quot;name&quot;: &quot;nginx-ingress&quot;, &quot;provider&quot;: &quot;provider[\&quot;registry.terraform.io/hashicorp/helm\&quot;]&quot;, &quot;instances&quot;: [ { &quot;status&quot;: &quot;tainted&quot;, &quot;schema_version&quot;: 0, &quot;attributes&quot;: { &quot;atomic&quot;: false, &quot;chart&quot;: &quot;/data/terraform/k8s/nginx-ingress-controller-arm64.tgz&quot;, &quot;cleanup_on_fail&quot;: false, &quot;create_namespace&quot;: false, &quot;dependency_update&quot;: false, &quot;description&quot;: null, &quot;devel&quot;: null, &quot;disable_crd_hooks&quot;: false, &quot;disable_openapi_validation&quot;: false, &quot;disable_webhooks&quot;: false, &quot;force_update&quot;: false, &quot;id&quot;: &quot;nginx-ingress&quot;, &quot;keyring&quot;: null, &quot;lint&quot;: false, &quot;manifest&quot;: null, &quot;max_history&quot;: 0, &quot;metadata&quot;: [ { &quot;app_version&quot;: &quot;1.1.0&quot;, &quot;chart&quot;: &quot;nginx-ingress-controller&quot;, &quot;name&quot;: &quot;nginx-ingress&quot;, &quot;namespace&quot;: &quot;default&quot;, &quot;revision&quot;: 1, &quot;values&quot;: &quot;{}&quot;, &quot;version&quot;: &quot;9.0.9&quot; } ], &quot;name&quot;: &quot;nginx-ingress&quot;, &quot;namespace&quot;: &quot;default&quot;, &quot;postrender&quot;: [], &quot;recreate_pods&quot;: false, &quot;render_subchart_notes&quot;: true, &quot;replace&quot;: false, &quot;repository&quot;: null, &quot;repository_ca_file&quot;: null, &quot;repository_cert_file&quot;: null, &quot;repository_key_file&quot;: null, &quot;repository_password&quot;: null, &quot;repository_username&quot;: null, &quot;reset_values&quot;: false, &quot;reuse_values&quot;: false, &quot;set&quot;: [], &quot;set_sensitive&quot;: [], &quot;skip_crds&quot;: false, &quot;status&quot;: &quot;failed&quot;, &quot;timeout&quot;: 300, &quot;values&quot;: null, &quot;verify&quot;: false, &quot;version&quot;: &quot;9.0.9&quot;, &quot;wait&quot;: true, &quot;wait_for_jobs&quot;: false }, &quot;sensitive_attributes&quot;: [], &quot;private&quot;: &quot;bnVsbA==&quot; } ] } ] } </code></pre> <p>When I try to apply in the same directory, it prompts the error again:</p> <pre><code>Plan: 1 to add, 0 to change, 0 to destroy. Do you want to perform these actions? Terraform will perform the actions described above. Only 'yes' will be accepted to approve. Enter a value: yes helm_release.nginx-ingress: Creating... ╷ │ Error: cannot re-use a name that is still in use │ │ with helm_release.nginx-ingress, │ on nginx-arm64.tf line 1, in resource &quot;helm_release&quot; &quot;nginx-ingress&quot;: │ 1: resource &quot;helm_release&quot; &quot;nginx-ingress&quot; { </code></pre> <p>Please share your thoughts. Thanks.</p> <p>Edit2:</p> <p>The DEBUG logs show some more clues:</p> <pre><code>2021-12-09T04:30:14.118Z [INFO] provider.terraform-provider-helm_v2.4.1_x5: 2021/12/09 04:30:14 [DEBUG] [resourceDiff: nginx-ingress] Release validated: timestamp=2021-12-09T04:30:14.118Z 2021-12-09T04:30:14.118Z [INFO] provider.terraform-provider-helm_v2.4.1_x5: 2021/12/09 04:30:14 [DEBUG] [resourceDiff: nginx-ingress] Done: timestamp=2021-12-09T04:30:14.118Z 2021-12-09T04:30:14.119Z [WARN] Provider &quot;registry.terraform.io/hashicorp/helm&quot; produced an invalid plan for helm_release.nginx-ingress, but we are tolerating it because it is using the legacy plugin SDK. The following problems may be the cause of any confusing errors from downstream operations: - .cleanup_on_fail: planned value cty.False for a non-computed attribute - .create_namespace: planned value cty.False for a non-computed attribute - .verify: planned value cty.False for a non-computed attribute - .recreate_pods: planned value cty.False for a non-computed attribute - .render_subchart_notes: planned value cty.True for a non-computed attribute - .replace: planned value cty.False for a non-computed attribute - .reset_values: planned value cty.False for a non-computed attribute - .disable_crd_hooks: planned value cty.False for a non-computed attribute - .lint: planned value cty.False for a non-computed attribute - .namespace: planned value cty.StringVal(&quot;default&quot;) for a non-computed attribute - .skip_crds: planned value cty.False for a non-computed attribute - .disable_webhooks: planned value cty.False for a non-computed attribute - .force_update: planned value cty.False for a non-computed attribute - .timeout: planned value cty.NumberIntVal(300) for a non-computed attribute - .reuse_values: planned value cty.False for a non-computed attribute - .dependency_update: planned value cty.False for a non-computed attribute - .disable_openapi_validation: planned value cty.False for a non-computed attribute - .atomic: planned value cty.False for a non-computed attribute - .wait: planned value cty.True for a non-computed attribute - .max_history: planned value cty.NumberIntVal(0) for a non-computed attribute - .wait_for_jobs: planned value cty.False for a non-computed attribute helm_release.nginx-ingress: Creating... 2021-12-09T04:30:14.119Z [INFO] Starting apply for helm_release.nginx-ingress 2021-12-09T04:30:14.119Z [INFO] Starting apply for helm_release.nginx-ingress 2021-12-09T04:30:14.119Z [DEBUG] helm_release.nginx-ingress: applying the planned Create change 2021-12-09T04:30:14.120Z [INFO] provider.terraform-provider-helm_v2.4.1_x5: 2021/12/09 04:30:14 [DEBUG] setting computed for &quot;metadata&quot; from ComputedKeys: timestamp=2021-12-09T04:30:14.120Z 2021-12-09T04:30:14.120Z [INFO] provider.terraform-provider-helm_v2.4.1_x5: 2021/12/09 04:30:14 [DEBUG] [resourceReleaseCreate: nginx-ingress] Started: timestamp=2021-12-09T04:30:14.120Z 2021-12-09T04:30:14.120Z [INFO] provider.terraform-provider-helm_v2.4.1_x5: 2021/12/09 04:30:14 [DEBUG] [resourceReleaseCreate: nginx-ingress] Getting helm configuration: timestamp=2021-12-09T04:30:14.120Z 2021-12-09T04:30:14.120Z [INFO] provider.terraform-provider-helm_v2.4.1_x5: 2021/12/09 04:30:14 [DEBUG] [INFO] GetHelmConfiguration start: timestamp=2021-12-09T04:30:14.120Z 2021-12-09T04:30:14.120Z [INFO] provider.terraform-provider-helm_v2.4.1_x5: 2021/12/09 04:30:14 [DEBUG] Using kubeconfig: /home/ubuntu/.kube/config: timestamp=2021-12-09T04:30:14.120Z 2021-12-09T04:30:14.120Z [INFO] provider.terraform-provider-helm_v2.4.1_x5: 2021/12/09 04:30:14 [INFO] Successfully initialized kubernetes config: timestamp=2021-12-09T04:30:14.120Z 2021-12-09T04:30:14.121Z [INFO] provider.terraform-provider-helm_v2.4.1_x5: 2021/12/09 04:30:14 [DEBUG] [INFO] GetHelmConfiguration success: timestamp=2021-12-09T04:30:14.121Z 2021-12-09T04:30:14.121Z [INFO] provider.terraform-provider-helm_v2.4.1_x5: 2021/12/09 04:30:14 [DEBUG] [resourceReleaseCreate: nginx-ingress] Getting chart: timestamp=2021-12-09T04:30:14.121Z 2021-12-09T04:30:14.125Z [INFO] provider.terraform-provider-helm_v2.4.1_x5: 2021/12/09 04:30:14 [DEBUG] [resourceReleaseCreate: nginx-ingress] Preparing for installation: timestamp=2021-12-09T04:30:14.125Z 2021-12-09T04:30:14.125Z [INFO] provider.terraform-provider-helm_v2.4.1_x5: 2021/12/09 04:30:14 ---[ values.yaml ]----------------------------------- {}: timestamp=2021-12-09T04:30:14.125Z 2021-12-09T04:30:14.125Z [INFO] provider.terraform-provider-helm_v2.4.1_x5: 2021/12/09 04:30:14 [DEBUG] [resourceReleaseCreate: nginx-ingress] Installing chart: timestamp=2021-12-09T04:30:14.125Z ╷ │ Error: cannot re-use a name that is still in use │ │ with helm_release.nginx-ingress, │ on nginx-arm64.tf line 1, in resource &quot;helm_release&quot; &quot;nginx-ingress&quot;: │ 1: resource &quot;helm_release&quot; &quot;nginx-ingress&quot; { │ ╵ 2021-12-09T04:30:14.158Z [DEBUG] provider.stdio: received EOF, stopping recv loop: err=&quot;rpc error: code = Unavailable desc = transport is closing&quot; 2021-12-09T04:30:14.160Z [DEBUG] provider: plugin process exited: path=.terraform/providers/registry.terraform.io/hashicorp/helm/2.4.1/linux_arm64/terraform-provider-helm_v2.4.1_x5 pid=558800 2021-12-09T04:30:14.160Z [DEBUG] provider: plugin exited </code></pre>
<p>You don't have to manually delete all the resources using <code>kubectl</code>. Under the hood the Terraform Helm provider still uses Helm. So if you run <code>helm list -A</code> you will see all the Helm releases on your cluster, including the <code>nginx-ingress</code> release. Deleting the release is then done via <code>helm uninstall nginx-ingress -n REPLACE_WITH_YOUR_NAMESPACE</code>.</p> <p>Before re-running <code>terraform apply</code> do check if the Helm release is still in your Terraform state via <code>terraform state list</code> (run this from the same directory as where you run <code>terraform apply</code> from). If you don't see <code>helm_release.nginx-ingress</code> in that list then it is not in your Terraform state and you can just rerun your <code>terraform apply</code>. Else you have to delete it via <code>terraform state rm helm_release.nginx-ingress</code> and then you can run <code>terraform apply</code> again.</p>
<p>I'm working on this cloud project where we have several development repositories in GitHub and in each we have the overlays containing config files that are specific for a local K8S cluster, a dev Azure cluster and a prod Azure cluster.</p> <p>In order to have different repos for these envs we use a repo with a kustomization file for each service that fetches the overlay of the dev/test/prod and uses it as it's base.</p> <p>However the issue is managing this resources since we don't want to share the dev repos to possible clients or other end users in order for them to deploy these services into their K8S environment but not giving them permissions will imply that they will not be able to fetch these overlays and bases and deploy them.</p> <p>What is the best practice in order to have a protected and restrictive dev repos and yet be able to do the deployment operation?</p> <p>I know this is a abstract question but I've never dealt with organization of repos in a scale like this.</p>
<p>To clarify I am posting Community Wiki answer.</p> <p>The solution you suggested in comment's section:</p> <blockquote> <p>We will have the deployments/namespaces/services manifests in the same repo as the application source code as well the an overlay with a customization with the necessary resources to fully deploy in the dev environment.</p> <p>As for test/ prod environments we created a structure to add an overlay per app with the same resource files but with the env details in the files to be used as configmaps.</p> <p>And a customization using the dev repository as the base. Unfortunately this will imply that the cluster admin will have access to all repos of an application.</p> </blockquote>
<p>I want to use the <a href="https://argo-cd.readthedocs.io/en/stable/operator-manual/cluster-bootstrapping/" rel="nofollow noreferrer">App-of-apps</a> practice with ArgoCD. So I created a simple folder structure like the one below. Then I created a project called <code>dev</code> and I created an app that will look inside the folder <code>apps</code>, so when new <code>Application</code> manifests are included, it will automatically create new applications. This last part works. Every time I add a new <code>Application</code> manifest, a new app is created as a child of the <code>apps</code>. However, the actual app that will monitor the respective folder and create the service and deployment is not created and I can't figure out what I am doing wrong. I have followed different tutorials that use Helm and Kustomize and all have given the same end result.</p> <p>Can someone spot what am I missing here?</p> <ul> <li>Folder structure</li> </ul> <pre class="lang-sh prettyprint-override"><code>deployments/dev ├── apps │ ├── app1.yaml │ └── app2.yaml ├── app1 │ ├── app1-deployment.yaml │ └── app1-svc.yaml └── app-2 ├── app2-deployment.yaml └── app2-svc.yaml </code></pre> <ul> <li>Parent app <code>Application</code> manifest that is watching <code>/dev/apps</code> folder</li> </ul> <pre class="lang-yaml prettyprint-override"><code>apiVersion: argoproj.io/v1alpha1 kind: Application metadata: name: root-app namespace: argocd spec: destination: server: https://kubernetes.default.svc namespace: argocd project: dev source: path: deployments/dev/apps/ repoURL: https://github.com/&lt;repo&gt;.git targetRevision: HEAD syncPolicy: automated: prune: true selfHeal: true allowEmpty: true </code></pre> <ul> <li>And the App1 and App2 <code>Application</code> manifest is the same for both apps like so:</li> </ul> <pre class="lang-yaml prettyprint-override"><code>apiVersion: argoproj.io/v1alpha1 kind: Application metadata: name: &lt;app1&gt;/&lt;app2&gt; namespace: default spec: destination: server: https://kubernetes.default.svc namespace: default project: dev source: path: deployments/dev/&lt;app1&gt; or deployments/dev/&lt;app2&gt; repoURL: https://github.com/&lt;repo&gt;.git targetRevision: HEAD syncPolicy: automated: prune: true selfHeal: true allowEmpty: true </code></pre>
<h2>Posting comment as the community wiki answer for better visibility</h2> <hr /> <p>It turns out that at the moment ArgoCD can only recognize application declarations made in ArgoCD namespace, but @everspader was doing it in the default namespace. For more info, please refer to <a href="https://github.com/argoproj/argo-cd/issues/3474" rel="nofollow noreferrer">GitHub Issue</a></p>
<p>The command <code>kubectl get pods &lt;POD NAME&gt;</code> will return the specific pod with that name. I wonder if there is a way that I can use part of the name, for instance, a command that returns all pods that start with <code>j</code>.</p>
<p>In Linux Bash:</p> <pre class="lang-sh prettyprint-override"><code>kubectl get pods | grep ^j </code></pre> <p>In Windows PowerShell:</p> <pre class="lang-sh prettyprint-override"><code>kubectl get pods | Select-String '^j' </code></pre>
<p>We can restart kubernetes deployment using kubectl rollout restart. I want to perform same action using kubernetes api server.</p>
<p>You can use this Curl to restart using the API</p> <pre><code>curl --location --request PATCH 'http://&lt;K8s cluster IP&gt;:6443/apis/apps/v1/namespaces/&lt;Namespace name&gt;/deployments/&lt;Deployment name&gt;?fieldManager=kubectl-rollout&amp;pretty=true' \ --header 'Content-Type: application/strategic-merge-patch+json' \ --data-raw '{ &quot;spec&quot;: { &quot;template&quot;: { &quot;metadata&quot;: { &quot;annotations&quot;: { &quot;kubectl.kubernetes.io/restartedAt&quot;: &lt;time.Now()&gt; } } } } }' </code></pre> <p>this will inject the annotation in deployment and restart the deployment.</p>
<p>I have a Service configured to be accessible via HTTP.</p> <pre><code>kind: Service apiVersion: v1 metadata: name: myservice spec: ports: - name: http protocol: TCP port: 80 targetPort: 8080 type: ClusterIP </code></pre> <p>And an Ngynx Ingress configured to make that internal service accessible from a specific secure <code>subdomain.domain</code></p> <pre><code>kind: Ingress apiVersion: extensions/v1beta1 metadata: name: myservice-ingress selfLink: /apis/extensions/v1beta1/namespaces/default/ingresses/myservice-ingress annotations: certmanager.k8s.io/issuer: letsencrypt-prod kubernetes.io/ingress.class: nginx nginx.ingress.kubernetes.io/backend-protocol: HTTP spec: tls: - hosts: - myservice.mydomain.com secretName: myservice-ingress-secret-tls rules: - host: myservice.mydomain.com http: paths: - path: / backend: serviceName: myservice servicePort: 80 status: loadBalancer: ingress: - {} </code></pre> <p>So when I reach <code>https://myservice.mydomain.com</code> I can access to my service through HTTPS. Is it safe enough or should I configure my service and pods to communicate only through <code>HTTPS</code>?</p>
<p>It's expected behaviour since you've set <code>TLS</code> in your Ingress.</p> <blockquote> <p>Note that by default the controller <strong>redirects</strong> (308) to <strong>HTTPS</strong> if TLS <strong>is enabled</strong> for that ingress. If you want to disable this behavior globally, you can use ssl-redirect: &quot;false&quot; in the NGINX <a href="https://kubernetes.github.io/ingress-nginx/user-guide/nginx-configuration/configmap/#ssl-redirect" rel="nofollow noreferrer">ConfigMap</a>.</p> </blockquote> <p>To configure this feature for specific ingress resources, you can use the <code>nginx.ingress.kubernetes.io/ssl-redirect: &quot;false&quot;</code> annotation in the particular resource.</p> <p>About your question: &quot;Is it safe enough..&quot; - it's opinion based question, so I can answer to use better <code>HTTPS</code>, rather than <code>HTTP</code>, but it's just my opinion. You can always find the difference between <code>HTTP</code> and <code>HTTPS</code></p>
<p>Do you know what is the annotation that we can use it on GKE to make a LoadBalancer service internal?. For example Azure (and AWS) supports the following annotation (shown in the YAML code snippet) to make a LoadBalancer service internal. I couldn’t find equivalent of it on GKE. For example naturally one may expect <strong>gcp-load-balancer-internal</strong> as the equivalent annotation on GKE; unfortunately it is not. Here is the Azure and AWS documentation for it, I am looking equivalent of it on GKE.</p> <ul> <li><a href="https://learn.microsoft.com/en-us/azure/aks/internal-lb" rel="nofollow noreferrer">Azure: internal LoadBalancer</a></li> <li><a href="https://kubernetes-sigs.github.io/aws-load-balancer-controller/v2.2/guide/service/annotations/" rel="nofollow noreferrer">AWS: annotations</a></li> </ul> <pre class="lang-yaml prettyprint-override"><code>apiVersion: v1 kind: Service metadata: annotations: service.beta.kubernetes.io/aws-load-balancer-internal: &quot;true&quot; service.beta.kubernetes.io/azure-load-balancer-internal: &quot;true&quot; </code></pre>
<p>The equivalent can be found <a href="https://cloud.google.com/kubernetes-engine/docs/how-to/internal-load-balancing#create" rel="nofollow noreferrer">here</a>.</p> <pre><code>apiVersion: v1 kind: Service metadata: name: ilb-service annotations: networking.gke.io/load-balancer-type: &quot;Internal&quot; labels: app: hello spec: type: LoadBalancer selector: app: hello ports: - port: 80 targetPort: 8080 protocol: TCP </code></pre>
<p>I want to configure port forward <code>80</code>-&gt;<code>32181</code>, <code>443</code>-&gt;<code>30598</code>. <code>32181</code> and <code>30598</code> is <code>NodePort</code> of k8s ingress controller which i can establish connection correctly:</p> <pre><code>$ curl http://localhost:32181 &lt;html&gt; &lt;head&gt;&lt;title&gt;404 Not Found&lt;/title&gt;&lt;/head&gt; &lt;body&gt; ... $ curl https://localhost:30598 -k &lt;html&gt; &lt;head&gt;&lt;title&gt;404 Not Found&lt;/title&gt;&lt;/head&gt; &lt;body&gt; ... </code></pre> <p>What I have done is:</p> <pre><code>$ cat /proc/sys/net/ipv4/ip_forward 1 $ firewall-cmd --list-all public (active) target: default icmp-block-inversion: no interfaces: eth0 sources: services: cockpit dhcpv6-client frp http https kube-apiserver kube-kubelet ssh ports: protocols: forward: no masquerade: yes forward-ports: port=80:proto=tcp:toport=32181:toaddr= port=443:proto=tcp:toport=30598:toaddr= source-ports: icmp-blocks: rich rules: </code></pre> <p>but I cant access my nginx via <code>80</code> or <code>443</code>:</p> <pre><code>$ curl https://localhost:443 -k curl: (7) Failed to connect to localhost port 443: Connection refused </code></pre> <p>and more info:</p> <blockquote> <p>centos: 8.2 4.18.0-348.2.1.el8_5.x86_64</p> </blockquote> <blockquote> <p>k8s: 1.22(with calico(v3.21.0) network plugin)</p> </blockquote> <blockquote> <p>firewalld: 0.9.3</p> </blockquote> <p>and iptables output:</p> <pre><code>$ iptables -nvL -t nat --line-numbers Chain PREROUTING (policy ACCEPT 51 packets, 2688 bytes) num pkts bytes target prot opt in out source destination 1 51 2688 cali-PREROUTING all -- * * 0.0.0.0/0 0.0.0.0/0 /* cali:6gwbT8clXdHdC1b1 */ 2 51 2688 KUBE-SERVICES all -- * * 0.0.0.0/0 0.0.0.0/0 /* kubernetes service portals */ 3 51 2688 DOCKER all -- * * 0.0.0.0/0 0.0.0.0/0 ADDRTYPE match dst-type LOCAL Chain INPUT (policy ACCEPT 50 packets, 2648 bytes) num pkts bytes target prot opt in out source destination Chain POSTROUTING (policy ACCEPT 1872 packets, 112K bytes) num pkts bytes target prot opt in out source destination 1 1894 114K cali-POSTROUTING all -- * * 0.0.0.0/0 0.0.0.0/0 /* cali:O3lYWMrLQYEMJtB5 */ 2 1862 112K KUBE-POSTROUTING all -- * * 0.0.0.0/0 0.0.0.0/0 /* kubernetes postrouting rules */ 3 0 0 MASQUERADE all -- * !docker0 172.17.0.0/16 0.0.0.0/0 Chain OUTPUT (policy ACCEPT 1922 packets, 116K bytes) num pkts bytes target prot opt in out source destination 1 1894 114K cali-OUTPUT all -- * * 0.0.0.0/0 0.0.0.0/0 /* cali:tVnHkvAo15HuiPy0 */ 2 1911 115K KUBE-SERVICES all -- * * 0.0.0.0/0 0.0.0.0/0 /* kubernetes service portals */ 3 758 45480 DOCKER all -- * * 0.0.0.0/0 !127.0.0.0/8 ADDRTYPE match dst-type LOCAL Chain DOCKER (2 references) num pkts bytes target prot opt in out source destination 1 0 0 RETURN all -- docker0 * 0.0.0.0/0 0.0.0.0/0 Chain KUBE-SERVICES (2 references) num pkts bytes target prot opt in out source destination 1 0 0 KUBE-SVC-JD5MR3NA4I4DYORP tcp -- * * 0.0.0.0/0 10.96.0.10 /* kube-system/kube-dns:metrics cluster IP */ tcp dpt:9153 2 0 0 KUBE-SVC-Z6GDYMWE5TV2NNJN tcp -- * * 0.0.0.0/0 10.110.193.197 /* kubernetes-dashboard/dashboard-metrics-scraper cluster IP */ tcp dpt:8000 3 0 0 KUBE-SVC-NPX46M4PTMTKRN6Y tcp -- * * 0.0.0.0/0 10.96.0.1 /* default/kubernetes:https cluster IP */ tcp dpt:443 4 0 0 KUBE-SVC-EDNDUDH2C75GIR6O tcp -- * * 0.0.0.0/0 10.97.201.174 /* ingress-nginx/ingress-nginx-controller:https cluster IP */ tcp dpt:443 5 0 0 KUBE-SVC-EZYNCFY2F7N6OQA2 tcp -- * * 0.0.0.0/0 10.103.242.141 /* ingress-nginx/ingress-nginx-controller-admission:https-webhook cluster IP */ tcp dpt:443 6 0 0 KUBE-SVC-ERIFXISQEP7F7OF4 tcp -- * * 0.0.0.0/0 10.96.0.10 /* kube-system/kube-dns:dns-tcp cluster IP */ tcp dpt:53 7 0 0 KUBE-SVC-TCOU7JCQXEZGVUNU udp -- * * 0.0.0.0/0 10.96.0.10 /* kube-system/kube-dns:dns cluster IP */ udp dpt:53 8 0 0 KUBE-SVC-CEZPIJSAUFW5MYPQ tcp -- * * 0.0.0.0/0 10.97.166.112 /* kubernetes-dashboard/kubernetes-dashboard cluster IP */ tcp dpt:443 9 0 0 KUBE-SVC-H5K62VURUHBF7BRH tcp -- * * 0.0.0.0/0 10.104.154.95 /* lens-metrics/kube-state-metrics:metrics cluster IP */ tcp dpt:8080 10 0 0 KUBE-SVC-MOZMMOD3XZX35IET tcp -- * * 0.0.0.0/0 10.96.73.22 /* lens-metrics/prometheus:web cluster IP */ tcp dpt:80 11 0 0 KUBE-SVC-CG5I4G2RS3ZVWGLK tcp -- * * 0.0.0.0/0 10.97.201.174 /* ingress-nginx/ingress-nginx-controller:http cluster IP */ tcp dpt:80 12 1165 69528 KUBE-NODEPORTS all -- * * 0.0.0.0/0 0.0.0.0/0 /* kubernetes service nodeports; NOTE: this must be the last rule in this chain */ ADDRTYPE match dst-type LOCAL Chain KUBE-POSTROUTING (1 references) num pkts bytes target prot opt in out source destination 1 1859 112K RETURN all -- * * 0.0.0.0/0 0.0.0.0/0 mark match ! 0x4000/0x4000 2 3 180 MARK all -- * * 0.0.0.0/0 0.0.0.0/0 MARK xor 0x4000 3 3 180 MASQUERADE all -- * * 0.0.0.0/0 0.0.0.0/0 /* kubernetes service traffic requiring SNAT */ random-fully Chain KUBE-MARK-DROP (0 references) num pkts bytes target prot opt in out source destination 1 0 0 MARK all -- * * 0.0.0.0/0 0.0.0.0/0 MARK or 0x8000 Chain KUBE-NODEPORTS (1 references) num pkts bytes target prot opt in out source destination 1 2 120 KUBE-SVC-EDNDUDH2C75GIR6O tcp -- * * 0.0.0.0/0 0.0.0.0/0 /* ingress-nginx/ingress-nginx-controller:https */ tcp dpt:30598 2 1 60 KUBE-SVC-CG5I4G2RS3ZVWGLK tcp -- * * 0.0.0.0/0 0.0.0.0/0 /* ingress-nginx/ingress-nginx-controller:http */ tcp dpt:32181 Chain KUBE-MARK-MASQ (27 references) num pkts bytes target prot opt in out source destination 1 3 180 MARK all -- * * 0.0.0.0/0 0.0.0.0/0 MARK or 0x4000 Chain KUBE-SEP-IPE5TMLTCUYK646X (1 references) num pkts bytes target prot opt in out source destination 1 0 0 KUBE-MARK-MASQ all -- * * 192.168.103.147 0.0.0.0/0 /* kube-system/kube-dns:metrics */ 2 0 0 DNAT tcp -- * * 0.0.0.0/0 0.0.0.0/0 /* kube-system/kube-dns:metrics */ tcp to:192.168.103.147:9153 Chain KUBE-SEP-3LZLTHU4JT3FAVZK (1 references) num pkts bytes target prot opt in out source destination 1 0 0 KUBE-MARK-MASQ all -- * * 192.168.103.149 0.0.0.0/0 /* kube-system/kube-dns:metrics */ 2 0 0 DNAT tcp -- * * 0.0.0.0/0 0.0.0.0/0 /* kube-system/kube-dns:metrics */ tcp to:192.168.103.149:9153 Chain KUBE-SVC-JD5MR3NA4I4DYORP (1 references) num pkts bytes target prot opt in out source destination 1 0 0 KUBE-MARK-MASQ tcp -- * * !192.168.0.0/16 10.96.0.10 /* kube-system/kube-dns:metrics cluster IP */ tcp dpt:9153 2 0 0 KUBE-SEP-IPE5TMLTCUYK646X all -- * * 0.0.0.0/0 0.0.0.0/0 /* kube-system/kube-dns:metrics */ statistic mode random probability 0.50000000000 3 0 0 KUBE-SEP-3LZLTHU4JT3FAVZK all -- * * 0.0.0.0/0 0.0.0.0/0 /* kube-system/kube-dns:metrics */ Chain KUBE-SEP-ZOAMCQDU54EOM4EJ (1 references) num pkts bytes target prot opt in out source destination 1 0 0 KUBE-MARK-MASQ all -- * * 192.168.103.141 0.0.0.0/0 /* kubernetes-dashboard/dashboard-metrics-scraper */ 2 0 0 DNAT tcp -- * * 0.0.0.0/0 0.0.0.0/0 /* kubernetes-dashboard/dashboard-metrics-scraper */ tcp to:192.168.103.141:8000 Chain KUBE-SVC-Z6GDYMWE5TV2NNJN (1 references) num pkts bytes target prot opt in out source destination 1 0 0 KUBE-MARK-MASQ tcp -- * * !192.168.0.0/16 10.110.193.197 /* kubernetes-dashboard/dashboard-metrics-scraper cluster IP */ tcp dpt:8000 2 0 0 KUBE-SEP-ZOAMCQDU54EOM4EJ all -- * * 0.0.0.0/0 0.0.0.0/0 /* kubernetes-dashboard/dashboard-metrics-scraper */ Chain KUBE-SEP-HYE2IFAO6PORQFJR (1 references) num pkts bytes target prot opt in out source destination 1 0 0 KUBE-MARK-MASQ all -- * * 192.168.0.176 0.0.0.0/0 /* default/kubernetes:https */ 2 0 0 DNAT tcp -- * * 0.0.0.0/0 0.0.0.0/0 /* default/kubernetes:https */ tcp to:192.168.0.176:6443 Chain KUBE-SVC-NPX46M4PTMTKRN6Y (1 references) num pkts bytes target prot opt in out source destination 1 0 0 KUBE-MARK-MASQ tcp -- * * !192.168.0.0/16 10.96.0.1 /* default/kubernetes:https cluster IP */ tcp dpt:443 2 0 0 KUBE-SEP-HYE2IFAO6PORQFJR all -- * * 0.0.0.0/0 0.0.0.0/0 /* default/kubernetes:https */ Chain KUBE-SEP-GJ4OJHBKIREWLMRS (1 references) num pkts bytes target prot opt in out source destination 1 0 0 KUBE-MARK-MASQ all -- * * 192.168.103.146 0.0.0.0/0 /* ingress-nginx/ingress-nginx-controller:https */ 2 2 120 DNAT tcp -- * * 0.0.0.0/0 0.0.0.0/0 /* ingress-nginx/ingress-nginx-controller:https */ tcp to:192.168.103.146:443 Chain KUBE-SVC-EDNDUDH2C75GIR6O (2 references) num pkts bytes target prot opt in out source destination 1 0 0 KUBE-MARK-MASQ tcp -- * * !192.168.0.0/16 10.97.201.174 /* ingress-nginx/ingress-nginx-controller:https cluster IP */ tcp dpt:443 2 2 120 KUBE-MARK-MASQ tcp -- * * 0.0.0.0/0 0.0.0.0/0 /* ingress-nginx/ingress-nginx-controller:https */ tcp dpt:30598 3 2 120 KUBE-SEP-GJ4OJHBKIREWLMRS all -- * * 0.0.0.0/0 0.0.0.0/0 /* ingress-nginx/ingress-nginx-controller:https */ Chain KUBE-SEP-K2CVHZPTBE2YAD6P (1 references) num pkts bytes target prot opt in out source destination 1 0 0 KUBE-MARK-MASQ all -- * * 192.168.103.146 0.0.0.0/0 /* ingress-nginx/ingress-nginx-controller-admission:https-webhook */ 2 0 0 DNAT tcp -- * * 0.0.0.0/0 0.0.0.0/0 /* ingress-nginx/ingress-nginx-controller-admission:https-webhook */ tcp to:192.168.103.146:8443 Chain KUBE-SVC-EZYNCFY2F7N6OQA2 (1 references) num pkts bytes target prot opt in out source destination 1 0 0 KUBE-MARK-MASQ tcp -- * * !192.168.0.0/16 10.103.242.141 /* ingress-nginx/ingress-nginx-controller-admission:https-webhook cluster IP */ tcp dpt:443 2 0 0 KUBE-SEP-K2CVHZPTBE2YAD6P all -- * * 0.0.0.0/0 0.0.0.0/0 /* ingress-nginx/ingress-nginx-controller-admission:https-webhook */ Chain KUBE-SEP-S6VTWHFP6KEYRW5L (1 references) num pkts bytes target prot opt in out source destination 1 0 0 KUBE-MARK-MASQ all -- * * 192.168.103.147 0.0.0.0/0 /* kube-system/kube-dns:dns-tcp */ 2 0 0 DNAT tcp -- * * 0.0.0.0/0 0.0.0.0/0 /* kube-system/kube-dns:dns-tcp */ tcp to:192.168.103.147:53 Chain KUBE-SEP-SFGZMYIS2CE4JD3K (1 references) num pkts bytes target prot opt in out source destination 1 0 0 KUBE-MARK-MASQ all -- * * 192.168.103.149 0.0.0.0/0 /* kube-system/kube-dns:dns-tcp */ 2 0 0 DNAT tcp -- * * 0.0.0.0/0 0.0.0.0/0 /* kube-system/kube-dns:dns-tcp */ tcp to:192.168.103.149:53 Chain KUBE-SVC-ERIFXISQEP7F7OF4 (1 references) num pkts bytes target prot opt in out source destination 1 0 0 KUBE-MARK-MASQ tcp -- * * !192.168.0.0/16 10.96.0.10 /* kube-system/kube-dns:dns-tcp cluster IP */ tcp dpt:53 2 0 0 KUBE-SEP-S6VTWHFP6KEYRW5L all -- * * 0.0.0.0/0 0.0.0.0/0 /* kube-system/kube-dns:dns-tcp */ statistic mode random probability 0.50000000000 3 0 0 KUBE-SEP-SFGZMYIS2CE4JD3K all -- * * 0.0.0.0/0 0.0.0.0/0 /* kube-system/kube-dns:dns-tcp */ Chain KUBE-SEP-IJUMPPTQDLYXOX4B (1 references) num pkts bytes target prot opt in out source destination 1 0 0 KUBE-MARK-MASQ all -- * * 192.168.103.147 0.0.0.0/0 /* kube-system/kube-dns:dns */ 2 0 0 DNAT udp -- * * 0.0.0.0/0 0.0.0.0/0 /* kube-system/kube-dns:dns */ udp to:192.168.103.147:53 Chain KUBE-SEP-C4W6TKYY5HHEG4RV (1 references) num pkts bytes target prot opt in out source destination 1 0 0 KUBE-MARK-MASQ all -- * * 192.168.103.149 0.0.0.0/0 /* kube-system/kube-dns:dns */ 2 0 0 DNAT udp -- * * 0.0.0.0/0 0.0.0.0/0 /* kube-system/kube-dns:dns */ udp to:192.168.103.149:53 Chain KUBE-SVC-TCOU7JCQXEZGVUNU (1 references) num pkts bytes target prot opt in out source destination 1 0 0 KUBE-MARK-MASQ udp -- * * !192.168.0.0/16 10.96.0.10 /* kube-system/kube-dns:dns cluster IP */ udp dpt:53 2 0 0 KUBE-SEP-IJUMPPTQDLYXOX4B all -- * * 0.0.0.0/0 0.0.0.0/0 /* kube-system/kube-dns:dns */ statistic mode random probability 0.50000000000 3 0 0 KUBE-SEP-C4W6TKYY5HHEG4RV all -- * * 0.0.0.0/0 0.0.0.0/0 /* kube-system/kube-dns:dns */ Chain KUBE-SEP-GX372II3CQAGUHFM (1 references) num pkts bytes target prot opt in out source destination 1 0 0 KUBE-MARK-MASQ all -- * * 192.168.103.145 0.0.0.0/0 /* kubernetes-dashboard/kubernetes-dashboard */ 2 0 0 DNAT tcp -- * * 0.0.0.0/0 0.0.0.0/0 /* kubernetes-dashboard/kubernetes-dashboard */ tcp to:192.168.103.145:8443 Chain KUBE-SVC-CEZPIJSAUFW5MYPQ (1 references) num pkts bytes target prot opt in out source destination 1 0 0 KUBE-MARK-MASQ tcp -- * * !192.168.0.0/16 10.97.166.112 /* kubernetes-dashboard/kubernetes-dashboard cluster IP */ tcp dpt:443 2 0 0 KUBE-SEP-GX372II3CQAGUHFM all -- * * 0.0.0.0/0 0.0.0.0/0 /* kubernetes-dashboard/kubernetes-dashboard */ Chain KUBE-SEP-I3RZS3REJP7POFLG (1 references) num pkts bytes target prot opt in out source destination 1 0 0 KUBE-MARK-MASQ all -- * * 192.168.103.143 0.0.0.0/0 /* lens-metrics/kube-state-metrics:metrics */ 2 0 0 DNAT tcp -- * * 0.0.0.0/0 0.0.0.0/0 /* lens-metrics/kube-state-metrics:metrics */ tcp to:192.168.103.143:8080 Chain KUBE-SVC-H5K62VURUHBF7BRH (1 references) num pkts bytes target prot opt in out source destination 1 0 0 KUBE-MARK-MASQ tcp -- * * !192.168.0.0/16 10.104.154.95 /* lens-metrics/kube-state-metrics:metrics cluster IP */ tcp dpt:8080 2 0 0 KUBE-SEP-I3RZS3REJP7POFLG all -- * * 0.0.0.0/0 0.0.0.0/0 /* lens-metrics/kube-state-metrics:metrics */ Chain KUBE-SEP-ROTMHDCXAI3T7IOR (1 references) num pkts bytes target prot opt in out source destination 1 0 0 KUBE-MARK-MASQ all -- * * 192.168.103.144 0.0.0.0/0 /* lens-metrics/prometheus:web */ 2 0 0 DNAT tcp -- * * 0.0.0.0/0 0.0.0.0/0 /* lens-metrics/prometheus:web */ tcp to:192.168.103.144:9090 Chain KUBE-SVC-MOZMMOD3XZX35IET (1 references) num pkts bytes target prot opt in out source destination 1 0 0 KUBE-MARK-MASQ tcp -- * * !192.168.0.0/16 10.96.73.22 /* lens-metrics/prometheus:web cluster IP */ tcp dpt:80 2 0 0 KUBE-SEP-ROTMHDCXAI3T7IOR all -- * * 0.0.0.0/0 0.0.0.0/0 /* lens-metrics/prometheus:web */ Chain KUBE-SEP-OAYGOO6JHJEB65WC (1 references) num pkts bytes target prot opt in out source destination 1 0 0 KUBE-MARK-MASQ all -- * * 192.168.103.146 0.0.0.0/0 /* ingress-nginx/ingress-nginx-controller:http */ 2 1 60 DNAT tcp -- * * 0.0.0.0/0 0.0.0.0/0 /* ingress-nginx/ingress-nginx-controller:http */ tcp to:192.168.103.146:80 Chain KUBE-SVC-CG5I4G2RS3ZVWGLK (2 references) num pkts bytes target prot opt in out source destination 1 0 0 KUBE-MARK-MASQ tcp -- * * !192.168.0.0/16 10.97.201.174 /* ingress-nginx/ingress-nginx-controller:http cluster IP */ tcp dpt:80 2 1 60 KUBE-MARK-MASQ tcp -- * * 0.0.0.0/0 0.0.0.0/0 /* ingress-nginx/ingress-nginx-controller:http */ tcp dpt:32181 3 1 60 KUBE-SEP-OAYGOO6JHJEB65WC all -- * * 0.0.0.0/0 0.0.0.0/0 /* ingress-nginx/ingress-nginx-controller:http */ Chain KUBE-PROXY-CANARY (0 references) num pkts bytes target prot opt in out source destination Chain cali-nat-outgoing (1 references) num pkts bytes target prot opt in out source destination 1 49 3274 MASQUERADE all -- * * 0.0.0.0/0 0.0.0.0/0 /* cali:flqWnvo8yq4ULQLa */ match-set cali40masq-ipam-pools src ! match-set cali40all-ipam-pools dst random-fully Chain cali-POSTROUTING (1 references) num pkts bytes target prot opt in out source destination 1 1894 114K cali-fip-snat all -- * * 0.0.0.0/0 0.0.0.0/0 /* cali:Z-c7XtVd2Bq7s_hA */ 2 1894 114K cali-nat-outgoing all -- * * 0.0.0.0/0 0.0.0.0/0 /* cali:nYKhEzDlr11Jccal */ 3 0 0 MASQUERADE all -- * tunl0 0.0.0.0/0 0.0.0.0/0 /* cali:SXWvdsbh4Mw7wOln */ ADDRTYPE match src-type !LOCAL limit-out ADDRTYPE match src-type LOCAL random-fully Chain cali-PREROUTING (1 references) num pkts bytes target prot opt in out source destination 1 51 2688 cali-fip-dnat all -- * * 0.0.0.0/0 0.0.0.0/0 /* cali:r6XmIziWUJsdOK6Z */ Chain cali-fip-snat (1 references) num pkts bytes target prot opt in out source destination Chain cali-OUTPUT (1 references) num pkts bytes target prot opt in out source destination 1 1894 114K cali-fip-dnat all -- * * 0.0.0.0/0 0.0.0.0/0 /* cali:GBTAv2p5CwevEyJm */ Chain cali-fip-dnat (2 references) num pkts bytes target prot opt in out source destination Chain KUBE-KUBELET-CANARY (0 references) num pkts bytes target prot opt in out source destination </code></pre>
<p>To clarify I am posting Community Wiki answer.</p> <p>The problem existed only during forwarding to a k8s service NodePort.</p> <p>To solve the problem <strong>you have set up an External Nginx as a TCP Proxy.</strong></p> <p>Here one can find <a href="https://docs.gitlab.com/charts/advanced/external-nginx/" rel="nofollow noreferrer">documentation</a> about <em>External NGINX</em>.</p> <blockquote> <p>Ingress does not directly support TCP services, so some additional configuration is necessary. Your NGINX Ingress Controller may have been <a href="https://github.com/kubernetes/ingress-nginx/blob/master/docs/deploy/index.md" rel="nofollow noreferrer">deployed directly</a> (i.e. with a Kubernetes spec file) or through the <a href="https://github.com/kubernetes/ingress-nginx" rel="nofollow noreferrer">official Helm chart</a>. The configuration of the TCP pass through will differ depending on the deployment approach.</p> </blockquote>
<p>What is the best way to enable BBR on default for my clusters? In this <a href="https://cloud.google.com/kubernetes-engine/docs/how-to/node-system-config" rel="nofollow noreferrer">link</a>, I didn't see an option for controlling the congestion control.</p>
<p>Google BBR can only be enabled in Linux operating systems. By default the Linux servers uses Reno and CUBIC but the latest version kernels also includes the google BBR algorithms and can be enabled manually.</p> <p>To enable it on CentOS 8 add below lines in /etc/sysctl.conf and issue command sysctl -p</p> <p>net.core.default_qdisc = fq net.ipv4.tcp_congestion_control = bbr</p> <p>For more Linux distributions you can refer to this <a href="https://supporthost.in/how-to-install-google-bbr/" rel="nofollow noreferrer">link</a>.</p>
<p>Do you know what is the annotation that we can use it on GKE to make a LoadBalancer service internal?. For example Azure (and AWS) supports the following annotation (shown in the YAML code snippet) to make a LoadBalancer service internal. I couldn’t find equivalent of it on GKE. For example naturally one may expect <strong>gcp-load-balancer-internal</strong> as the equivalent annotation on GKE; unfortunately it is not. Here is the Azure and AWS documentation for it, I am looking equivalent of it on GKE.</p> <ul> <li><a href="https://learn.microsoft.com/en-us/azure/aks/internal-lb" rel="nofollow noreferrer">Azure: internal LoadBalancer</a></li> <li><a href="https://kubernetes-sigs.github.io/aws-load-balancer-controller/v2.2/guide/service/annotations/" rel="nofollow noreferrer">AWS: annotations</a></li> </ul> <pre class="lang-yaml prettyprint-override"><code>apiVersion: v1 kind: Service metadata: annotations: service.beta.kubernetes.io/aws-load-balancer-internal: &quot;true&quot; service.beta.kubernetes.io/azure-load-balancer-internal: &quot;true&quot; </code></pre>
<p>There are 2 annotations:</p> <p>For GKE versions 1.17 and later, use the annotation:</p> <pre><code>networking.gke.io/load-balancer-type: &quot;Internal&quot; </code></pre> <p>For earlier versions, use the annotation:</p> <pre><code>cloud.google.com/load-balancer-type: &quot;Internal&quot; </code></pre> <p>Plus, I’m sharing with you some GCP’s helpful official documentation in the following URLs <a href="https://cloud.google.com/kubernetes-engine/docs/how-to/internal-load-balancing" rel="nofollow noreferrer">Using an internal TCP/UDP load balancer</a> and <a href="https://cloud.google.com/load-balancing/docs/l7-internal/setting-up-l7-internal?hl=en#configure-a-network" rel="nofollow noreferrer">Setting up Internal HTTP(S) Load Balancing </a>.</p>
<p>I'm new to kubernetes. I'm just wondering is there any downside if i'm set the value for kubernetes container resource requests and limits as max as possible like this?</p> <pre><code>resources: limits: cpu: '3' memory: 1Gi requests: cpu: '2' memory: 256Mi </code></pre>
<p>You should set <code>requests</code> to the minimum values your pod needs and <code>limits</code> to the max you allow it to use. It helps Kubernetes to schedule pods properly.</p> <p>If the <code>requests</code> value is too high, then Kubernetes may not have any node that fulfills these requirements and your pod may not run at all.</p> <p>Check this link for more details: <a href="https://sysdig.com/blog/kubernetes-limits-requests/" rel="nofollow noreferrer">https://sysdig.com/blog/kubernetes-limits-requests/</a></p>
<p>I'm using Kubernetes with kube-state-metrics and Prometheus/grafana to graph various metrics of the Kubernetes Cluster.</p> <p>Now I'd like to Graph how many <strong>new</strong> PODs have been created per Hour over Time.</p> <p>The Metric <code>kube_pod_created</code> contains the Creation-Timestamp as Value but since there is a Value in each Time-Slot, the following Query also returns Results >0 for Time-Slots where no new PODs have been created:</p> <pre><code>count(rate(kube_pod_created[1h])) by(namespace) </code></pre> <p>Can I use the Value in some sort of criteria to only count if Value is within the "current" Time-Slot ?</p>
<p>PODs created in past hour</p> <p><code>count ( (time() - sum by (pod) (kube_pod_created)) &lt; 60*60 )</code></p>
<p>I have a Kubernetes cluster with multiple nodes in two different subnets (<code>x</code> and <code>y</code>). I have an IPsec VPN tunnel setup between my <code>x</code> subnet and an external network. Now my problem is that the pods that get scheduled in the nodes on the <code>y</code> subnet can't send requests to the external network because they're in nodes not covered by the VPN tunnel. Creating another VPN to cover the <code>y</code> subnet isn't possible right now. Is there a way in k8s to force all pods' traffic to go through a single source? Or any clean solution even if outside of k8s?</p>
<p>Posting this as a community wiki, feel free to edit and expand.</p> <hr /> <p>There is no built-in functionality in kubernetes that can do it. However there are two available options which can help to achieve the required setup:</p> <ol> <li><strong>Istio</strong></li> </ol> <p>If services are well known then it's possible to use <a href="https://istio.io/latest/docs/tasks/traffic-management/egress/egress-gateway/" rel="nofollow noreferrer">istio egress gateway</a>. We are interested in this use case:</p> <blockquote> <p>Another use case is a cluster where the application nodes don’t have public IPs, so the in-mesh services that run on them cannot access the Internet. Defining an egress gateway, directing all the egress traffic through it, and allocating public IPs to the egress gateway nodes allows the application nodes to access external services in a controlled way.</p> </blockquote> <ol start="2"> <li><strong>Antrea egress</strong></li> </ol> <p>There's another solution which can be used - <a href="https://antrea.io/docs/v1.4.0/docs/egress/" rel="nofollow noreferrer">antrea egress</a>. Use cases are:</p> <p>You may be interested in using this capability if any of the following apply:</p> <blockquote> <ul> <li><p>A consistent IP address is desired when specific Pods connect to services outside of the cluster, for source tracing in audit logs, or for filtering by source IP in external firewall, etc.</p> </li> <li><p>You want to force outgoing external connections to leave the cluster via certain Nodes, for security controls, or due to network topology restrictions.</p> </li> </ul> </blockquote>
<p>Reading through &quot;Kubernetes In Action&quot; book, there is a kubectl command which creates a pod but does not deploy it:</p> <pre><code>$ kubectl run kubia --image=dockeruser/kubia --port=8080 --generator=run/v1 replicationcontroller &quot;kubia&quot; created </code></pre> <p>The generator option is there to ensure that a replication controller is created and that there is no deployment. But in the version of kubectl that I am using, v1.22.3, the generator flag is deprecated. Leaving the generator option out will create the pod, but no replication controller.</p> <p>Which command effectively creates the rc?</p>
<p>You don't need &quot;generator&quot; starting 1.17, you can use &quot;create&quot; like <code>kubectl create deployment kubia --image=dockeruser/kubia --port=8080</code></p>
<p>I found on microsoft documentation a yaml that consent to do everything in all resources inside a namespace. I modified this yaml to avoid delete verbs and it works fine:</p> <pre><code> kind: Role apiVersion: rbac.authorization.k8s.io/v1 metadata: name: myaksrole_useraccess namespace: mynamespace rules: - apiGroups: [&quot;&quot;, &quot;extensions&quot;, &quot;apps&quot;] resources: [&quot;*&quot;] verbs: [&quot;create&quot;, &quot;patch&quot;, &quot;get&quot;, &quot;update&quot;, &quot;list&quot;] - apiGroups: [&quot;batch&quot;] resources: - jobs - cronjobs verbs: [&quot;create&quot;, &quot;patch&quot;, &quot;get&quot;, &quot;update&quot;, &quot;list&quot;] </code></pre> <p>My question is: How I can add delete only for pods resources in this yaml?</p>
<p>Let's check the <code>myaksrole_useraccess</code> Role from the original definition:</p> <pre><code>kubectl describe role myaksrole_useraccess -n mynamespace Name: myaksrole_useraccess kind: Role Labels: &lt;none&gt; Annotations: &lt;none&gt; PolicyRule: Resources Non-Resource URLs Resource Names Verbs --------- ----------------- -------------- ----- * [] [] [create patch get update list] *.apps [] [] [create patch get update list] cronjobs.batch [] [] [create patch get update list] jobs.batch [] [] [create patch get update list] *.extensions [] [] [create patch get update list] </code></pre> <p>Then we can add additional permission for the Pods resource. The updated Role definition is shown below.</p> <pre><code>kind: Role apiVersion: rbac.authorization.k8s.io/v1 metadata: name: myaksrole_useraccess namespace: mynamespace rules: - apiGroups: [&quot;&quot;, &quot;extensions&quot;, &quot;apps&quot;] resources: [&quot;*&quot;] verbs: [&quot;create&quot;, &quot;patch&quot;, &quot;get&quot;, &quot;update&quot;, &quot;list&quot;] - apiGroups: [&quot;batch&quot;] resources: - jobs - cronjobs verbs: [&quot;create&quot;, &quot;patch&quot;, &quot;get&quot;, &quot;update&quot;, &quot;list&quot;] - apiGroups: [&quot;&quot;] resources: - pods verbs: [&quot;delete&quot;, &quot;create&quot;, &quot;patch&quot;, &quot;get&quot;, &quot;update&quot;, &quot;list&quot;] </code></pre> <p>Apply the changes:</p> <pre><code>kubectl apply -f myaksrole_useraccess.yaml </code></pre> <p>Check the <code>myaksrole_useraccess</code> Role again:</p> <pre><code>kubectl describe role myaksrole_useraccess -n mynamespace Name: myaksrole_useraccess Labels: &lt;none&gt; Annotations: &lt;none&gt; PolicyRule: Resources Non-Resource URLs Resource Names Verbs --------- ----------------- -------------- ----- * [] [] [create patch get update list] *.apps [] [] [create patch get update list] cronjobs.batch [] [] [create patch get update list] jobs.batch [] [] [create patch get update list] *.extensions [] [] [create patch get update list] pods [] [] [delete create patch get update list] </code></pre>
<p>I would like to know how exactly pods get an IP address, and how they distribute the pods to agent and master.</p> <p>I have 1 master node and 2 agent nodes. my pods all are running well, but I am curious how the pods get an IP address.</p> <p>some pods have IP cluster nodes, meanwhile, some have an ethernet IP address. I run Nginx and Metallb for the load balancer. Disable Traefik and Klipper.</p> <p>if we can see the agent-03 has 2 IP addresses run on</p> <pre><code>root:/# kubectl get pods -A -o wide ingress nginx-dep-fdcd8sdfs-gj5gff 1/1 Running 0 46h 10.42.0.80 master &lt;none&gt; &lt;none&gt; ingress nginx-dep-fdcd8sdfs-dn80n 1/1 Running 0 46h 10.42.0.79 master &lt;none&gt; &lt;none&gt; ingress nginx-doc-7cc85c5899-sdh55 1/1 Running 0 44h 10.42.0.82 master &lt;none&gt; &lt;none&gt; ingress nginx-doc-7cc85c5899-gjghs 1/1 Running 0 44h 10.42.0.83 master &lt;none&gt; &lt;none&gt; prometheus prometheus-node-exporter-6tl8t 1/1 Running 0 47h 192.168.1.3 agent-03 &lt;none&gt; &lt;none&gt; ingress ingress-controller-nginx-ingress-controller-rqs8n 1/1 Running 5 47h 192.168.1.3 agent-03 &lt;none&gt; &lt;none&gt; prometheus prometheus-kube-prometheus-operator-68fbcb6d67-8qsnf 1/1 Running 1 46h 10.42.2.52 agent-03 &lt;none&gt; &lt;none&gt; ingress nginx-doc-7cc85c5899-b77j6 1/1 Running 0 43h 10.42.2.57 agent-03 &lt;none&gt; &lt;none&gt; metallb-system speaker-sk4pz 1/1 Running 1 47h 192.168.1.3 agent-03 &lt;none&gt; &lt;none&gt; </code></pre> <p>in my pod's shows agent-03 run Nginx-doc use IP cluster while metal use IP ethernet, or it depends on what service are running in pods?</p> <pre><code>ingress nginx-doc-7cc85c5899-b77j6 1/1 Running 0 43h 10.42.2.57 agent-03 &lt;none&gt; &lt;none&gt; metallb-system speaker-sk4pz 1/1 Running 1 47h 192.168.1.3 agent-03 &lt;none&gt; &lt;none&gt; </code></pre> <p>and I can see master has 2 Nginx-doc pods running, which means when I deploy 3 Nginx-doc one agent will not get any Nginx-doc because it has been taken by the master. and it is not divided equally.</p> <p>If I miss configuring which part do I need to fix.</p>
<p>Based on your internal plugin your POD will get the IPs. Which again will be the internal IPs mostly.</p> <p>There are different types of Network interfaces, we can use <strong>CNI</strong> as per need : <a href="https://kubernetes.io/docs/concepts/cluster-administration/networking/" rel="nofollow noreferrer">https://kubernetes.io/docs/concepts/cluster-administration/networking/</a></p> <p>POD gets exposed by the <strong>service</strong>. There are different types of services. <strong>Cluster IP</strong>, <strong>Node Port</strong>, <strong>Load Balancer.</strong> <a href="https://kubernetes.io/docs/concepts/services-networking/service/" rel="nofollow noreferrer">https://kubernetes.io/docs/concepts/services-networking/service/</a></p> <blockquote> <p>in my pod's shows agent-03 run Nginx-doc use IP cluster while metal use IP ethernet, or it depends on what service are running in pods?</p> </blockquote> <p>Could be possible due to the service type you are using due to that IP is different and using ethernet.</p> <p>If your service type is <strong>LoadBalancer</strong> using <strong>MetalLb</strong> which means that the service is exposed using the <strong>IP</strong>, not like internal IP that PODs have mostly.</p> <p><code>kubectl get svc -n &lt;namespace name&gt;</code> and check</p> <blockquote> <p>and I can see master has 2 Nginx-doc pods running, which means when I deploy 3 Nginx-doc one agent will not get any Nginx-doc because it has been taken by the master. and it is not divided equally.</p> </blockquote> <p>There is no guarantee on that, K8s put and assign pods based on score.</p> <p>You can read more about score at here : <a href="https://kubernetes.io/docs/concepts/scheduling-eviction/kube-scheduler/" rel="nofollow noreferrer">https://kubernetes.io/docs/concepts/scheduling-eviction/kube-scheduler/</a></p> <p>If you want to fix your POD on a specific node, suppose you are running the GPU with Node your should schedule on that Node to use GPU in that case you can use.</p> <p><a href="https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/" rel="nofollow noreferrer">https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/</a></p>
<p>I'm trying to deploy a HA Keycloak cluster (2 nodes) on Kubernetes (GKE). So far the cluster nodes (pods) are failing to discover each other in all the cases as of what I deduced from the logs. Where the pods initiate and the service is up but they fail to see other nodes.</p> <p>Components</p> <ul> <li>PostgreSQL DB deployment with a clusterIP service on the default port.</li> <li>Keycloak Deployment of 2 nodes with the needed ports container ports 8080, 8443, a relevant clusterIP, and a service of type LoadBalancer to expose the service to the internet</li> </ul> <p>Logs Snippet:</p> <pre><code>INFO [org.infinispan.remoting.transport.jgroups.JGroupsTransport] (MSC service thread 1-4) ISPN000078: Starting JGroups channel ejb INFO [org.infinispan.remoting.transport.jgroups.JGroupsTransport] (MSC service thread 1-4) ISPN000094: Received new cluster view for channel ejb: [keycloak-567575d6f8-c5s42|0] (1) [keycloak-567575d6f8-c5s42] INFO [org.infinispan.remoting.transport.jgroups.JGroupsTransport] (MSC service thread 1-1) ISPN000094: Received new cluster view for channel ejb: [keycloak-567575d6f8-c5s42|0] (1) [keycloak-567575d6f8-c5s42] INFO [org.infinispan.remoting.transport.jgroups.JGroupsTransport] (MSC service thread 1-3) ISPN000094: Received new cluster view for channel ejb: [keycloak-567575d6f8-c5s42|0] (1) [keycloak-567575d6f8-c5s42] INFO [org.infinispan.remoting.transport.jgroups.JGroupsTransport] (MSC service thread 1-4) ISPN000079: Channel ejb local address is keycloak-567575d6f8-c5s42, physical addresses are [127.0.0.1:55200] . . . INFO [org.jboss.as] (Controller Boot Thread) WFLYSRV0025: Keycloak 15.0.2 (WildFly Core 15.0.1.Final) started in 67547ms - Started 692 of 978 services (686 services are lazy, passive or on-demand) INFO [org.jboss.as] (Controller Boot Thread) WFLYSRV0060: Http management interface listening on http://127.0.0.1:9990/management INFO [org.jboss.as] (Controller Boot Thread) WFLYSRV0051: Admin console listening on http://127.0.0.1:9990 </code></pre> <p><strong>And as we can see in the above logs the node sees itself as the only container/pod ID</strong></p> <h2>Trying KUBE_PING protocol</h2> <p>I tried using the <strong>kubernetes.KUBE_PING</strong> protocol for discovery but it didn't work and the call to the kubernetes downward API. With a <strong>403 Authorization error</strong> in the logs (BELOW IS PART OF IT):</p> <pre><code>Server returned HTTP response code: 403 for URL: https://[SERVER_IP]:443/api/v1/namespaces/default/pods </code></pre> <p>At this point, I was able to log in to the portal and do the changes but it was not yet an HA cluster since changes were not replicated and the session was not preserved, in other words, if I delete the pod that I was using I was redirected to the other with a new session (as if it was a separate node)</p> <h2>Trying DNS_PING protocol</h2> <p>When I tried DNS_PING things were different I had no Kubernetes downward API issues but I was not able to log in.</p> <p>In detail, I was able to reach the login page normally, but when I enter my credentials and try logging in the page tries loading but gets me back to the login page with no logs in the pods in this regard.</p> <p>Below are some of the references I resorted to over the past couple of days:</p> <ul> <li><a href="https://github.com/keycloak/keycloak-containers/blob/main/server/README.md#openshift-example-with-dnsdns_ping" rel="nofollow noreferrer">https://github.com/keycloak/keycloak-containers/blob/main/server/README.md#openshift-example-with-dnsdns_ping</a></li> <li><a href="https://github.com/keycloak/keycloak-containers/blob/main/server/README.md#clustering" rel="nofollow noreferrer">https://github.com/keycloak/keycloak-containers/blob/main/server/README.md#clustering</a></li> <li><a href="https://www.youtube.com/watch?v=g8LVIr8KKSA" rel="nofollow noreferrer">https://www.youtube.com/watch?v=g8LVIr8KKSA</a></li> <li><a href="https://www.keycloak.org/2019/05/keycloak-cluster-setup.html" rel="nofollow noreferrer">https://www.keycloak.org/2019/05/keycloak-cluster-setup.html</a></li> <li><a href="https://www.keycloak.org/docs/latest/server_installation/#creating-a-keycloak-custom-resource-on-kubernetes" rel="nofollow noreferrer">https://www.keycloak.org/docs/latest/server_installation/#creating-a-keycloak-custom-resource-on-kubernetes</a></li> </ul> <h2>My Yaml Manifest files</h2> <p><strong>Postgresql Deployment</strong></p> <pre><code>apiVersion: apps/v1 kind: Deployment metadata: name: postgres spec: replicas: 1 selector: matchLabels: app: postgres template: metadata: labels: app: postgres spec: containers: - name: postgres image: postgres:13 imagePullPolicy: IfNotPresent ports: - containerPort: 5432 env: - name: POSTGRES_PASSWORD value: &quot;postgres&quot; - name: PGDATA value: /var/lib/postgresql/data/pgdata --- apiVersion: v1 kind: Service metadata: name: postgres spec: selector: app: postgres ports: - port: 5432 targetPort: 5432 </code></pre> <p><strong>Keycloak HA cluster Deployment</strong></p> <pre><code>apiVersion: apps/v1 kind: Deployment metadata: name: keycloak labels: app: keycloak spec: replicas: 2 strategy: type: RollingUpdate rollingUpdate: maxUnavailable: 1 selector: matchLabels: app: keycloak template: metadata: labels: app: keycloak spec: containers: - name: keycloak image: jboss/keycloak env: - name: KEYCLOAK_USER value: admin - name: KEYCLOAK_PASSWORD value: admin123 - name: DB_VENDOR value: POSTGRES - name: DB_ADDR value: &quot;postgres&quot; - name: DB_PORT value: &quot;5432&quot; - name: DB_USER value: &quot;postgres&quot; - name: DB_PASSWORD value: &quot;postgres&quot; - name: DB_SCHEMA value: &quot;public&quot; - name: DB_DATABASE value: &quot;keycloak&quot; # - name: JGROUPS_DISCOVERY_PROTOCOL # value: kubernetes.KUBE_PING # - name: JGROUPS_DISCOVERY_PROPERTIES # value: dump_requests=true,port_range=0,namespace=default # value: port_range=0,dump_requests=true - name: JGROUPS_DISCOVERY_PROTOCOL value: dns.DNS_PING - name: JGROUPS_DISCOVERY_PROPERTIES value: &quot;dns_query=keycloak&quot; - name: CACHE_OWNERS_COUNT value: '2' - name: CACHE_OWNERS_AUTH_SESSIONS_COUNT value: '2' - name: PROXY_ADDRESS_FORWARDING value: &quot;true&quot; ports: - name: http containerPort: 8080 - name: https containerPort: 8443 --- apiVersion: v1 kind: Service metadata: name: keycloak labels: app: keycloak spec: type: ClusterIP ports: - name: http port: 80 targetPort: 8080 - name: https port: 443 targetPort: 8443 selector: app: keycloak --- apiVersion: v1 kind: Service metadata: name: keycloak-np labels: app: keycloak spec: type: LoadBalancer ports: - name: http port: 80 targetPort: 8080 - name: https port: 443 targetPort: 8443 selector: app: keycloak </code></pre> <h2>IMPORTANT NOTE</h2> <ul> <li>I tried both protocols with and without the database setup.</li> <li>The above yaml has all the discovery protocol combinations I tried each at a time (the ones commented)</li> </ul>
<h3>For Keycloak 17 and newer</h3> <p>By default, those versions use DNS_PING as the discovery mechanism for JGroups (the underlying cluster mechanism) but you still need to activate it.</p> <p>You'll need:</p> <ul> <li>a <a href="https://kubernetes.io/docs/concepts/services-networking/service/#headless-services" rel="nofollow noreferrer">headless service</a> pointing to your keycloak pods (a headless service is just a normal service but with <code>ClusterIP: none</code>)</li> <li>env <code>KC_CACHE_STACK=kubernetes</code> (to activate the kubernetes jgroup configs) and <code>JAVA_OPTS_APPEND=-Djgroups.dns.query=&lt;name-of-headless-service&gt;</code> (to tell it how to find the other keycloak pods).</li> </ul> <p>That way, when starting up, jgroups will issue a dns query for (example: keycloak-headless.my_namespace.svc.cluster.local) and the response will be the IP of all pods associated to the headless service.</p> <p>JGroups will then contact every IP in communication port and stablish the cluster.</p> <hr /> <p><strong>UPDATE</strong> 2022-08-01: This configuration below is for the legacy version of keycloak (or versions up to 16). From 17 on Keycloak migrated to the Quarkus distribution and the configuration is different, as above.</p> <h3>For Keycloak up to 16</h3> <p>The way KUBE_PING works is similar to running <code>kubectl get pods</code> inside one Keycloak pod to find the other Keycloak pods' IPs and then trying to connect to them one by one. However, Keycloak does this by querying the Kubernetes API directly instead of using <code>kubectl</code>.</p> <p>To access the Kubernetes API, Keycloak needs credentials in the form of an access token. You can pass your token directly, but this is not very secure or convenient.</p> <p>Kubernetes has a built-in mechanism for injecting a token into a pod (or the software running inside that pod) to allow it to query the API. This is done by creating a service account, giving it the necessary permissions through a RoleBinding, and setting that account in the pod configuration.</p> <p>The token is then mounted as a file at a known location, which is hardcoded and expected by all Kubernetes clients. When the client wants to call the API, it looks for the token at that location.</p> <p><a href="https://kubernetes.io/docs/tasks/configure-pod-container/configure-service-account/" rel="nofollow noreferrer">You can get a deeper look at the Service Account mechanism in the documentation</a>.</p> <p>In some situations, you may not have the necessary permissions to create RoleBindings. In this case, you can ask an administrator to create the service account and RoleBinding for you or pass your own user's token (if you have the necessary permissions) through the SA_TOKEN_FILE environment variable.</p> <p>You can create the file using a secret or configmap, mount it to the pod, and set SA_TOKEN_FILE to the file location. Note that this method is specific to JGroups library (used by Keycloak) and <a href="https://github.com/jgroups-extras/jgroups-kubernetes/blob/master/src/main/java/org/jgroups/protocols/kubernetes/KUBE_PING.java" rel="nofollow noreferrer">the documentation is here</a>.</p> <hr /> <p>If you do have permissions to create service accounts and RoleBindings in the cluster:</p> <p>An example (not tested):</p> <pre class="lang-bash prettyprint-override"><code>export TARGET_NAMESPACE=default # convenient method to create a service account kubectl create serviceaccount keycloak-kubeping-service-account -n $TARGET_NAMESPACE # No convenient method to create Role and RoleBindings # Needed to explicitly define them. cat &lt;&lt;EOF | kubectl apply -f - kind: Role apiVersion: rbac.authorization.k8s.io/v1 metadata: name: keycloak-kubeping-pod-reader rules: - apiGroups: [&quot;&quot;] resources: [&quot;pods&quot;] verbs: [&quot;get&quot;, &quot;list&quot;] --- apiVersion: rbac.authorization.k8s.io/v1beta1 kind: RoleBinding metadata: name: keycloak-kubeping-api-access roleRef: apiGroup: rbac.authorization.k8s.io kind: Role name: keycloak-kubeping-pod-reader subjects: - kind: ServiceAccount name: keycloak-kubeping-service-account namespace: $TARGET_NAMESPACE EOF </code></pre> <p>On the deployment, you set the serviceAccount:</p> <pre class="lang-yaml prettyprint-override"><code>apiVersion: apps/v1 kind: Deployment metadata: name: keycloak spec: template: spec: serviceAccount: keycloak-kubeping-service-account serviceAccountName: keycloak-kubeping-service-account containers: - name: keycloak image: jboss/keycloak env: # ... - name: JGROUPS_DISCOVERY_PROTOCOL value: kubernetes.KUBE_PING - name: JGROUPS_DISCOVERY_PROPERTIES value: dump_requests=true - name: KUBERNETES_NAMESPACE valueFrom: fieldRef: apiVersion: v1 fieldPath: metadata.namespace # ... </code></pre> <p><code>dump_requests=true</code> will help you debug Kubernetes requests. Better to have it <code>false</code> in production. You can use <code>namespace=&lt;yournamespace</code> instead of <code>KUBERNETES_NAMESPACE</code>, but that's a handy way the pod has to autodetect the namespace it's running at.</p> <p>Please note that KUBE_PING will find all pods in the namespace, not only keycloak pods, and will try to connect to all of them. Of course, if your other pods don't care about that, it's OK.</p>
<p>I am trying to learn Google Kubernetes Engine. I am deploying a web app in Node.js on a cluster containing 6 sensitive environment variables. Locally I have them in an .env file that I have .gitignored. I push the code to github which creates a container on Cloud Build through a trigger.</p> <p>I am using the graphical user interface of GCP (i.e not Kubectl, gsutil or the likes of it). I am also doing it without Yaml-files. This works perfectly fine for now.</p> <p>However, I am troubleshooting an issue which makes me having to deploy new workloads all the time, and as such I need to add those environmental variables every time, which is quite tedious.</p> <p>I understand the solution is to do it either using gsutil and/or use yaml-files. I know I will have to start using gsutil and yaml at some point, and maybe that is now.</p> <p>However, I wonder if I put environmental variables in a yaml-file that I push to github and further on to GCP, I obviously cannot gitignore it. <strong>How, then, do I keep the passwords etc outside of the code base?</strong> I moved these variables from the code into environmental variables for that reason.</p> <p>What is common/good practise to work with environmental variables on GCP - in a easy and safe manner?</p>
<blockquote> <p>What is common/good practise to work with environmental variables on GCP - in a easy and safe manner?</p> </blockquote> <p>Very easy documentation : <a href="https://cloud.google.com/kubernetes-engine/docs/concepts/secret" rel="nofollow noreferrer">https://cloud.google.com/kubernetes-engine/docs/concepts/secret</a></p> <p>You should be using the Key-value store or other Key value management service.</p> <p>Kubernetes suggest the best practice is to use the K8s <strong>secret</strong> and <strong>configmap</strong> which is base64 encoded key-value pair. That you applied to K8s cluster using YAML and which further get injected to deployment and application get it from the environment.</p> <p>Either you inject variables into environment variables or inject as files into file system from where further used by the application.</p> <p>You can check more at : <a href="https://kubernetes.io/docs/concepts/configuration/secret/" rel="nofollow noreferrer">https://kubernetes.io/docs/concepts/configuration/secret/</a></p> <p><strong>Basic example secret injecting as Environment:</strong></p> <pre><code>apiVersion: v1 kind: Pod metadata: name: secret-env-pod spec: containers: - name: mycontainer image: redis env: - name: SECRET_USERNAME valueFrom: secretKeyRef: name: mysecret key: username </code></pre> <p>You store files into secret and that secret base64 encoded injected to deployment and add file there in the filesystem. Once your application starts it start using a file from that file.</p> <p><strong>Basic example secret injecting as File into file system:</strong></p> <pre><code>apiVersion: v1 kind: Pod metadata: name: mypod spec: containers: - name: mypod image: redis volumeMounts: - name: foo mountPath: &quot;/etc/foo&quot; volumes: - name: foo secret: secretName: mysecret </code></pre> <p>Now it's on you which type of Environment variables you have, if it's simple Key-value or .env etc.</p> <p>If it's simple Keyvalue, you are looking for <strong>encryption</strong> at rest, security and other access policy, and <strong>UI</strong> to update secret.</p> <p>i would recommend checking out the <a href="https://www.vaultproject.io/" rel="nofollow noreferrer">Hashicorp</a> vault famous and used by many enterprises. Using this you can encrypt the secret and inject it into the deployment. But you need deploy and manage this workload it's not managed service like secret manager or so.</p> <p>i am not an employee of Google but you are on GKE i would also suggest checking out the Secret manager or KMS which can manage your secret.</p> <p>Article : <a href="https://cloud.google.com/kubernetes-engine/docs/how-to/encrypting-secrets" rel="nofollow noreferrer">https://cloud.google.com/kubernetes-engine/docs/how-to/encrypting-secrets</a></p> <p>Github CSI driver : <a href="https://github.com/GoogleCloudPlatform/secrets-store-csi-driver-provider-gcp" rel="nofollow noreferrer">https://github.com/GoogleCloudPlatform/secrets-store-csi-driver-provider-gcp</a></p> <p>If you have no concerns with <strong>encoding</strong> and those are not important secrets you can use <strong>default inbuilt K8s secret</strong>.</p> <p>On committing YAML file side, if you are using <strong>Vault</strong> or <strong>secret manager</strong> you won't have to manage <strong>secret</strong> in YAML file or deployment YAML won't be storing any <strong>confidential</strong> <strong>secrets</strong>.</p>
<p>I have the following Dockerfile:</p> <pre class="lang-sh prettyprint-override"><code>FROM python:3-alpine WORKDIR /usr/src/app COPY requirements.txt . RUN pip install -qr requirements.txt COPY target-watch.py . CMD [&quot;python3&quot;, &quot;./target-watch.py&quot;] </code></pre> <p>If I deploy this to a Kubernetes cluster the build went fine, but I got an error from the Kubernetes logs. To verfiy my image I run the following command:</p> <pre class="lang-sh prettyprint-override"><code>docker run --rm -it --entrypoint /bin/bash docker-conveyor.xxx.com/myorg/my_cron_jobs:2021.12.08_03.51_abcdef </code></pre> <p>Which gives me this response:</p> <pre class="lang-none prettyprint-override"><code>docker: Error response from daemon: OCI runtime create failed: container_linux.go:380: starting container process caused: exec: &quot;/bin/bash&quot;: stat /bin/bash: no such file or directory: unknown. </code></pre> <p>How can this be fixed? I assume a shell is missing in my image. How do i have to change my Dockerfile to make it work without any errors?</p>
<p>Your container image doesn't have bash so you should use /bin/sh instead of /bin/bash.</p> <pre><code>docker run --rm -it --entrypoint /bin/sh docker-conveyor.xxx.com/myorg/my_cron_jobs:2021.12.08_03.51_abcdef </code></pre> <p>Alpine docker image doesn't have bash installed by default. You will need to add the following commands to get bash:</p> <pre><code>RUN apk update &amp;&amp; apk add bash </code></pre> <p>If you're using Alpine 3.3+ then you can just do</p> <pre><code>RUN apk add --no-cache bash </code></pre>
<p>The KubernetesPodOperator in my Airflow dag is trying to launch a pod using the following pod spec (replaced some config values with <code>xxx</code>):</p> <pre><code>{ &quot;apiVersion&quot;: &quot;v1&quot;, &quot;kind&quot;: &quot;Pod&quot;, &quot;metadata&quot;: { &quot;annotations&quot;: { &quot;sidecar.istio.io/inject&quot;: &quot;false&quot;, &quot;azureDisk&quot;: { &quot;kind&quot;: &quot;Managed&quot;, &quot;diskName&quot;: &quot;airflow-buffer&quot;, &quot;diskURI&quot;: &quot;xxx&quot;, &quot;cachingMode&quot;: &quot;None&quot; } }, &quot;labels&quot;: { &quot;airflow_version&quot;: &quot;1.10.15&quot;, &quot;kubernetes_pod_operator&quot;: &quot;True&quot;, &quot;dag_id&quot;: &quot;cxf-main&quot;, &quot;task_id&quot;: &quot;cxf-main&quot;, &quot;execution_date&quot;: &quot;2021-11-20T0300000000-d97e9064f&quot;, &quot;try_number&quot;: &quot;3&quot; }, &quot;name&quot;: &quot;xxx&quot;, &quot;namespace&quot;: &quot;airflow&quot; }, &quot;spec&quot;: { &quot;affinity&quot;: {}, &quot;containers&quot;: [ { &quot;args&quot;: [], &quot;command&quot;: [ &quot;python&quot;, &quot;src/main.py&quot; ], &quot;env&quot;: [ { &quot;name&quot;: &quot;xxx&quot;, &quot;value&quot;: &quot;xxx&quot; }, { &quot;name&quot;: &quot;xxx&quot;, &quot;value&quot;: &quot;production&quot; } ], &quot;envFrom&quot;: [], &quot;image&quot;: &quot;xxx&quot;, &quot;imagePullPolicy&quot;: &quot;IfNotPresent&quot;, &quot;name&quot;: &quot;base&quot;, &quot;resources&quot;: { &quot;limits&quot;: {}, &quot;requests&quot;: {} }, &quot;volumeMounts&quot;: [ { &quot;mountPath&quot;: &quot;/mnt/buffer&quot;, &quot;name&quot;: &quot;xxx&quot;, &quot;readOnly&quot;: true } ] } ], &quot;hostNetwork&quot;: false, &quot;imagePullSecrets&quot;: [ { &quot;name&quot;: &quot;xxx&quot; } ], &quot;initContainers&quot;: [], &quot;nodeSelector&quot;: {}, &quot;restartPolicy&quot;: &quot;Never&quot;, &quot;securityContext&quot;: {}, &quot;serviceAccountName&quot;: &quot;default&quot;, &quot;tolerations&quot;: [], &quot;volumes&quot;: [ { &quot;name&quot;: &quot;xxx&quot;, &quot;persistentVolumeClaim&quot;: { &quot;claimName&quot;: &quot;xxx&quot; } } ] } } </code></pre> <p>However, the Kubernetes API is returning an exception and I can't figure out why:</p> <pre><code>Pod in version \&quot;v1\&quot; cannot be handled as a Pod: v1.Pod.ObjectMeta: v1.ObjectMeta.Annotations: ReadString: expects \&quot; or n, but found {, error found in #10 byte of ...|reDisk\&quot;: {\&quot;kind\&quot;: \&quot;M|..., bigger context ...|\&quot;sidecar.istio.io/inject\&quot;: \&quot;false\&quot;, \&quot;azureDisk\&quot;: {\&quot;kind\&quot;: \&quot;Managed\&quot;, \&quot;diskName\&quot;: \&quot;airflow-buffer\&quot;, \&quot;|... </code></pre>
<p>You have nested annotations and thats also what the error is telling you.</p> <pre><code>v1.ObjectMeta.Annotations: ReadString: expects \&quot; or n, but found {, </code></pre> <p>You are not allowed to do this.</p> <pre class="lang-json prettyprint-override"><code>&quot;annotations&quot;: { &quot;sidecar.istio.io/inject&quot;: &quot;false&quot;, // cannot nest azureDisk inside annotations &quot;azureDisk&quot;: { &quot;kind&quot;: &quot;Managed&quot;, &quot;diskName&quot;: &quot;airflow-buffer&quot;, &quot;diskURI&quot;: &quot;xxx&quot;, &quot;cachingMode&quot;: &quot;None&quot; } } </code></pre> <p>This object belongs in the volumes array.</p> <pre class="lang-json prettyprint-override"><code>&quot;volumes&quot;: [ { &quot;name&quot;: &quot;mydisk&quot;, &quot;azureDisk&quot;: { &quot;kind&quot;: &quot;Managed&quot;, &quot;diskName&quot;: &quot;airflow-buffer&quot;, &quot;diskURI&quot;: &quot;xxx&quot;, &quot;cachingMode&quot;: &quot;None&quot; } } ] </code></pre> <p>You can also see this in this documentation for example, in YAML format.</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 have Kubernetes with ClusterRoles defined for my users and permissions by (RoleBindings) namespaces. I want these users could be accessed into the Kubernetes Dashboard with custom perms. However, when they try to log in when using kubeconfig option that's got this message:</p> <pre><code>&quot;Internal error (500): Not enough data to create auth info structure.&quot; </code></pre> <p><a href="https://github.com/kubernetes/dashboard/blob/master/docs/user/access-control/creating-sample-user.md" rel="nofollow noreferrer">https://github.com/kubernetes/dashboard/blob/master/docs/user/access-control/creating-sample-user.md</a> -- This guide is only for creating ADMIN users, not users with custom perms or without privileges... (edited)</p>
<p><strong>Update SOLVED:</strong></p> <p>You have to do this:</p> <ol> <li>Create ServiceAccount per user</li> </ol> <pre><code>apiVersion: v1 kind: ServiceAccount metadata: name: NAME-user namespace: kubernetes-dashboard </code></pre> <ol start="2"> <li>Adapt the RoleBinding adding this SA</li> </ol> <pre><code>kind: RoleBinding apiVersion: rbac.authorization.k8s.io/v1 metadata: name: PUT YOUR CR HERE namespace: PUT YOUR NS HERE subjects: - kind: User name: PUT YOUR CR HERE apiGroup: 'rbac.authorization.k8s.io' - kind: ServiceAccount name: NAME-user namespace: kubernetes-dashboard roleRef: kind: ClusterRole name: PUT YOUR CR HERE apiGroup: 'rbac.authorization.k8s.io' </code></pre> <ol start="3"> <li>Get the token:</li> </ol> <pre><code>kubectl -n kubernetes-dashboard get secret $(kubectl -n kubernetes-dashboard get sa/NAME-user -o jsonpath=&quot;{.secrets[0].name}&quot;) -o go-template=&quot;{{.data.token | base64decode}}&quot; </code></pre> <ol start="4"> <li>Add token into your kubeconfig file. Your kb should be contain something like this:</li> </ol> <pre><code>apiVersion: v1 clusters: - cluster: server: https://XXXX name: kubernetes contexts: - context: cluster: kubernetes user: YOUR UER name: kubernetes current-context: &quot;kubernetes&quot; kind: Config preferences: {} users: - name: YOUR USER user: client-certificate-data: CODED client-key-data: CODED token: CODED ---&gt; ADD TOKEN HERE </code></pre> <ol start="5"> <li>Login</li> </ol>
<p>In Helm's v3 documentation: <a href="https://helm.sh/docs/chart_template_guide/accessing_files/" rel="nofollow noreferrer">Accessing Files Inside Templates</a>, the author gives an example of 3 properties (toml) files; where each file has only one key/value pair.</p> <p>The configmap.yaml looks like this. I'm only adding one <em>config.toml</em> for simplicity.</p> <pre><code>apiVersion: v1 kind: ConfigMap metadata: name: {{ .Release.Name }}-config data: {{- $files := .Files }} {{- range tuple &quot;config.toml&quot; }} {{ . }}: |- {{ $files.Get . }} {{- end }} </code></pre> <p>This works fine, until I add a <em>second</em> line to the config.toml file.</p> <p>config.toml</p> <pre><code>replicaCount=1 foo=bar </code></pre> <p>Then I get an Error: <code>INSTALLATION FAILED: YAML parse error on deploy/templates/configmap.yaml: error converting YAML to JSON: yaml: line 9: could not find expected ':'</code></p> <p>Any thoughts will be appreciated. Thanks</p>
<p>Helm will read in that file, but it is (for good or bad) a <strong>text</strong> templating engine. It does not understand that you are trying to compose a YAML file and thus it will not help you. That's actually why you will see so many, many templates in the wild with <code>{{ .thing | indent 8 }}</code> or <code>{{ .otherThing | toYaml }}</code> -- because <a href="https://helm.sh/docs/chart_template_guide/control_structures/#controlling-whitespace" rel="nofollow noreferrer">you need to help Helm</a> know in what context it is emitting the <em>text</em></p> <p>Thus, in your specific case, you'll want the <a href="https://masterminds.github.io/sprig/strings.html#indent" rel="nofollow noreferrer"><code>indent</code> filter</a> with a value of 4 because your current template has two spaces for the key indent level, and two more spaces for the value block scalar</p> <pre><code>data: {{- $files := .Files }} {{- range tuple &quot;config.toml&quot; }} {{ . }}: |- {{ $files.Get . | indent 4 }} {{/* notice this ^^^ template expression is flush left, because the 'indent' is handling whitespace, not the golang template itself */}} {{- end }} </code></pre> <hr /> <p>Also, while this is the specific answer to your question, don't overlook the <a href="https://helm.sh/docs/chart_template_guide/accessing_files/#configmap-and-secrets-utility-functions" rel="nofollow noreferrer"><code>.AsConfig</code> section on that page</a> which seems much more likely to be what you really want to happen, and requires less <code>indent</code> math</p>
<p>I'm creating three EKS clusters using <a href="https://registry.terraform.io/modules/terraform-aws-modules/eks/aws/latest" rel="nofollow noreferrer">this</a> module. Everything works fine, just that when I try to add the configmap to the clusters using <code>map_roles</code>, I face an issue.</p> <p>My configuration looks like this which I have it within all three clusters</p> <pre><code>map_roles = [{ rolearn = &quot;arn:aws:iam::${var.account_no}:role/argo-${var.environment}-${var.aws_region}&quot; username = &quot;system:node:{{EC2PrivateDNSName}}&quot; groups = [&quot;system:bootstrappers&quot;,&quot;system:nodes&quot;] }, { rolearn = &quot;arn:aws:sts::${var.account_no}:assumed-role/${var.assumed_role_1}&quot; username = &quot;admin&quot; groups = [&quot;system:masters&quot;,&quot;system:nodes&quot;,&quot;system:bootstrappers&quot;] }, { rolearn = &quot;arn:aws:sts::${var.account_no}:assumed-role/${var.assumed_role_2}&quot; username = &quot;admin&quot; groups = [&quot;system:masters&quot;,&quot;system:nodes&quot;,&quot;system:bootstrappers&quot;] } ] </code></pre> <p>The problem occurs while applying the template. It says</p> <pre><code>configmaps &quot;aws-auth&quot; already exists </code></pre> <p>When I studied the error further I realised that when applying the template, the module creates three configmap resources of the same name like these</p> <pre><code> resource &quot;kubernetes_config_map&quot; &quot;aws_auth&quot; { # ... } resource &quot;kubernetes_config_map&quot; &quot;aws_auth&quot; { # ... } resource &quot;kubernetes_config_map&quot; &quot;aws_auth&quot; { # ... } </code></pre> <p>This obviously is a problem. How do I fix this issue?</p>
<p>The aws-auth configmap is created by EKS, when you create a managed node pool. It has the configuration required for nodes to register with the control plane. If you want to control the contents of the configmap with Terraform you have two options.</p> <p>Either make sure you create the config map before the managed node pools resource. Or import the existing config map into the Terraform state manually.</p>
<p>I'm new to monitoring the k8s cluster with prometheus, node exporter and so on.</p> <p>I want to know that what the metrics exactly mean for though the name of metrics are self descriptive.</p> <p>I already checked the github of node exporter, but I got not useful information.</p> <p>Where can I get the descriptions of node exporter metrics?</p> <p>Thanks</p>
<p>There is a short description along with each of the metrics. You can see them if you open node exporter in browser or just <code>curl http://my-node-exporter:9100/metrics</code>. You will see all the exported metrics and lines with <code># HELP</code> are the description ones:</p> <pre><code># HELP node_cpu_seconds_total Seconds the cpus spent in each mode. # TYPE node_cpu_seconds_total counter node_cpu_seconds_total{cpu=&quot;0&quot;,mode=&quot;idle&quot;} 2.59840376e+07 </code></pre> <p>Grafana can show this help message in the editor: <a href="https://i.stack.imgur.com/5Ciz5.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/5Ciz5.png" alt="grafana" /></a> Prometheus (with recent experimental editor) can show it too: <a href="https://i.stack.imgur.com/CElLt.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/CElLt.png" alt="enter image description here" /></a> And this works for all metrics, not just node exporter's. If you need more technical details about those values, I recommend searching for the information in Google and <code>man</code> pages (if you're on Linux). Node exporter takes most of the metrics from <code>/proc</code> almost as-is and it is not difficult to find the details. Take for example <code>node_memory_KReclaimable_bytes</code>. 'Bytes' suffix is obviously the unit, <code>node_memory</code> is just a namespace prefix, and <code>KReclaimable</code> is the actual metric name. Using <code>man -K KReclaimable</code> will bring you to the <a href="https://man7.org/linux/man-pages/man5/proc.5.html" rel="nofollow noreferrer">proc(5)</a> man page, where you can find that:</p> <pre><code> KReclaimable %lu (since Linux 4.20) Kernel allocations that the kernel will attempt to reclaim under memory pressure. Includes SReclaimable (below), and other direct allocations with a shrinker. </code></pre> <p>Finally, if this intention to learn more about the metrics is inspired by the desire to configure alerts for your hardware, you can skip to the last part and grab some alerts shared by the community from here: <a href="https://awesome-prometheus-alerts.grep.to/rules#host-and-hardware" rel="nofollow noreferrer">https://awesome-prometheus-alerts.grep.to/rules#host-and-hardware</a></p>
<p>After creating a Service Account for Jenkins with the commands:</p> <pre><code>kubectl -n jenkins create sa jenkins kubectl create clusterrolebinding jenkins --clusterrole cluster-admin --serviceaccount=jenkins:jenkins </code></pre> <p>and adding the certificate in Jenkins (Manage Jenkins --> Configure System --> Add Cloud) I get the error message</p> <pre><code>Error connecting to https://169.46.7.238:21769: Failure executing: GET at: https://169.46.7.238:21769/api/v1/namespaces/jenkins/pods. Message: Forbidden!Configured service account doesn't have access. Service account may have been revoked. User "system:serviceaccount:jenkins:default" cannot list pods in the namespace "jenkins".. </code></pre> <p>It seems like Jenkins tries to use the <code>default</code>Serviceaccount.</p> <p>How can this be fixed? </p>
<p>This one is work for me <code>kubectl create clusterrolebinding jenkins --clusterrole cluster-admin --serviceaccount=jenkins:default</code></p>
<p>Am in very early stages of exploring Argo with Spark operator to run Spark samples on the minikube setup on my EC2 instance.</p> <p>Following are the resources details, not sure why am not able to see the spark app logs.</p> <p><strong>WORKFLOW.YAML</strong></p> <pre><code>kind: Workflow metadata: name: spark-argo-groupby spec: entrypoint: sparkling-operator templates: - name: spark-groupby resource: action: create manifest: | apiVersion: &quot;sparkoperator.k8s.io/v1beta2&quot; kind: SparkApplication metadata: generateName: spark-argo-groupby spec: type: Scala mode: cluster image: gcr.io/spark-operator/spark:v3.0.3 imagePullPolicy: Always mainClass: org.apache.spark.examples.GroupByTest mainApplicationFile: local:///opt/spark/spark-examples_2.12-3.1.1-hadoop-2.7.jar sparkVersion: &quot;3.0.3&quot; driver: cores: 1 coreLimit: &quot;1200m&quot; memory: &quot;512m&quot; labels: version: 3.0.0 executor: cores: 1 instances: 1 memory: &quot;512m&quot; labels: version: 3.0.0 - name: sparkling-operator dag: tasks: - name: SparkGroupBY template: spark-groupby </code></pre> <p><strong>ROLES</strong></p> <pre><code># Role for spark-on-k8s-operator to create resources on cluster apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRole metadata: name: spark-cluster-cr labels: rbac.authorization.kubeflow.org/aggregate-to-kubeflow-edit: &quot;true&quot; rules: - apiGroups: - sparkoperator.k8s.io resources: - sparkapplications verbs: - '*' --- # Allow airflow-worker service account access for spark-on-k8s apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRoleBinding metadata: name: argo-spark-crb roleRef: apiGroup: rbac.authorization.k8s.io kind: ClusterRole name: spark-cluster-cr subjects: - kind: ServiceAccount name: default namespace: argo </code></pre> <p><strong>ARGO UI</strong></p> <p><a href="https://i.stack.imgur.com/6KqvX.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/6KqvX.png" alt="Workflow status" /></a></p> <p><a href="https://i.stack.imgur.com/pzuAZ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/pzuAZ.png" alt="Workflow logs" /></a></p> <p>To dig deep I tried all the steps that's listed on <a href="https://dev.to/crenshaw_dev/how-to-debug-an-argo-workflow-31ng" rel="nofollow noreferrer">https://dev.to/crenshaw_dev/how-to-debug-an-argo-workflow-31ng</a> yet could not get app logs.</p> <p>Basically when I run these examples am expecting spark app logs to be printed - in this case output of following Scala example</p> <p><a href="https://github.com/apache/spark/blob/master/examples/src/main/scala/org/apache/spark/examples/GroupByTest.scala" rel="nofollow noreferrer">https://github.com/apache/spark/blob/master/examples/src/main/scala/org/apache/spark/examples/GroupByTest.scala</a></p> <p>Interesting when I list PODS, I was expecting to see driver pods and executor pods but always see only one POD and it has above logs as in the image attached. <strong>Please help me to understand why logs are not generated and how can I get it?</strong></p> <pre><code>RAW LOGS $ kubectl logs spark-pi-dag-739246604 -n argo time=&quot;2021-12-10T13:28:09.560Z&quot; level=info msg=&quot;Starting Workflow Executor&quot; version=&quot;{v3.0.3 2021-05-11T21:14:20Z 02071057c082cf295ab8da68f1b2027ff8762b5a v3.0.3 clean go1.15.7 gc linux/amd64}&quot; time=&quot;2021-12-10T13:28:09.581Z&quot; level=info msg=&quot;Creating a docker executor&quot; time=&quot;2021-12-10T13:28:09.581Z&quot; level=info msg=&quot;Executor (version: v3.0.3, build_date: 2021-05-11T21:14:20Z) initialized (pod: argo/spark-pi-dag-739246604) with template:\n{\&quot;name\&quot;:\&quot;sparkpi\&quot;,\&quot;inputs\&quot;:{},\&quot;outputs\&quot;:{},\&quot;metadata\&quot;:{},\&quot;resource\&quot;:{\&quot;action\&quot;:\&quot;create\&quot;,\&quot;manifest\&quot;:\&quot;apiVersion: \\\&quot;sparkoperator.k8s.io/v1beta2\\\&quot;\\nkind: SparkApplication\\nmetadata:\\n generateName: spark-pi-dag\\nspec:\\n type: Scala\\n mode: cluster\\n image: gjeevanm/spark:v3.1.1\\n imagePullPolicy: Always\\n mainClass: org.apache.spark.examples.SparkPi\\n mainApplicationFile: local:///opt/spark/spark-examples_2.12-3.1.1-hadoop-2.7.jar\\n sparkVersion: 3.1.1\\n driver:\\n cores: 1\\n coreLimit: \\\&quot;1200m\\\&quot;\\n memory: \\\&quot;512m\\\&quot;\\n labels:\\n version: 3.0.0\\n executor:\\n cores: 1\\n instances: 1\\n memory: \\\&quot;512m\\\&quot;\\n labels:\\n version: 3.0.0\\n\&quot;},\&quot;archiveLocation\&quot;:{\&quot;archiveLogs\&quot;:true,\&quot;s3\&quot;:{\&quot;endpoint\&quot;:\&quot;minio:9000\&quot;,\&quot;bucket\&quot;:\&quot;my-bucket\&quot;,\&quot;insecure\&quot;:true,\&quot;accessKeySecret\&quot;:{\&quot;name\&quot;:\&quot;my-minio-cred\&quot;,\&quot;key\&quot;:\&quot;accesskey\&quot;},\&quot;secretKeySecret\&quot;:{\&quot;name\&quot;:\&quot;my-minio-cred\&quot;,\&quot;key\&quot;:\&quot;secretkey\&quot;},\&quot;key\&quot;:\&quot;spark-pi-dag/spark-pi-dag-739246604\&quot;}}}&quot; time=&quot;2021-12-10T13:28:09.581Z&quot; level=info msg=&quot;Loading manifest to /tmp/manifest.yaml&quot; time=&quot;2021-12-10T13:28:09.581Z&quot; level=info msg=&quot;kubectl create -f /tmp/manifest.yaml -o json&quot; time=&quot;2021-12-10T13:28:10.348Z&quot; level=info msg=argo/SparkApplication.sparkoperator.k8s.io/spark-pi-daghhl6s time=&quot;2021-12-10T13:28:10.348Z&quot; level=info msg=&quot;Starting SIGUSR2 signal monitor&quot; time=&quot;2021-12-10T13:28:10.348Z&quot; level=info msg=&quot;No output parameters&quot; </code></pre>
<p>As Michael mentioned in his answer, Argo Workflows does not know how other CRDs (such as <code>SparkApplication</code> that you used) work and thus could not pull the logs from the pods created by that particular CRD.</p> <p>However, you can add the label <code>workflows.argoproj.io/workflow: {{workflow.name}}</code> to the pods generated by <code>SparkApplication</code> to let Argo Workflows know and then use <code>argo logs -c &lt;container-name&gt;</code> to pull the logs from those pods.</p> <p>You can find an example here but Kubeflow CRD but in your case you'll want to add labels to the <code>executor</code> and <code>driver</code> to your <code>SparkApplication</code> CRD in the resource template: <a href="https://github.com/argoproj/argo-workflows/blob/master/examples/k8s-resource-log-selector.yaml" rel="nofollow noreferrer">https://github.com/argoproj/argo-workflows/blob/master/examples/k8s-resource-log-selector.yaml</a></p>
<p>For pod we keep it v1 When replicaset we keep it apps/v1.</p> <p>Question is apps/v1 contains all the objects of v1 as well or what's the hierarchy? Can someone please explain ?</p>
<p>The apiVersion is composed of two components: the<code>group</code> and the <code>version</code>.</p> <p>The <code>version</code> indicates the levels of stability and support: if version contains <code>alpha</code>, the software may contains bugs and the feature may be dropped in future release; if version contains <code>beta</code>, the feature is considered tested, and is enabled by default - the feature will not be dropped but some details may change.</p> <p>The <code>group</code> have been introduced to ease development and maintenance of k8s. The API group is also specified in REST path when accessing the k8s API. The full list of groups is located: <a href="https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.23/#-strong-api-groups-strong-" rel="nofollow noreferrer">https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.23/#-strong-api-groups-strong-</a></p> <p>So there is no hierarchy between v1 and apps/v1.</p> <p>The first API resources introduced in Kubernetes do not have groups. So you will use the <code>apiVersion</code>: <code>v1</code>. Later resources are linked to a group. For examples, <code>Jobs</code> and <code>CronJobs</code> are both in the group <code>batch</code>. So their <code>apiVersion</code> will be <code>batch/v1</code>. <code>Deployments</code> and <code>replicasets</code> are in the <code>apps</code> group, and are using <code>apiVersion</code>: <code>apps/v1</code>.</p> <p>You can obtain all api-resources using the command : <code>kubectl api-resources</code></p> <p>See also: <a href="https://kubernetes.io/docs/reference/using-api/#api-groups" rel="nofollow noreferrer">https://kubernetes.io/docs/reference/using-api/#api-groups</a></p>
<p>Now I am using <code>HostSNI(</code>*<code>)</code> to mapping the TCP service like <code>mysql\postgresql...</code> in traefik 2.2.1 in Kubernetes cluster v1.18 . beacuse I am in my local machine and did not have a valid certification. This is the config:</p> <pre><code>apiVersion: traefik.containo.us/v1alpha1 kind: IngressRouteTCP metadata: name: mysql-ingress-tcp-route namespace: middleware spec: entryPoints: - mysql routes: - match: HostSNI(`*`) services: - name: report-mysqlha port: 3306 </code></pre> <p>is config works fine in my local machine. But I still want to know the side effect to using <code>HostSNI(</code><em><code>)</code> mapping stratege. What is the disadvantege to using <code>HostSNI(</code></em><code>)</code> not a domain name? Is it possible to using a fake domain name in my local machine?</p>
<p>For those needing an example of TCP with TLS passthrough and SNI routing</p> <pre><code>apiVersion: traefik.containo.us/v1alpha1 kind: IngressRouteTCP metadata: name: test-https namespace: mynamespace spec: entryPoints: - websecure # maps to port 443 by default routes: - match: HostSNI(`my.domain.com`) services: - name: myservice port: 443 tls: passthrough: true </code></pre>
<p>I am writing a script, where I want to restart kubernetes pods with the scale-down scale-up method</p> <pre><code>kubectl scale --replicas=0 myPod -n myNamespace kubectl scale --replicas=3 myPod -n myNamespace </code></pre> <p>I would like the script to wait until the pods are <code>Running</code> - so I thought something like</p> <pre><code>while kubectl get pods --field-selector=status.phase=Running -n myNameSpace | grep -c myPod = 3; do sleep 1 echo &quot;.&quot; done </code></pre> <p>could work - but no dice. The <code>= 3</code> part doesn't work. I can't just use</p> <pre><code>while kubectl get pods --field-selector=status.phase!=Running -n myNameSpace | grep -c myPod &gt; /dev/null </code></pre> <p>since the pods start in sequence, and I could get unlucky by querying just as one pod deployed, and others didn't even start.</p> <p>How can I ensure that the script continues only after all 3 of the pods are <code>Running</code>?</p>
<p>Write your condition in [ ] and get the value of command with ` or $. for example in your case:</p> <pre><code>while [ &quot;$(kubectl get pods --field-selector=status.phase=Running -n myNameSpace | grep -c myPod)&quot; != 3 ] do sleep 1 echo &quot;wait&quot; done echo &quot;All three pods is running and continue your script&quot; </code></pre>
<p>I want to execute a task in Argo workflow if a string starts with a particular substring. For example, my string is <code>tests/dev-or.yaml</code> and I want to execute task if my string starts with <code>tasks/</code></p> <p>Here is my workflow but the condition is not being validated properly</p> <pre><code>apiVersion: argoproj.io/v1alpha1 kind: Workflow metadata: generateName: conditional- spec: entrypoint: conditional-example arguments: parameters: - name: should-print value: &quot;tests/dev-or.yaml&quot; templates: - name: conditional-example inputs: parameters: - name: should-print steps: - - name: print-hello template: whalesay when: &quot;{{inputs.parameters.should-print }} startsWith 'tests/'&quot; - name: whalesay container: image: docker/whalesay:latest command: [sh, -c] args: [&quot;cowsay hello&quot;] </code></pre> <p>Below is the error it is giving when I run the workflow</p> <pre><code>WorkflowFailed 7s workflow-controller Invalid 'when' expression 'tests/dev-or.yaml startsWith 'tests/'': Unable to access unexported field 'yaml' in token 'or.yaml' </code></pre> <p>Seems it is not accepting <code>-</code>, <code>.yaml</code> and <code>/</code> while evaluating the when condition.</p> <p>Any mistake am making in my workflow? What's the right way to use this condition?</p>
<p>tl;dr - use this: <code>when: &quot;'{{inputs.parameters.should-print}}' =~ '^tests/'&quot;</code></p> <p>Parameter substitution happens before the <code>when</code> expression is evaluated. So the when expression is actually <code>tests/dev-or.yaml startsWith 'tests/'</code>. As you can see, the first string needs quotation marks.</p> <p>But even if you had <code>when: &quot;'{{inputs.parameters.should-print}}' startsWith 'tests/'&quot;</code> (single quotes added), the expression would fail with this error: <code>Cannot transition token types from STRING [tests/dev-or.yaml] to VARIABLE [startsWith]</code>.</p> <p>Argo Workflows <a href="https://github.com/argoproj/argo-workflows/tree/master/examples#conditionals" rel="nofollow noreferrer">conditionals</a> are evaluated as <a href="https://github.com/Knetic/govaluate" rel="nofollow noreferrer">govaluate</a> expressions. govaluate <a href="https://github.com/Knetic/govaluate/blob/master/MANUAL.md#built-in-functions" rel="nofollow noreferrer">does not have any built-in functions</a>, and Argo Workflows does not augment it with any functions. So <code>startsWith</code> is not defined.</p> <p>Instead, you should use govaluate's <a href="https://github.com/Knetic/govaluate/blob/master/MANUAL.md#regex-comparators--" rel="nofollow noreferrer">regex comparator</a>. The expression will look like this: <code>when: &quot;'{{inputs.parameters.should-print}}' =~ '^tests/'&quot;</code>.</p> <p>This is the functional Workflow:</p> <pre class="lang-yaml prettyprint-override"><code>apiVersion: argoproj.io/v1alpha1 kind: Workflow metadata: generateName: conditional- spec: entrypoint: conditional-example arguments: parameters: - name: should-print value: &quot;tests/dev-or.yaml&quot; templates: - name: conditional-example inputs: parameters: - name: should-print steps: - - name: print-hello template: whalesay when: &quot;'{{inputs.parameters.should-print}}' =~ '^tests/'&quot; - name: whalesay container: image: docker/whalesay:latest command: [sh, -c] args: [&quot;cowsay hello&quot;] </code></pre>
<p>EDIT: It was a config error, I was setting wrong kv name :/</p> <p>As said in title I'm facing an issue with secret creation using SecretProviderClass.</p> <p>I've created my aks and my kv (and filled it) on azure. then I'll proceed to follow <a href="https://learn.microsoft.com/en-us/azure/aks/csi-secrets-store-driver" rel="nofollow noreferrer">those</a> steps using a user-assigned managed identity</p> <p>but no <code>secret</code> resource get created and pods got stuck on creation with mount failure.</p> <p>those are the steps I followed</p> <pre><code>az extension add --name aks-preview az extension update --name aks-preview az aks enable-addons --addons azure-keyvault-secrets-provider -g $RESOURCE_GROUP -n $AKS_CLUSTER az aks update -g $RESOURCE_GROUP -n $AKS_CLUSTER --enable-managed-identity --disable-secret-rotation $AKS_ID = (az aks show -g $RESOURCE_GROUP -n $AKS_CLUSTER --query identityProfile.kubeletidentity.clientId -o tsv) az keyvault set-policy -n $AZUREKEYVAULT --secret-permissions get --spn $AKS_ID </code></pre> <p>the SecretProviderClass manifest I'm using</p> <pre><code>apiVersion: secrets-store.csi.x-k8s.io/v1 kind: SecretProviderClass metadata: name: azure-kvname spec: provider: azure secretObjects: - secretName: akvsecrets type: Opaque data: - objectName: AzureSignalRConnectionString key: AzureSignalRConnectionString - objectName: BlobStorageConnectionString key: BlobStorageConnectionString - objectName: SqlRegistryConnectionString key: SqlRegistryConnectionString - objectName: TokenSymmetricKey key: TokenSymmetricKey parameters: useVMManagedIdentity: &quot;true&quot; userAssignedIdentityID: XXX # VMSS UserAssignedIdentity keyvaultName: &quot;sampleaks001&quot; # the name of the KeyVault objects: | array: - | objectName: AzureSignalRConnectionString objectType: secret - | objectName: BlobStorageConnectionString objectType: secret - | objectName: SqlRegistryConnectionString objectType: secret - | objectName: TokenSymmetricKey objectType: secret resourceGroup: sample # [REQUIRED for version &lt; 0.0.4] the resource group of the KeyVault subscriptionId: XXXX # [REQUIRED for version &lt; 0.0.4] the subscription ID of the KeyVault tenantId: XXX # the tenant ID of the KeyVault </code></pre> <p>and the deploy manifest</p> <pre><code>apiVersion: apps/v1 kind: Deployment metadata: name: trm-api-test namespace: default spec: replicas: 1 selector: matchLabels: app: trm-api-test template: metadata: labels: app: trm-api-test spec: nodeSelector: &quot;kubernetes.io/os&quot;: linux containers: - name: trm-api-test image: nginx resources: requests: cpu: 100m memory: 128Mi limits: cpu: 250m memory: 256Mi ports: - containerPort: 80 env: - name: AzureSignalRConnectionString valueFrom: secretKeyRef: name: akvsecrets key: AzureSignalRConnectionString - name: TokenSymmetricKey valueFrom: secretKeyRef: name: akvsecrets key: TokenSymmetricKey - name: BlobStorageConnectionString valueFrom: secretKeyRef: name: akvsecrets key: BlobStorageConnectionString - name: SqlRegistryConnectionString valueFrom: secretKeyRef: name: akvsecrets key: SqlRegistryConnectionString volumeMounts: - name: secrets-store-inline mountPath: &quot;/mnt/secrets-store&quot; readOnly: true volumes: - name: secrets-store-inline csi: driver: secrets-store.csi.k8s.io readOnly: true volumeAttributes: secretProviderClass: &quot;azure-kvname&quot; --- apiVersion: v1 kind: Service metadata: name: trm-api-service-test namespace: default spec: type: ClusterIP selector: app: trm-api-test ports: - port: 80 targetPort: 80 protocol: TCP </code></pre> <p>I'm sure I'm missing something, but can't understand what. Thanks in advance!</p>
<p>you are using the clientId, but it should be the objectId form the kubelet identity:</p> <pre><code>export KUBE_ID=$(az aks show -g &lt;resource group&gt; -n &lt;aks cluster name&gt; --query identityProfile.kubeletidentity.objectId -o tsv) export AKV_ID=$(az keyvault show -g &lt;resource group&gt; -n &lt;akv name&gt; --query id -o tsv) az role assignment create --assignee $KUBE_ID --role &quot;Key Vault Secrets Officer&quot; --scope $AKV_ID </code></pre> <p>This is a working SecretProviderClass i am using (adjusted to your config):</p> <pre><code>apiVersion: secrets-store.csi.x-k8s.io/v1 kind: SecretProviderClass metadata: name: azure-kvname spec: provider: azure secretObjects: - data: - objectName: AzureSignalRConnectionString key: AzureSignalRConnectionString - objectName: BlobStorageConnectionString key: BlobStorageConnectionString - objectName: SqlRegistryConnectionString key: SqlRegistryConnectionString - objectName: TokenSymmetricKey key: TokenSymmetricKey secretName: akvsecrets type: Opaque parameters: usePodIdentity: &quot;false&quot; useVMManagedIdentity: &quot;true&quot; userAssignedIdentityID: XXX # Kubelet Client Id ( Nodepool Managed Idendity ) keyvaultName: &quot;sampleaks001&quot; # the name of the KeyVault tenantId: XXX # the tenant ID of the KeyVault objects: | array: - | objectName: AzureSignalRConnectionString objectAlias: AzureSignalRConnectionString objectType: secret - | objectName: BlobStorageConnectionString objectAlias: BlobStorageConnectionString objectType: secret - | objectName: SqlRegistryConnectionString objectAlias: SqlRegistryConnectionString objectType: secret - | objectName: TokenSymmetricKey objectAlias: TokenSymmetricKey objectType: secret </code></pre> <p>You can also check documentation <a href="https://azure.github.io/secrets-store-csi-driver-provider-azure/configurations/sync-with-k8s-secrets/" rel="nofollow noreferrer">here</a> as you will find better examples as on the Azure Docs.</p>
<p>I try to deploy mongodb with helm and it gives this error:</p> <pre><code>mkdir: cannot create directory /bitnami/mongodb/data : permision denied. </code></pre> <p>I also tried this solution:</p> <pre><code>sudo chown -R 1001 /tmp/mongo </code></pre> <p>but it says no this directory.</p>
<p>You have permission denied on <code>/bitnami/mongodb/data</code> and you are trying to modify another path: <code>/tmp/mongo</code>. It is possible that you do not have such a directory at all. You need to change the owner of the resource for which you don't have permissions, not random (non-related) paths :)</p> <p>You've probably seen <a href="https://github.com/bitnami/bitnami-docker-mongodb/issues/177" rel="nofollow noreferrer">this github issue</a> and this answer:</p> <blockquote> <p>You are getting that error message because the container can't mount the /tmp/mongo directory you specified in the docker-compose.yml file.</p> <p>As you can see in <a href="https://github.com/bitnami/bitnami-docker-mongodb#366-r16-and-411-r9" rel="nofollow noreferrer">our changelog</a>, the container was migrated to the non-root user approach, that means that the user <code>1001</code> needs read/write permissions in the /tmp/mongo folder so it can be mounted and used. Can you modify the permissions in your local folder and try to launch the container again?</p> </blockquote> <pre><code>sudo chown -R 1001 /tmp/mongo </code></pre> <p>This method will work if you are going to mount the <code>/tmp/mongo</code> folder, which is actually not quite a common behavior. Look for another answer:</p> <blockquote> <p>Please note that mounting host path volumes is not the usual way to work with these containers. If using docker-compose, it would be using docker volumes (which already handle the permission issue), the same would apply with Kubernetes and the MongoDB helm chart, which would use the <code>securityContext</code> section to ensure the proper permissions.</p> </blockquote> <p>In your situation, you'll just have change owner to the path <code>/bitnami/mongodb/data</code> or to use <a href="https://kubernetes.io/docs/tasks/configure-pod-container/security-context/" rel="nofollow noreferrer">Security Context</a> on your Helm chart and everything should work out for you.</p> <p>Probably <a href="https://kubernetes.io/docs/tasks/configure-pod-container/security-context/#configure-volume-permission-and-ownership-change-policy-for-pods" rel="nofollow noreferrer">here</a> you can find the most interesting part with example context:</p> <pre class="lang-yaml prettyprint-override"><code>securityContext: runAsUser: 1000 runAsGroup: 3000 fsGroup: 2000 fsGroupChangePolicy: &quot;OnRootMismatch&quot; </code></pre>
<p>A Kubelet has several endpoint paths it listens on, such as <code>/metrics</code>, <code>/metrics/cadvisor</code>, <code>/logs</code>, etc. One can easily query these endpoints by running <code>kubectl get --raw /api/v1/nodes/&lt;node-name&gt;/proxy/&lt;path&gt;</code> (after running <code>kubectl proxy</code>).</p> <p>My question is how can one obtain the list of all these paths that Kubelet is serving? A list can be found in the Kubelet's own code <a href="https://github.com/kubernetes/kubernetes/blob/master/pkg/kubelet/server/server.go#L84" rel="nofollow noreferrer">here</a>, but that's just a subset. There's for example <code>/pods</code> which is not on that list, but defined further down in <a href="https://github.com/kubernetes/kubernetes/blob/master/pkg/kubelet/server/server.go#L342" rel="nofollow noreferrer">the code as well</a>. But there are others that aren't explicitly listed in the code, such as <code>/healthz</code>, which one guesses by looking at <a href="https://github.com/kubernetes/kubernetes/blob/master/pkg/kubelet/server/server.go#L333" rel="nofollow noreferrer">other lines of the code</a>. I'd also venture to believe that other addons or 3rd party products could result in the Kubelet exposing more paths.</p> <p>I tried using <code>/healthz?verbose</code>, but it only returns basic information, and nothing near a list of paths:</p> <pre><code>[+]ping ok [+]log ok [+]syncloop ok healthz check passed </code></pre> <p>The Kubernetes API Server returns a very nice list of paths using <code>kubectl get --raw /</code> as seen below (truncated due to length). Is there something equivalent for Kubelet's own paths?</p> <pre><code>{ &quot;paths&quot;: [ &quot;/.well-known/openid-configuration&quot;, &quot;/api&quot;, &quot;/api/v1&quot;, &quot;/apis&quot;, &quot;/apis/&quot;, &quot;/apis/admissionregistration.k8s.io&quot;, &quot;/apis/admissionregistration.k8s.io/v1&quot;, &quot;/apis/admissionregistration.k8s.io/v1beta1&quot;, &quot;/apis/apiextensions.k8s.io&quot;, &quot;/apis/apiextensions.k8s.io/v1&quot;, &quot;/apis/apiextensions.k8s.io/v1beta1&quot;, &quot;/apis/apiregistration.k8s.io&quot;, &quot;/apis/apiregistration.k8s.io/v1&quot;, &quot;/apis/apiregistration.k8s.io/v1beta1&quot;, &quot;/apis/apps&quot;, &quot;/apis/apps/v1&quot;, &quot;/apis/authentication.k8s.io&quot;, &quot;/apis/authentication.k8s.io/v1&quot;, &quot;/apis/authentication.k8s.io/v1beta1&quot;, &quot;/apis/authorization.k8s.io&quot;, &quot;/apis/authorization.k8s.io/v1&quot;, &quot;/apis/authorization.k8s.io/v1beta1&quot;, &quot;/apis/autoscaling&quot;, &quot;/apis/autoscaling/v1&quot;, &quot;/apis/autoscaling/v2beta1&quot;, &quot;/apis/autoscaling/v2beta2&quot;, &quot;/apis/batch&quot;, &quot;/apis/batch/v1&quot;, &quot;/apis/batch/v1beta1&quot;, &quot;/apis/certificates.k8s.io&quot;, .... </code></pre>
<p>Based on the information from different sources, below provided some endpoints for kubelet.</p> <p>From the code of <a href="https://github.com/kubernetes/kubernetes/blob/release-1.23/pkg/kubelet/server/server.go#L85" rel="nofollow noreferrer">kubelet server</a>:</p> <pre><code>/metrics /metrics/cadvisor /metrics/resource /metrics/probes /stats/ /logs/ /debug/pprof/ /debug/flags/v </code></pre> <p><a href="https://github.com/kubernetes/kubernetes/blob/release-1.23/pkg/kubelet/server/server.go#L342" rel="nofollow noreferrer">also</a>:</p> <pre><code>/pods/* </code></pre> <p><a href="https://github.com/kubernetes/kubernetes/blob/release-1.23/pkg/kubelet/server/server.go#L409" rel="nofollow noreferrer">and</a>:</p> <pre><code>/run/* /exec/* /attach/* /portForward/* /containerLogs/* /configz /runningpods/ </code></pre> <p><a href="https://github.com/kubernetes/kubernetes/blob/release-1.23/pkg/kubelet/server/auth_test.go#L108" rel="nofollow noreferrer">here</a>:</p> <pre><code>&quot;/attach/{podNamespace}/{podID}/{containerName}&quot;: &quot;proxy&quot;, &quot;/attach/{podNamespace}/{podID}/{uid}/{containerName}&quot;: &quot;proxy&quot;, &quot;/configz&quot;: &quot;proxy&quot;, &quot;/containerLogs/{podNamespace}/{podID}/{containerName}&quot;: &quot;proxy&quot;, &quot;/debug/flags/v&quot;: &quot;proxy&quot;, &quot;/debug/pprof/{subpath:*}&quot;: &quot;proxy&quot;, &quot;/exec/{podNamespace}/{podID}/{containerName}&quot;: &quot;proxy&quot;, &quot;/exec/{podNamespace}/{podID}/{uid}/{containerName}&quot;: &quot;proxy&quot;, &quot;/healthz&quot;: &quot;proxy&quot;, &quot;/healthz/log&quot;: &quot;proxy&quot;, &quot;/healthz/ping&quot;: &quot;proxy&quot;, &quot;/healthz/syncloop&quot;: &quot;proxy&quot;, &quot;/logs/&quot;: &quot;log&quot;, &quot;/logs/{logpath:*}&quot;: &quot;log&quot;, &quot;/metrics&quot;: &quot;metrics&quot;, &quot;/metrics/cadvisor&quot;: &quot;metrics&quot;, &quot;/metrics/probes&quot;: &quot;metrics&quot;, &quot;/metrics/resource&quot;: &quot;metrics&quot;, &quot;/pods/&quot;: &quot;proxy&quot;, &quot;/portForward/{podNamespace}/{podID}&quot;: &quot;proxy&quot;, &quot;/portForward/{podNamespace}/{podID}/{uid}&quot;: &quot;proxy&quot;, &quot;/run/{podNamespace}/{podID}/{containerName}&quot;: &quot;proxy&quot;, &quot;/run/{podNamespace}/{podID}/{uid}/{containerName}&quot;: &quot;proxy&quot;, &quot;/runningpods/&quot;: &quot;proxy&quot;, &quot;/stats/&quot;: &quot;stats&quot;, &quot;/stats/summary&quot;: &quot;stats&quot; </code></pre> <p>The asterisk indicates that full request should be updated with some parameters. For example for <code>/containerLogs/*</code> with adding <code>/{podNamespace}/{podID}/{containerName}</code>:</p> <pre><code>kubectl get --raw /api/v1/nodes/&lt;node-name&gt;/proxy/containerLogs/{podNamespace}/{podID}/{containerName} </code></pre> <p>Some information <a href="https://kubernetes.io/docs/reference/command-line-tools-reference/kubelet-authentication-authorization/#kubelet-authorization" rel="nofollow noreferrer">from kubernetes site about kubelet API</a>:</p> <pre><code>/stats/* /metrics/* /logs/* /spec/* </code></pre> <p>Also you can look at this page from <a href="https://github.com/cyberark/kubeletctl/blob/master/API_TABLE.md" rel="nofollow noreferrer">kubeletctl</a>. It's a bit outdated, but may provide some useful information about the kubelet API and HTTP requests.</p> <p>And this <a href="https://www.deepnetwork.com/blog/2020/01/13/kubelet-api.html" rel="nofollow noreferrer">article about the kubelet API</a> is good too.</p> <p>In any case, it is recommended to check the kubernetes documentation before using it to see what is deprecated in current / old releases.</p> <p>p.s. If you are interested in this topic, you can create an issue on <a href="https://github.com/kubernetes/kubernetes/issues" rel="nofollow noreferrer">kubernetes GitHub page</a> to propose an improvement for kubelet documentation.</p>
<p>I have a GKE cluster which doesn't scale up when a particular deployment needs more resources. I've checked the cluster autoscaler logs and it has entries with this error: <code>no.scale.up.nap.pod.zonal.resources.exceeded</code>. The <a href="https://cloud.google.com/kubernetes-engine/docs/how-to/cluster-autoscaler-visibility#noscaleup-reasons" rel="nofollow noreferrer">documentation</a> for this error says:</p> <blockquote> <p>Node auto-provisioning did not provision any node group for the Pod in this zone because doing so would violate resource limits.</p> </blockquote> <p>I don't quite understand which resource limits are mentiond in the documentation and why it prevents node-pool from scaling up?</p> <p>If I scale cluster up manually - deployment pods are scaled up and everything works as expected, so, seems it's not a problem with project quotas.</p>
<ul> <li><p><a href="https://cloud.google.com/kubernetes-engine/docs/how-to/node-auto-provisioning#limits_for_clusters" rel="nofollow noreferrer">Limits for clusters</a> that you define are enforced based on the total CPU and memory resources used across your cluster, not just auto-provisioned pools.</p> </li> <li><p>When you are not using node auto provisioning (NAP), <a href="https://cloud.google.com/kubernetes-engine/docs/how-to/node-auto-provisioning#disable" rel="nofollow noreferrer">disable node auto provisioning feature for the cluster.</a></p> </li> <li><p>When you are using NAP, then <a href="https://cloud.google.com/kubernetes-engine/docs/how-to/node-auto-provisioning#enable" rel="nofollow noreferrer">update the cluster wide resource</a> limits defined in NAP for the cluster .</p> </li> <li><p>Try a workaround by specifying the <a href="https://cloud.google.com/kubernetes-engine/docs/how-to/node-auto-provisioning#custom_machine_family" rel="nofollow noreferrer">machine type explicitly</a> in the workload spec. Ensure to use a supported machine family with GKE node auto-provisioning</p> </li> </ul>