prompt
stringlengths
65
38.7k
response
stringlengths
41
29.1k
<p>Me and my colleague have an issue, whenever I type</p> <pre class="lang-sh prettyprint-override"><code>helm install mystuff-nginx ingress-nginx/ingress-nginx --version 3.26.0 </code></pre> <p>I have successfully deployed nginx in version <code>3.26.0</code>, however when he runs the same command on his laptop just with different name <code>mystuff-nginx-1</code> he installs it in the lastest version <code>4.0.1</code>, and idea what's going on ? We have helm, gcloud and kubectl in the same versions, even redownloaded the binary.</p> <p>and we know the version is available</p> <pre class="lang-sh prettyprint-override"><code>MacBook-Pro-2% helm search repo -l ingress-nginx/ingress-nginx ingress-nginx/ingress-nginx 4.0.2 1.0.1 Ingress controller for Kubernetes using NGINX a... ingress-nginx/ingress-nginx 4.0.1 1.0.0 Ingress controller for Kubernetes using NGINX a... ingress-nginx/ingress-nginx 3.37.0 0.49.1 Ingress controller for Kubernetes using NGINX a... ingress-nginx/ingress-nginx 3.36.0 0.49.0 Ingress controller for Kubernetes using NGINX a... ingress-nginx/ingress-nginx 3.35.0 0.48.1 Ingress controller for Kubernetes using NGINX a... ... ingress-nginx/ingress-nginx 3.26.0 0.44.0 Ingress controller for Kubernetes using NGINX a... </code></pre>
<p>According to Helm's documentation:</p> <pre><code>helm install [NAME] [CHART] [flags] </code></pre> <p>The version flag:</p> <pre><code>--version string specify a version constraint for the chart version to use. This constraint can be a specific tag (e.g. 1.1.1) or it may reference a valid range (e.g. ^2.0.0). If this is not specified, the latest version is used </code></pre> <p>So, you can try:</p> <pre><code>$ helm install nginx-ingress ingress-nginx/ingress-nginx --version &quot;3.26.0&quot; </code></pre> <p>helm list:</p> <pre><code>NAME NAMESPACE REVISION UPDATED STATUS CHART APP VERSION nginx-ingress default 1 2021-09-24 09:44:54.261772858 -0300 -03 deployed ingress-nginx-3.26.0 0.44.0 </code></pre> <p>I used the helm version v3.5.4 and a k3d cluster to test.</p>
<p>I would like to replicate volume data among multiple nodes for redundancy.</p> <p>I saw that the CSI drivers support <a href="https://kubernetes.io/docs/concepts/storage/volume-snapshots/" rel="nofollow noreferrer">snapshots</a> but I was looking for something more <a href="https://linuxize.com/post/how-to-use-rsync-for-local-and-remote-data-transfer-and-synchronization/" rel="nofollow noreferrer">rsync</a>.</p> <p>Any help is greatly appreciated.</p>
<p>Having analysed the comments it looks like one of the options would be to deploy <code>rsync</code> as a container.</p> <p>For example <code>rsync</code> deployments one can visit below links:</p> <ul> <li><a href="https://hub.docker.com/r/steveltn/rsync-deploy/" rel="nofollow noreferrer">rsync-deploy</a></li> <li><a href="https://medium.com/jaequery/a-simple-docker-deployment-with-only-rsync-and-ssh-b283ad5129d1" rel="nofollow noreferrer">A simple Docker deployment with just rsync and SSH</a></li> </ul>
<p>You can find mentions of that resource in the following Questions: <a href="https://stackoverflow.com/questions/53230623/forbidden-to-access-kubernetes-api-server">1</a>, <a href="https://stackoverflow.com/questions/49396607/where-can-i-get-a-list-of-kubernetes-api-resources-and-subresources">2</a>. But I am not able to figure out what is the use of this resource.</p>
<p>Yes, it's true, the provided (in comments) link to the documentation might be confusing so let me try to clarify you this.</p> <p>As per <a href="https://kubernetes.io/docs/tasks/access-application-cluster/access-cluster/#so-many-proxies" rel="nofollow noreferrer">the official documentation</a> the apiserver proxy:</p> <blockquote> <ul> <li>is a bastion built into the apiserver</li> <li>connects a user outside of the cluster to cluster IPs which otherwise might not be reachable</li> <li>runs in the apiserver processes</li> <li>client to proxy uses HTTPS (or http if apiserver so configured)</li> <li>proxy to target may use HTTP or HTTPS as chosen by proxy using available information</li> <li><strong>can be used to reach a Node, Pod, or Service</strong></li> <li>does load balancing when used to reach a Service</li> </ul> </blockquote> <p>So answering your question - setting <code>node/proxy</code>resource in <code>clusterRole</code> allows k8s services access kubelet endpoints on specific node and path.</p> <p>As per <a href="https://kubernetes.io/docs/concepts/architecture/control-plane-node-communication/#control-plane-to-node" rel="nofollow noreferrer">the official documentation</a>:</p> <blockquote> <p>There are two primary communication paths from the control plane (apiserver) to the nodes. The first is from the apiserver to the kubelet process which runs on each node in the cluster. The second is from the apiserver to any node, pod, or service through the apiserver's proxy functionality.</p> </blockquote> <p>The connections from the apiserver to the kubelet are used for:</p> <ul> <li>fetching logs for pods</li> <li>attaching (through kubectl) to running pods</li> <li>providing the kubelet's port-forwarding functionality</li> </ul> <p>Here are also few running examples of using <code>node/proxy</code> resource in <code>clusterRole</code>:</p> <ol> <li><a href="https://devopscube.com/setup-prometheus-monitoring-on-kubernetes/" rel="nofollow noreferrer">How to Setup Prometheus Monitoring On Kubernetes Cluster</a></li> <li><a href="https://acloudguru.com/blog/engineering/running-prometheus-on-kubernetes" rel="nofollow noreferrer">Running Prometheus on Kubernetes</a></li> </ol>
<p>I have a following <code>kubectl</code> command to obtain the credentials for my Azure cluster:</p> <pre><code>kubectl config set-credentials token --token=&quot;$(cat /var/run/secrets/kubernetes.io/serviceaccount/token)&quot; --auth-provider=azure </code></pre> <p>However, this throws the following error:</p> <pre><code>creating a new azure token source for device code authentication: client-id is empty </code></pre> <p>After doing some investigation, I found out that we need to supply additional information for <code>client id</code>, <code>tenant id</code>, and <code>apiserver id</code>:</p> <pre><code>kubectl config \ set-credentials &quot;&lt;username&gt;&quot; \ --auth-provider=azure \ --auth-provider-arg=environment=AzurePublicCloud \ --auth-provider-arg=client-id=&lt;kubectl-app-id&gt; \ --auth-provider-arg=tenant-id=&lt;tenant-id&gt; \ --auth-provider-arg=apiserver-id=&lt;apiserver-app-id&gt; </code></pre> <p>How should we obtain the <code>client id</code>, <code>tenant id</code>, and <code>apiserver id</code> details?</p>
<p>Command <code>kubectl config set-credentials</code> is used to <a href="https://kubernetes.io/docs/tasks/access-application-cluster/configure-access-multiple-clusters/#define-clusters-users-and-contexts" rel="nofollow noreferrer">set credentials</a> as the name implies. If you want to get some information from your cluster you have several ways to do. For example you can use Azure Portal. Everything is described <a href="https://www.inkoop.io/blog/how-to-get-azure-api-credentials/" rel="nofollow noreferrer">in this article</a>. For example to get Tenant ID you need to:</p> <blockquote> <ol> <li><a href="https://portal.azure.com/" rel="nofollow noreferrer">Login into your azure account</a>.</li> <li>Select azure active directory in the left sidebar.</li> <li>Click properties.</li> <li>Copy the directory ID.</li> </ol> </blockquote> <p>To get Client ID:</p> <blockquote> <ol> <li><a href="https://portal.azure.com/" rel="nofollow noreferrer">Login into your azure account</a>.</li> <li>Select azure active directory in the left sidebar.</li> <li>Click Enterprise applications.</li> <li>Click All applications.</li> <li>Select the application which you have created.</li> <li>Click Properties.</li> <li>Copy the Application ID .</li> </ol> </blockquote> <p>To get Client Secret:</p> <blockquote> <ol> <li><a href="https://portal.azure.com/" rel="nofollow noreferrer">Login into your azure account</a>.</li> <li>Select azure active directory in the left sidebar.</li> <li>Click App registrations.</li> <li>Select the application which you have created.</li> <li>Click on All settings.</li> <li>Click on Keys.</li> <li>Type Key description and select the Duration.</li> <li>Click save.</li> <li>Copy and store the key value. You won't be able to retrieve it after you leave this page.</li> </ol> </blockquote> <p>You can also find these informations using cli based on <a href="https://learn.microsoft.com/en-us/cli/azure/ad/app/credential?view=azure-cli-latest#az_ad_app_credential_list" rel="nofollow noreferrer">oficial documentation</a>.</p> <p>You can also find additional example for <a href="https://learn.microsoft.com/en-us/azure/active-directory/fundamentals/active-directory-how-to-find-tenant" rel="nofollow noreferrer">Tenant ID</a> (example with Azure portal and cli options):</p> <pre><code>az login az account list az account tenant list </code></pre>
<p>In K8s, every cluster has a set of nodes, some are master and others are worker nodes. How can we know if a node is a master or a worker?</p>
<p>In general, the easiest way to check if node is master or worker is to check if it has label <code>node-role.kubernetes.io/control-plane</code> (<a href="https://v1-20.docs.kubernetes.io/docs/setup/release/notes/#urgent-upgrade-notes" rel="noreferrer">or before Kubernetes <code>v1.20</code></a>: <code>node-role.kubernetes.io/master</code>):</p> <p>Since Kubernetes <code>v1.20</code>:</p> <pre><code>kubectl get nodes -l 'node-role.kubernetes.io/control-plane' </code></pre> <p>Before Kubernetes <code>v1.20</code>:</p> <pre><code>kubectl get nodes -l 'node-role.kubernetes.io/master' </code></pre> <p>To get workers we can use negation for above expressions (since Kubernetes <code>v1.20</code>):</p> <pre><code>kubectl get nodes -l '!node-role.kubernetes.io/control-plane' </code></pre> <p>Before Kubernetes <code>v1.20</code>:</p> <pre><code>kubectl get nodes -l '!node-role.kubernetes.io/master' </code></pre> <p>Another approach is to use command <code>kubectl cluster-info</code> which will print IP address of the <code>control-plane</code>:</p> <pre><code>Kubernetes control plane is running at https://{ip-address-of-the-control-plane}:8443 </code></pre> <p>Keep in mind that for some cloud provided solutions it may work totally different. For example, <a href="https://cloud.google.com/kubernetes-engine/docs/concepts/cluster-architecture" rel="noreferrer">in GKE, nodes don't have any roles by default and IP address returned by <code>kubectl cluster-info</code> is address of the API Server</a>, not listed in <code>kubectl get nodes</code> command so always remember to double-check docs provided by your Kubernetes cluster provider.</p>
<p>How do I solve this problem?</p> <pre><code>$ go mod init $ go get k8s.io/kubernetes@v1.15.5 go: k8s.io/kubernetes@v1.15.5 requires k8s.io/api@v0.0.0: reading k8s.io/api/go.mod at revision v0.0.0: unknown revision v0.0.0 </code></pre> <p>Environment is:<br> <code>go 1.13</code><br /> <code>ubuntu 16.04</code></p>
<p>Go to version go1.16.7 linux/amd64.</p> <p>This issue occurs because the dependency for kubernetes requires k8s.io/api v0.0.0 which is not present- <a href="https://github.com/kubernetes/kubernetes/blob/ddc4ed03657d6c8c009a5d915265d00cadcb634c/go.mod#L155" rel="nofollow noreferrer">https://github.com/kubernetes/kubernetes/blob/ddc4ed03657d6c8c009a5d915265d00cadcb634c/go.mod#L155</a></p> <p>So we have to find the specific versions for what we require This dependency list fixed issue for me.</p> <pre><code>require github.com/GoogleCloudPlatform/spark-on-k8s-operator v0.0.0-20210902044020-c6c97a176521 replace ( k8s.io/api =&gt; k8s.io/api v0.19.6 k8s.io/apiextensions-apiserver =&gt; k8s.io/apiextensions-apiserver v0.19.6 k8s.io/apimachinery =&gt; k8s.io/apimachinery v0.19.6 k8s.io/apiserver =&gt; k8s.io/apiserver v0.19.6 k8s.io/cli-runtime =&gt; k8s.io/cli-runtime v0.19.6 k8s.io/client-go =&gt; k8s.io/client-go v0.19.6 k8s.io/cloud-provider =&gt; k8s.io/cloud-provider v0.19.6 k8s.io/cluster-bootstrap =&gt; k8s.io/cluster-bootstrap v0.19.6 k8s.io/code-generator =&gt; k8s.io/code-generator v0.19.6 k8s.io/component-base =&gt; k8s.io/component-base v0.19.6 k8s.io/cri-api =&gt; k8s.io/cri-api v0.19.6 k8s.io/csi-translation-lib =&gt; k8s.io/csi-translation-lib v0.19.6 k8s.io/kube-aggregator =&gt; k8s.io/kube-aggregator v0.19.6 k8s.io/kube-controller-manager =&gt; k8s.io/kube-controller-manager v0.19.6 k8s.io/kube-proxy =&gt; k8s.io/kube-proxy v0.19.6 k8s.io/kube-scheduler =&gt; k8s.io/kube-scheduler v0.19.6 k8s.io/kubectl =&gt; k8s.io/kubectl v0.19.6 k8s.io/kubelet =&gt; k8s.io/kubelet v0.19.6 k8s.io/legacy-cloud-providers =&gt; k8s.io/legacy-cloud-providers v0.19.6 k8s.io/metrics =&gt; k8s.io/metrics v0.19.6 k8s.io/sample-apiserver =&gt; k8s.io/sample-apiserver v0.19.6 ) </code></pre>
<p>I'm trying to deploy traefik in Kubernetes with minikube. The deployment works well, the pod starts but when I look into pod logs, I get this :</p> <pre><code>Failed to list *v1beta1.Ingress: the server could not find the requested resource (get ingresses.extensions) </code></pre> <p>My current kubectl &amp; kubernetes server versions are :</p> <pre><code>kubectl version Client Version: version.Info{Major:&quot;1&quot;, Minor:&quot;22&quot;, GitVersion:&quot;v1.22.1&quot;, GitCommit:&quot;632ed300f2c34f6d6d15ca4cef3d3c7073412212&quot;, GitTreeState:&quot;clean&quot;, BuildDate:&quot;2021-08-19T15:45:37Z&quot;, GoVersion:&quot;go1.16.7&quot;, Compiler:&quot;gc&quot;, Platform:&quot;linux/amd64&quot;} Server Version: version.Info{Major:&quot;1&quot;, Minor:&quot;22&quot;, GitVersion:&quot;v1.22.1&quot;, GitCommit:&quot;632ed300f2c34f6d6d15ca4cef3d3c7073412212&quot;, GitTreeState:&quot;clean&quot;, BuildDate:&quot;2021-08-19T15:39:34Z&quot;, GoVersion:&quot;go1.16.7&quot;, Compiler:&quot;gc&quot;, Platform:&quot;linux/amd64&quot; </code></pre> <p>The version of traefik image that I try to deploy : <strong>traefik:v2.0</strong></p> <p>I set up all the RBAC resources and my current configuration for traefik is :</p> <pre><code>apiVersion: networking.k8s.io/v1 kind: IngressClass metadata: name: traefik-lb spec: controller: traefik.io/ingress-controller --- apiVersion: &quot;networking.k8s.io/v1&quot; kind: &quot;Ingress&quot; metadata: name: &quot;example-ingress&quot; spec: ingressClassName: &quot;traefik-lb&quot; rules: - host: &quot;*.example.com&quot; http: paths: - path: &quot;/example&quot; pathType: Exact backend: service: name: &quot;rabbitmq&quot; port: number: 32666 --- apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRole metadata: name: traefik-ingress-controller rules: - apiGroups: [&quot;&quot;] resources: [services, endpoints] verbs: [list, watch] - apiGroups: [extensions] resources: [ingresses] verbs: [list] --- apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRoleBinding metadata: name: traefik-ingress-controller roleRef: apiGroup: rbac.authorization.k8s.io kind: ClusterRole name: traefik-ingress-controller subjects: - kind: ServiceAccount name: {{ include &quot;traefik.serviceAccountName&quot; . }} namespace: default </code></pre> <p>The command api-versions result :</p> <pre><code>d3vpasha@d3vpasha-ZenBook-UX425EA-UX425EA ~/helm-charts/charts/traefik (dev)$ kubectl api-versions admissionregistration.k8s.io/v1 apiextensions.k8s.io/v1 apiregistration.k8s.io/v1 apps/v1 authentication.k8s.io/v1 authorization.k8s.io/v1 autoscaling/v1 autoscaling/v2beta1 autoscaling/v2beta2 batch/v1 batch/v1beta1 certificates.k8s.io/v1 coordination.k8s.io/v1 discovery.k8s.io/v1 discovery.k8s.io/v1beta1 events.k8s.io/v1 events.k8s.io/v1beta1 flowcontrol.apiserver.k8s.io/v1beta1 networking.k8s.io/v1 node.k8s.io/v1 node.k8s.io/v1beta1 policy/v1 policy/v1beta1 rbac.authorization.k8s.io/v1 scheduling.k8s.io/v1 storage.k8s.io/v1 storage.k8s.io/v1beta1 v1 </code></pre> <p>I don't see what I do wrong :/ if someone can help me, thank you in advance</p> <p>EDIT : I would like to add the fact that traefik:2.5 has not this problem so it's something related to the version 2.0 of traefik...</p>
<p>You might want to look at a lot of examples that I have done for the same <a href="https://github.com/codeaprendiz/devops-essentials/tree/main/home/container-orchestration/kubernetes" rel="nofollow noreferrer">here</a></p> <p>Try <a href="https://github.com/codeaprendiz/devops-essentials/tree/main/home/container-orchestration/kubernetes/practice-tasks/task-aws-010-deploy-treafik-kops-k8s-helm" rel="nofollow noreferrer">this</a>. You might need to change the service type from LoadBalancer to ClusterIP.</p> <p>This might help as well <a href="https://github.com/codeaprendiz/devops-essentials/tree/main/home/container-orchestration/kubernetes/practice-tasks/task-gcp-023-traefik-whoami" rel="nofollow noreferrer">traefik-whoami</a></p> <p>Try using helm for generating resources. Its much more convenient to manage. You can always generate the k8s-manifests if something is wrong.</p>
<p>I have a brand new (so empty) AKS cluster. I want to install two instances of the nginx ingress controller, in different namespaces and with different ingress class, using helm.</p> <p>I start with the first:</p> <pre><code>helm install ingress1 ingress-nginx/ingress-nginx --namespace namespace1 --set controller.ingressClass=class1 NAME: ingress1 LAST DEPLOYED: Fri Sep 24 20:46:28 2021 NAMESPACE: namespace1 STATUS: deployed REVISION: 1 TEST SUITE: None NOTES: The ingress-nginx controller has been installed. It may take a few minutes for the LoadBalancer IP to be available. </code></pre> <p>All good</p> <p>Now I go with the second:</p> <pre><code>helm install ingress2 ingress-nginx/ingress-nginx --namespace namespace2 --set controller.ingressClass=class2 Error: rendered manifests contain a resource that already exists. Unable to continue with install: IngressClass &quot;nginx&quot; in namespace &quot;&quot; exists and cannot be imported into the current release: invalid ownership metadata; annotation validation error: key &quot;meta.helm.sh/release-name&quot; must equal &quot;ingress2&quot;: current value is &quot;ingress1&quot;; annotation validation error: key &quot;meta.helm.sh/release-namespace&quot; must equal &quot;namespace2&quot;: current value is &quot;namespace1&quot; </code></pre> <p>What is the correct way to install multiple nginx ingress controller instances in the same cluster?</p>
<p>I think that you're setting the wrong values, thus the class name is <code>nginx</code> in both installs. Take a look at the template here: <a href="https://github.com/kubernetes/ingress-nginx/blob/3ae09fd1fac381fce9f5066febf172a4a70c10a9/charts/ingress-nginx/templates/controller-ingressclass.yaml#L13" rel="noreferrer">controller-ingressclass</a></p> <p>If you're using the official ingress-nginx Helm repository: <code>https://kubernetes.github.io/ingress-nginx</code> then try setting this instead: <code>controller.ingressClassResource.name=class1|class2</code> instead:</p> <pre class="lang-sh prettyprint-override"><code>helm install ingress1 ingress-nginx/ingress-nginx --namespace namespace1 --set controller.ingressClassResource.name=class1 helm install ingress2 ingress-nginx/ingress-nginx --namespace namespace2 --set controller.ingressClassResource.name=class2 </code></pre> <p>depending on your needs, you may also require to change the other values <a href="https://github.com/kubernetes/ingress-nginx/blob/3ae09fd1fac381fce9f5066febf172a4a70c10a9/charts/ingress-nginx/values.yaml#L98" rel="noreferrer">of the ingressClassResource</a></p>
<h2>TLDR;</h2> <p>Why bother settings <code>-Xmx</code> and <code>-Xms</code> in a kubernetes app?</p> <hr /> <p>We've inherited a kubernetes app that is having out of memory errors. It looks like the initial devs set kubernetes resource limits (.95 CPU core and 4Gb memory) as shown below. However, they also set the max heap size in <code>JAVA_OPTS -Xmx</code> to 800mb.</p> <p><a href="https://i.stack.imgur.com/szv9K.png" rel="noreferrer"><img src="https://i.stack.imgur.com/szv9K.png" alt="enter image description here" /></a></p> <p>I've found lots of good material on best settings for <code>-Xmx</code> (eg <a href="https://akobor.me/posts/heap-size-and-resource-limits-in-kubernetes-for-jvm-applications" rel="noreferrer">this one</a>), but can't find a straight answer to the following question: do we really need to set <code>-Xmx</code> (and less importantly, <code>-Xms</code>) in a kubernetes container? We've already set hard limits on the container <code>resources</code>, so what is the point to setting these flags? If we removed them altogether, what would the consequence be? Would the app GC more often? Would it scale heap size dynamically or would heap size max be fixed at some default maxium like 256MB? Is there any rule of thumb of setting <code>-Xmx</code> in proportion to kubernets containers?</p>
<p>If you don't set a maximum heap size the behavior depends on the java version used. Current JREs support determining the container limits and use that to guide their internal heuristics.</p> <p>when running with an older version the memory to be used for the heap will be determined based on the physical memory visible to the container, which might be excessive.</p> <p>Note that hitting the memory limit of the container will lead to killing the process and restarting the container.</p> <p>I suggest you use a sane value, as determined from operational testing, for Xmx and Xms to get a stable memory usage.</p>
<p>I am having issues with a certain compiled binary file that has to run as a health check for a certain container in a deployment pod. On AWS environment it runs as expected, but on premises the script fails with a vague error (it's no use even sharing it). I understand that perhaps the problem is in the kubernetes environment not being configured as expected by the script, but I do not know where exactly to look because I don't know what the script does and have no access to its source code.</p> <p>I've read online about debugging utilities for linux, but none of them seem useful for this purpose, or I didn't understand how to use them properly. Is it possible to find which files are being accessed by the script? That would allow me to compare those files between the on-premises environment and the AWS env. and see what is different, so I can solve this problem.</p>
<p>Solved, keeping this up for reference if anyone needs it in the future. You can list all files accessed by your program using <code>strace /path/to/bin 2&gt;&amp;1 | grep openat</code>. Very useful for debugging without source code.</p>
<p>We have a bunch of pods that use RabbitMQ. If the pods are shut down by K8S with SIGTERM, we have found that our RMQ client (Python Pika) has no time to close the connection to RMQ Server causing it to think those clients are still alive until 2 heartbeats are missed.</p> <p>Our investigation has turned up that on SIGTERM, K8S kills all in- and most importantly OUTbound TCP connections, among other things (removing endpoints, etc.) Tried to see if any connections were still possible during preStop hooks, but preStop seems very internally focused and no traffic got out.</p> <p>Has anybody else experienced this issue and solved it? All we need to do is be able to get a message out the door before kubelet slams the door. Our pods are not K8S &quot;Services&quot; so some <a href="https://stackoverflow.com/questions/62567844/kubernetes-graceful-shutdown-continue-to-serve-traffic-during-termination">suggestions</a> didn't help.</p> <p>Steps to reproduce:</p> <ol> <li>add preStop hook sleep 30s to Sender pod</li> <li>tail logs of Receiver pod to see inbound requests</li> <li>enter Sender container's shell &amp; loop curl Receiver - requests appear in the logs</li> <li><code>k delete pod</code> to start termination of Sender pod</li> <li>curl requests immediately begin to hang in Sender, nothing in the Receiver logs</li> </ol>
<p>We tested this extensively and found that new EKS clusters, with Calico installed (see below) will experience this problem, unless Calico is upgraded. Networking will be immediately killed when a pod is sent SIGTERM instead of waiting for the grace period. If you're experiencing this problem and are using Calico, please check the version of Calico against this thread:</p> <p><a href="https://github.com/projectcalico/calico/issues/4518" rel="nofollow noreferrer">https://github.com/projectcalico/calico/issues/4518</a></p> <p>If you're installing Calico using the AWS yaml found here: <a href="https://github.com/aws/amazon-vpc-cni-k8s/tree/master/config" rel="nofollow noreferrer">https://github.com/aws/amazon-vpc-cni-k8s/tree/master/config</a></p> <p>Be advised that the fixes have NOT landed in any of the released versions, we had to install from master, like so:</p> <pre><code> kubectl apply \ -f https://raw.githubusercontent.com/aws/amazon-vpc-cni-k8s/master/config/master/calico-operator.yaml \ -f https://raw.githubusercontent.com/aws/amazon-vpc-cni-k8s/master/config/master/calico-crs.yaml </code></pre> <p>and we also upgraded the AWS CNI for good measure, although that wasn't explicitly required to solve our issue:</p> <pre><code> kubectl apply -f https://raw.githubusercontent.com/aws/amazon-vpc-cni-k8s/v1.8.0/config/v1.8/aws-k8s-cni.yaml kubectl apply -f https://raw.githubusercontent.com/aws/amazon-vpc-cni-k8s/v1.9.1/config/v1.9/aws-k8s-cni.yaml </code></pre> <p>Here's a bunch of <a href="https://docs.aws.amazon.com/eks/latest/userguide/managing-vpc-cni.html" rel="nofollow noreferrer">confusing documentation from AWS</a> that makes it seem like you should switch to use new AWS &quot;add-ons&quot; to manage this stuff, but after an extensive discussion with support, was advised against</p>
<p>I know that i can use <code>kubectl get componentstatus</code> command to check the health status of the k8 cluster but some how the output i am receiving do not show the health. Below is the output from master server.</p> <p><a href="https://i.stack.imgur.com/7Td5F.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/7Td5F.png" alt="enter image description here"></a></p> <p>I can do deployments, can create pods and services which means everything is working fine but not sure how to check the health status.</p>
<p><strong>Solved</strong> in kube-apiserver v1.17.0, also you should use command below in your older apiserver.</p> <pre><code>kubectl get cs -o=go-template='{{printf &quot;NAME\t\t\tHEALTH_STATUS\tMESSAGE\t\n&quot;}}{{range .items}}{{$name := .metadata.name}}{{range .conditions}}{{printf &quot;%-24s%-16s%-20s\n&quot; $name .status .message}}{{end}}{{end}}' </code></pre> <p>enjoy</p>
<p>I am trying to deploy a <code>Kubernetes</code> cluster on <code>AWS EKS</code> using <code>Terraform</code>, run from a <code>Gitlab CI</code> pipeline. My code currently gets a full cluster up and running, except there is a step in which it tries to add the nodes (which are created separately) into the cluster.</p> <p>When it tries to do this, this is the error I receive:</p> <pre><code>│ Error: configmaps is forbidden: User &quot;system:serviceaccount:gitlab-managed-apps:default&quot; cannot create resource &quot;configmaps&quot; in API group &quot;&quot; in the namespace &quot;kube-system&quot; │ │ with module.mastercluster.kubernetes_config_map.aws_auth[0], │ on .terraform/modules/mastercluster/aws_auth.tf line 63, in resource &quot;kubernetes_config_map&quot; &quot;aws_auth&quot;: │ 63: resource &quot;kubernetes_config_map&quot; &quot;aws_auth&quot; { │ </code></pre> <p><code>Terraform</code> I believe is trying to edit the configmap <code>aws_auth</code> in the <code>kube-system</code> namespace, but for whatever reason, it doesn't have permission to do so?</p> <p>I have found a different answer from years ago on Stackoverflow, that currently matches with what the documentation has to say about adding a <code>aws_eks_cluster_auth</code> data source and adding this to the <code>kubernetes</code> provider.</p> <p>My configuration of this currently looks like this:</p> <pre><code>data &quot;aws_eks_cluster&quot; &quot;mastercluster&quot; { name = module.mastercluster.cluster_id } data &quot;aws_eks_cluster_auth&quot; &quot;mastercluster&quot; { name = module.mastercluster.cluster_id } provider &quot;kubernetes&quot; { alias = &quot;mastercluster&quot; host = data.aws_eks_cluster.mastercluster.endpoint cluster_ca_certificate = base64decode(data.aws_eks_cluster.mastercluster.certificate_authority[0].data) token = data.aws_eks_cluster_auth.mastercluster.token load_config_file = false } </code></pre> <p>The weird thing is, this has worked for me before. I have successfully deployed multiple clusters using this method. This configuration is an almost identical copy to another one I had before, only the names of the clusters are different. I am totally lost as to why this can possibly go wrong.</p>
<h1>Use <code>semver</code> to lock <code>hashicorp provider</code> versions</h1> <p>That's why is so important to use <a href="https://semver.org" rel="nofollow noreferrer"><code>semver</code></a> in <code>terraform</code> manifests.</p> <p>As per <a href="https://learn.hashicorp.com/tutorials/terraform/provider-versioning" rel="nofollow noreferrer">Terraform documentation</a>:</p> <blockquote> <p>Terraform providers manage resources by communicating between Terraform and target APIs. Whenever the target APIs change or add functionality, provider maintainers may update and version the provider.</p> <p>When multiple users or automation tools run the same Terraform configuration, they should all use the same versions of their required providers.</p> </blockquote> <h1>Use <code>RBAC</code> rules for <code>Kubernetes</code></h1> <p>There is a Github issue filed about this: <a href="https://github.com/hashicorp/terraform-provider-kubernetes/issues/1127" rel="nofollow noreferrer">v2.0.1: Resources cannot be created. Does kubectl reference to kube config properly? · Issue #1127 · hashicorp/terraform-provider-kubernetes</a> with the same error message as in yours case.</p> <p>And <a href="https://github.com/hashicorp/terraform-provider-kubernetes/issues/1127#issuecomment-765635852" rel="nofollow noreferrer">one of the comments answers</a>:</p> <blockquote> <p>Offhand, this looks related to <a href="https://kubernetes.io/docs/reference/access-authn-authz/rbac/#role-and-clusterrole" rel="nofollow noreferrer">RBAC</a> rules in the cluster (which may have been installed by the helm chart). This command might help diagnose the permissions issues relating to the service account in the error message.</p> <pre><code>$ kubectl auth can-i create namespace --as=system:serviceaccount:gitlab-prod:default $ kubectl auth can-i --list --as=system:serviceaccount:gitlab-prod:default </code></pre> <p>You might be able to compare that list with other users on the cluster:</p> <pre><code>kubectl auth can-i --list --namespace=default --as=system:serviceaccount:default:default </code></pre> <pre><code>$ kubectl auth can-i create configmaps yes $ kubectl auth can-i create configmaps --namespace=nginx-ingress --as=system:serviceaccount:gitlab-prod:default no </code></pre> <p>And investigate related clusterroles:</p> <pre><code>$ kube describe clusterrolebinding system:basic-user Name: system:basic-user Labels: kubernetes.io/bootstrapping=rbac-defaults Annotations: rbac.authorization.kubernetes.io/autoupdate: true Role: Kind: ClusterRole Name: system:basic-user Subjects: Kind Name Namespace ---- ---- --------- Group system:authenticated $ kubectl describe clusterrole system:basic-user Name: system:basic-user Labels: kubernetes.io/bootstrapping=rbac-defaults Annotations: rbac.authorization.kubernetes.io/autoupdate: true PolicyRule: Resources Non-Resource URLs Resource Names Verbs --------- ----------------- -------------- ----- selfsubjectaccessreviews.authorization.k8s.io [] [] [create] selfsubjectrulesreviews.authorization.k8s.io [] [] [create] </code></pre> <p>My guess is that the chart or Terraform config in question is responsible for creating the service account, and the [cluster] roles and rolebindings, but it might be doing so in the wrong order, or not idempotently (so you get different results on re-install vs the initial install). But we would need to see a configuration that reproduces this error. In my testing of version 2 of the providers on <a href="https://github.com/hashicorp/terraform-provider-kubernetes/tree/master/_examples/aks" rel="nofollow noreferrer">AKS</a>, <a href="https://github.com/hashicorp/terraform-provider-kubernetes/tree/master/_examples/eks" rel="nofollow noreferrer">EKS</a>, <a href="https://github.com/hashicorp/terraform-provider-kubernetes/tree/master/_examples/gke" rel="nofollow noreferrer">GKE</a>, and <a href="https://registry.terraform.io/providers/hashicorp/kubernetes/latest/docs/guides/getting-started#creating-your-first-kubernetes-resources" rel="nofollow noreferrer">minikube</a>, I haven't seen this issue come up.</p> <p>Feel free to browse these working examples of building specific clusters and using them with Kubernetes and Helm providers. Giving the config a skim might give you some ideas for troubleshooting further.</p> </blockquote> <h1>Howto solve <code>RBAC</code> issues</h1> <p>As for the error</p> <pre><code>Error: configmaps is forbidden: User &quot;system:serviceaccount:kube-system:default&quot; cannot list </code></pre> <p>There is <a href="https://github.com/helm/helm/issues/5100#issuecomment-533787541" rel="nofollow noreferrer">great explanation by @m-abramovich</a>:</p> <blockquote> <p>First, some information for newbies.<br /> In Kubernetes there are:</p> <ul> <li>Account - something like your ID. Example: john</li> <li>Role - some group in the project permitted to do something. Examples: cluster-admin, it-support, ...</li> <li>Binding - joining Account to Role. &quot;John in it-support&quot; - is a binding.</li> </ul> <p>Thus, in our message above, we see that our Tiller acts as account &quot;default&quot; registered at namespace &quot;kube-system&quot;. Most likely you didn't bind him to a sufficient role.</p> <p>Now back to the problem.<br /> How do we track it:</p> <ul> <li>check if you have specific <strong>account</strong> for tiller. Usually it has same name - &quot;tiller&quot;:<br /> <code>kubectl [--namespace kube-system] get serviceaccount</code><br /> create if not:<br /> <code>kubectl [--namespace kube-system] create serviceaccount tiller</code></li> <li>check if you have <strong>role</strong> or <strong>clusterrole</strong> (cluster role is &quot;better&quot; for newbies - it is cluster-wide unlike namespace-wide role). If this is not a production, you can use highly privileged role &quot;cluster-admin&quot;:<br /> <code>kubectl [--namespace kube-system] get clusterrole</code><br /> you can check role content via:<br /> <code>kubectl [--namespace kube-system] get clusterrole cluster-admin -o yaml</code></li> <li>check if <strong>account</strong> &quot;tiller&quot; in first clause has a binding to <strong>clusterrole</strong> &quot;cluster-admin&quot; that you deem sufficient:<br /> <code>kubectl [--namespace kube-system] get clusterrolebinding</code><br /> if it is hard to figure out based on names, you can simply create new:<br /> <code>kubectl [--namespace kube-system] create clusterrolebinding tiller-cluster-admin --clusterrole=cluster-admin --serviceaccount=kube-system:tiller</code></li> <li>finally, when you have the account, the role and the binding between them, you can check if you really act as this account:<br /> <code>kubectl [--namespace kube-system] get deploy tiller-deploy -o yaml</code></li> </ul> <p>I suspect that your output will not have settings &quot;serviceAccount&quot; and &quot;serviceAccountName&quot;:</p> <pre><code>dnsPolicy: ClusterFirst restartPolicy: Always schedulerName: default-scheduler securityContext: {} terminationGracePeriodSeconds: 30 </code></pre> <p>if yes, than add an account you want tiller to use:<br /> <code>kubectl [--namespace kube-system] patch deploy tiller-deploy -p '{&quot;spec&quot;:{&quot;template&quot;:{&quot;spec&quot;:{&quot;serviceAccount&quot;:&quot;tiller&quot;}}}}'</code><br /> (if you use PowerShell, then check below for post from <a href="https://github.com/snpdev" rel="nofollow noreferrer">@snpdev</a>)<br /> Now you repeat previous check command and see the difference:</p> <pre><code>dnsPolicy: ClusterFirst restartPolicy: Always schedulerName: default-scheduler securityContext: {} serviceAccount: tiller &lt;-- new line serviceAccountName: tiller &lt;-- new line terminationGracePeriodSeconds: 30 </code></pre> </blockquote> <h1>Resources:</h1> <ul> <li><a href="https://kubernetes.io/docs/reference/access-authn-authz/rbac/" rel="nofollow noreferrer">Using RBAC Authorization | Kubernetes</a></li> <li><a href="https://www.cncf.io/blog/2018/08/01/demystifying-rbac-in-kubernetes/" rel="nofollow noreferrer">Demystifying RBAC in Kubernetes | Cloud Native Computing Foundation</a></li> <li><a href="https://helm.sh/docs/topics/rbac/" rel="nofollow noreferrer">Helm | Role-based Access Control</a></li> <li><a href="https://learn.hashicorp.com/tutorials/terraform/provider-versioning" rel="nofollow noreferrer">Lock and Upgrade Provider Versions | Terraform - HashiCorp Learn</a></li> </ul>
<p>Cards on the table, I'm a newcomer to <code>AWS</code> so my ignorance is likely the source of my issue.</p> <p>Sharing the output from my terminal I think is the best way to describe my issue so:</p> <p>I discovered my issue when I tried to spin up a 4 node <code>AWS EKS</code> cluster via <code>eksctl create cluster --name atp-dev --node-type m5.large --nodes 4</code></p> <p>Here is the output from that command:</p> <pre><code>2021-09-25 10:52:06 [ℹ] eksctl version 0.49.0 2021-09-25 10:52:06 [ℹ] using region us-west-2 2021-09-25 10:52:06 [ℹ] setting availability zones to [us-west-2a us-west-2b us-west-2d] 2021-09-25 10:52:06 [ℹ] subnets for us-west-2a - public:192.168.0.0/19 private:192.168.96.0/19 2021-09-25 10:52:06 [ℹ] subnets for us-west-2b - public:192.168.32.0/19 private:192.168.128.0/19 2021-09-25 10:52:06 [ℹ] subnets for us-west-2d - public:192.168.64.0/19 private:192.168.160.0/19 2021-09-25 10:52:07 [ℹ] nodegroup &quot;ng-a477426f&quot; will use &quot;ami-0adca766413605f27&quot; [AmazonLinux2/1.19] 2021-09-25 10:52:07 [ℹ] using Kubernetes version 1.19 2021-09-25 10:52:07 [ℹ] creating EKS cluster &quot;atp-dev&quot; in &quot;us-west-2&quot; region with un-managed nodes 2021-09-25 10:52:07 [ℹ] will create 2 separate CloudFormation stacks for cluster itself and the initial nodegroup 2021-09-25 10:52:07 [ℹ] if you encounter any issues, check CloudFormation console or try 'eksctl utils describe-stacks --region=us-west-2 --cluster=atp-dev' 2021-09-25 10:52:07 [ℹ] CloudWatch logging will not be enabled for cluster &quot;atp-dev&quot; in &quot;us-west-2&quot; 2021-09-25 10:52:07 [ℹ] you can enable it with 'eksctl utils update-cluster-logging --enable-types={SPECIFY-YOUR-LOG-TYPES-HERE (e.g. all)} --region=us-west-2 --cluster=atp-dev' 2021-09-25 10:52:07 [ℹ] Kubernetes API endpoint access will use default of {publicAccess=true, privateAccess=false} for cluster &quot;atp-dev&quot; in &quot;us-west-2&quot; 2021-09-25 10:52:07 [ℹ] 2 sequential tasks: { create cluster control plane &quot;atp-dev&quot;, 3 sequential sub-tasks: { wait for control plane to become ready, create addons, create nodegroup &quot;ng-a477426f&quot; } } 2021-09-25 10:52:07 [ℹ] building cluster stack &quot;eksctl-atp-dev-cluster&quot; 2021-09-25 10:52:07 [!] 1 error(s) occurred and cluster hasn't been created properly, you may wish to check CloudFormation console 2021-09-25 10:52:07 [ℹ] to cleanup resources, run 'eksctl delete cluster --region=us-west-2 --name=atp-dev' 2021-09-25 10:52:07 [✖] creating CloudFormation stack &quot;eksctl-atp-dev-cluster&quot;: AlreadyExistsException: Stack [eksctl-atp-dev-cluster] already exists status code: 400, request id: 550e6a9d-d919-4a34-a012-7bc362f07c5a Error: failed to create cluster &quot;atp-dev&quot; </code></pre> <p>I checked <code>CloudFormation</code> console like it suggests but there are no stacks to interact with I try following directions from the output with <code>eksctl utils describe-stacks --region=us-west-2 --cluster=atp-dev</code> which gives me a whole lot of information.</p> <p>I can't really parse because this is where my understanding of all this ends:</p> <pre><code>2021-09-25 10:57:38 [ℹ] eksctl version 0.49.0 2021-09-25 10:57:38 [ℹ] using region us-west-2 2021-09-25 10:57:39 [ℹ] stack/eksctl-atp-dev-nodegroup-ng-7b715a90 = { Capabilities: [&quot;CAPABILITY_IAM&quot;], CreationTime: 2021-09-22 18:18:00.55 +0000 UTC, DeletionTime: 2021-09-23 03:53:22.696 +0000 UTC, Description: &quot;EKS nodes (AMI family: AmazonLinux2, SSH access: false, private networking: false) [created and managed by eksctl]&quot;, DisableRollback: false, DriftInformation: { StackDriftStatus: &quot;NOT_CHECKED&quot; }, EnableTerminationProtection: false, Outputs: [ { OutputKey: &quot;FeaturePrivateNetworking&quot;, OutputValue: &quot;false&quot; }, { ExportName: &quot;eksctl-atp-dev-nodegroup-ng-7b715a90::InstanceRoleARN&quot;, OutputKey: &quot;InstanceRoleARN&quot;, OutputValue: &quot;arn:aws:iam::988496401707:role/eksctl-atp-dev-nodegroup-ng-7b715-NodeInstanceRole-TR0AX0LF3N6J&quot; }, { OutputKey: &quot;FeatureLocalSecurityGroup&quot;, OutputValue: &quot;true&quot; }, { ExportName: &quot;eksctl-atp-dev-nodegroup-ng-7b715a90::InstanceProfileARN&quot;, OutputKey: &quot;InstanceProfileARN&quot;, OutputValue: &quot;arn:aws:iam::988496401707:instance-profile/eksctl-atp-dev-nodegroup-ng-7b715a90-NodeInstanceProfile-ZUE15KQVO72E&quot; }, { OutputKey: &quot;FeatureSharedSecurityGroup&quot;, OutputValue: &quot;true&quot; } ], RollbackConfiguration: { }, StackId: &quot;arn:aws:cloudformation:us-west-2:988496401707:stack/eksctl-atp-dev-nodegroup-ng-7b715a90/6b591dc0-1bd1-11ec-9bec-0a0320ad966b&quot;, StackName: &quot;eksctl-atp-dev-nodegroup-ng-7b715a90&quot;, StackStatus: &quot;DELETE_FAILED&quot;, StackStatusReason: &quot;The following resource(s) failed to delete: [SG]. &quot;, Tags: [ { Key: &quot;alpha.eksctl.io/cluster-name&quot;, Value: &quot;atp-dev&quot; }, { Key: &quot;alpha.eksctl.io/nodegroup-name&quot;, Value: &quot;ng-7b715a90&quot; }, { Key: &quot;eksctl.cluster.k8s.io/v1alpha1/cluster-name&quot;, Value: &quot;atp-dev&quot; }, { Key: &quot;alpha.eksctl.io/nodegroup-type&quot;, Value: &quot;unmanaged&quot; }, { Key: &quot;alpha.eksctl.io/eksctl-version&quot;, Value: &quot;0.49.0&quot; }, { Key: &quot;eksctl.io/v1alpha2/nodegroup-name&quot;, Value: &quot;ng-7b715a90&quot; } ] } 2021-09-25 10:57:39 [ℹ] stack/eksctl-atp-dev-cluster = { Capabilities: [&quot;CAPABILITY_IAM&quot;], CreationTime: 2021-09-22 18:02:51.122 +0000 UTC, Description: &quot;EKS cluster (dedicated VPC: true, dedicated IAM: true) [created and managed by eksctl]&quot;, DisableRollback: false, DriftInformation: { StackDriftStatus: &quot;NOT_CHECKED&quot; }, EnableTerminationProtection: false, Outputs: [ { ExportName: &quot;eksctl-atp-dev-cluster::SubnetsPrivate&quot;, OutputKey: &quot;SubnetsPrivate&quot;, OutputValue: &quot;subnet-0b82f725a2a3635e0,subnet-013021889c8604724,subnet-0ecc53da4fe6b3dde&quot; }, { ExportName: &quot;eksctl-atp-dev-cluster::SubnetsPublic&quot;, OutputKey: &quot;SubnetsPublic&quot;, OutputValue: &quot;subnet-0f7457b575c99d0c3,subnet-044fa1e27da8b0c7e,subnet-03a4577caf8947eda&quot; }, { OutputKey: &quot;FeatureNATMode&quot;, OutputValue: &quot;Single&quot; }, { ExportName: &quot;eksctl-atp-dev-cluster::ServiceRoleARN&quot;, OutputKey: &quot;ServiceRoleARN&quot;, OutputValue: &quot;arn:aws:iam::988496401707:role/eksctl-atp-dev-cluster-ServiceRole-S4KL2UIIWWH&quot; }, { ExportName: &quot;eksctl-atp-dev-cluster::Endpoint&quot;, OutputKey: &quot;Endpoint&quot;, OutputValue: &quot;https://OUTPUTKEY.gr7.us-west-2.eks.amazonaws.com&quot; }, { ExportName: &quot;eksctl-ATP-dev-cluster::SharedNodeSecurityGroup&quot;, OutputKey: &quot;SharedNodeSecurityGroup&quot;, OutputValue: &quot;[REDACTED]&quot; }, { ExportName: &quot;eksctl-ATP-dev-cluster::VPC&quot;, OutputKey: &quot;VPC&quot;, OutputValue: &quot;[REDACTED]&quot; }, { ExportName: &quot;eksctl-atp-dev-cluster::ClusterSecurityGroupId&quot;, OutputKey: &quot;ClusterSecurityGroupId&quot;, OutputValue: &quot;[REDACTED]&quot; }, { OutputKey: &quot;ClusterStackName&quot;, OutputValue: &quot;eksctl-atp-dev-cluster&quot; }, { OutputKey: &quot;CertificateAuthorityData&quot;, OutputValue: &quot;[REDACTED]&quot; }, { ExportName: &quot;eksctl-atp-dev-cluster::SecurityGroup&quot;, OutputKey: &quot;SecurityGroup&quot;, OutputValue: &quot;[REDACTED]&quot; }, { ExportName: &quot;eksctl-atp-dev-cluster::ARN&quot;, OutputKey: &quot;ARN&quot;, OutputValue: &quot;arn:aws:eks:us-west-2:988496401707:cluster/atp-dev&quot; } ], RollbackConfiguration: { }, StackId: &quot;arn:aws:cloudformation:us-west-2:988496401707:stack/eksctl-atp-dev-cluster/4d4a7bf0-1bcf-11ec-9822-028a7f03527f&quot;, StackName: &quot;eksctl-atp-dev-cluster&quot;, StackStatus: &quot;CREATE_COMPLETE&quot;, StackStatusReason: &quot;Export eksctl-atp-dev-cluster::VPC cannot be deleted as it is in use by eksctl-atp-dev-nodegroup-ng-7b715a90&quot;, Tags: [{ Key: &quot;alpha.eksctl.io/cluster-name&quot;, Value: &quot;atp-dev&quot; },{ Key: &quot;eksctl.cluster.k8s.io/v1alpha1/cluster-name&quot;, Value: &quot;atp-dev&quot; },{ Key: &quot;alpha.eksctl.io/eksctl-version&quot;, Value: &quot;0.49.0&quot; }] } </code></pre>
<p>There are two great apps for listing and removing almost any <code>AWS</code> resource, including yours case.</p> <ul> <li><code>awsls</code> is for listing <code>AWS</code> resources</li> <li><code>awsrm</code> is for removing <code>AWS</code> resources</li> </ul> <h1><code>awsls</code> is for listing <code>AWS</code> resources</h1> <p><a href="https://github.com/jckuester/awsls" rel="nofollow noreferrer">jckuester/awsls: A list command for AWS resources</a></p> <blockquote> <p>awsls supports listing of <a href="https://github.com/jckuester/awsls#supported-resources" rel="nofollow noreferrer">over 250 types of resources</a> across 100 different AWS services. The goal is to code-generate a list function for every AWS resource that is covered by the Terraform AWS Provider (currently over 500). If you want to contribute, <a href="https://github.com/jckuester/awsls/blob/master/gen" rel="nofollow noreferrer">the generator is here</a>.</p> </blockquote> <h1><code>awsrm</code> is for removing <code>AWS</code> resources</h1> <p><a href="https://github.com/jckuester/awsrm" rel="nofollow noreferrer">jckuester/awsrm: A remove command for AWS resources</a></p> <blockquote> <p>This command line tool follows the <a href="https://en.wikipedia.org/wiki/Unix_philosophy#Do_One_Thing_and_Do_It_Well" rel="nofollow noreferrer">Unix Philosophy</a> of <code>doing only one thing and doing it well</code>:</p> <p>It simplifies deleting over <a href="https://github.com/jckuester/awsrm#supported-resources" rel="nofollow noreferrer">250 AWS resource types</a> across multiple accounts and regions.</p> <p>Like other Unix-like tools, <code>awsrm</code> reveals its full power when combining it via pipes with other tools, such as <a href="https://github.com/jckuester/awsls" rel="nofollow noreferrer"><code>awsls</code></a> for listing AWS resources and <code>grep</code> for filtering by resource attributes.</p> </blockquote> <h1>E.g. removing <code>aws_eks_cluster</code> with <code>awsrm</code></h1> <p>To remove <strong>all</strong> <code>aws_eks_cluster</code>s from your account, you may want</p> <pre><code>awsls aws_eks_cluster | awsrm </code></pre> <p>To remove <code>aws_eks_cluster</code> from <strong>specific region</strong>:</p> <pre><code>awsls aws_eks_cluster -r us-west-1 | awsrm -r us-west-1 </code></pre> <p>To remove <code>aws_eks_cluster</code> from <strong>specific profile and region</strong>:</p> <pre><code>awsls aws_eks_cluster -p &lt;yourprofile&gt; -r us-west-1 | awsrm -r us-west-1 -p &lt;yourprofile&gt; </code></pre>
<p>We are planning to run our Azure Devops build agents in a Kubernetes pods.But going through the internet, couldn't find any recommended approach to follow.</p> <p>Details:</p> <ul> <li>Azure Devops Server</li> <li>AKS- 1.19.11</li> </ul> <p>Looking for</p> <ul> <li>AKS kubernetes cluster where ADO can trigger its pipeline with the dependencies.</li> <li>The scaling of pods should happen as the load from the ADO will be initiating</li> <li>Is there any default MS provided image available currently for the build agents?</li> <li>The image should be light weight with BuildAgents and the zulu jdk debian as we are running java based apps.</li> </ul> <p>Any suggestions highly appreciated</p>
<p><a href="https://learn.microsoft.com/en-us/azure/devops/pipelines/agents/docker?view=azure-devops" rel="nofollow noreferrer">This article</a> provides instructions for running your Azure Pipelines agent in Docker. You can set up a self-hosted agent in Azure Pipelines to run inside a Windows Server Core (for Windows hosts), or Ubuntu container (for Linux hosts) with Docker.</p> <blockquote> <p>The image should be light weight with BuildAgents and the zulu jdk debian as we are running java based apps.</p> </blockquote> <h5><a href="https://learn.microsoft.com/en-us/azure/devops/pipelines/agents/docker?view=azure-devops#add-tools-and-customize-the-container" rel="nofollow noreferrer">Add tools and customize the container</a></h5> <p>Once you have created a basic build agent, you can extend the Dockerfile to include additional tools and their dependencies, or build your own container by using this one as a base layer. Just make sure that the following are left untouched:</p> <ul> <li>The <code>start.sh</code> script is called by the Dockerfile.</li> <li>The <code>start.sh</code> script is the last command in the Dockerfile.</li> <li>Ensure that derivative containers don't remove any of the dependencies stated by the Dockerfile.</li> </ul> <blockquote> <p><strong>Note:</strong> <a href="https://learn.microsoft.com/en-us/azure/aks/cluster-configuration#container-runtime-configuration" rel="nofollow noreferrer">Docker was replaced with containerd</a> in Kubernetes 1.19, and <strong>Docker-in-Docker</strong> became unavailable. A few use cases to run docker inside a docker container:</p> <ul> <li>One potential use case for docker in docker is for the CI pipeline, where you need to build and push docker images to a container registry after a successful code build.</li> <li>Building Docker images with a VM is pretty straightforward. However, when you plan to use Jenkins <a href="https://devopscube.com/docker-containers-as-build-slaves-jenkins/" rel="nofollow noreferrer">Docker-based dynamic agents</a> for your CI/CD pipelines, docker in docker comes as a must-have functionality.</li> <li>Sandboxed environments.</li> <li>For experimental purposes on your local development workstation.</li> </ul> </blockquote> <p>If your use case requires running docker inside a container then, you must use Kubernetes with version &lt;= 1.18.x (currently not supported on Azure) as shown <a href="https://learn.microsoft.com/en-us/azure/devops/pipelines/agents/docker?view=azure-devops#configure-secrets-and-deploy-a-replica-set" rel="nofollow noreferrer">here</a> or run the agent in an alternative <strong>docker</strong> environment as shown <a href="https://learn.microsoft.com/en-us/azure/devops/pipelines/agents/docker?view=azure-devops#start-the-image-1" rel="nofollow noreferrer">here</a>.</p> <p>Else if you are <a href="https://learn.microsoft.com/en-us/azure/devops/pipelines/agents/docker?view=azure-devops#use-azure-kubernetes-service-cluster" rel="nofollow noreferrer">deploying the self hosted agent on AKS</a>, the <code>azdevops-deployment</code> <em>Deployment</em> at step 4, <a href="https://learn.microsoft.com/en-us/azure/devops/pipelines/agents/docker?view=azure-devops#configure-secrets-and-deploy-a-replica-set" rel="nofollow noreferrer">here</a>, must be changed to:</p> <pre><code>apiVersion: apps/v1 kind: Deployment metadata: name: azdevops-deployment labels: app: azdevops-agent spec: replicas: 1 #here is the configuration for the actual agent always running selector: matchLabels: app: azdevops-agent template: metadata: labels: app: azdevops-agent spec: containers: - name: azdevops-agent image: &lt;acr-server&gt;/dockeragent:latest env: - name: AZP_URL valueFrom: secretKeyRef: name: azdevops key: AZP_URL - name: AZP_TOKEN valueFrom: secretKeyRef: name: azdevops key: AZP_TOKEN - name: AZP_POOL valueFrom: secretKeyRef: name: azdevops key: AZP_POOL </code></pre> <blockquote> <p>The scaling of pods should happen as the load from the ADO will be initiating</p> </blockquote> <p>You can use cluster-autoscaler and <a href="https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale/" rel="nofollow noreferrer">horizontal pod autoscaler</a>. When combined, the horizontal pod autoscaler is focused on running the number of pods required to meet application demand. The cluster autoscaler is focused on running the number of nodes required to support the scheduled pods. [<a href="https://learn.microsoft.com/en-us/azure/aks/cluster-autoscaler#about-the-cluster-autoscaler" rel="nofollow noreferrer">Reference</a>]</p>
<p>I can see from the pod description that my pod &quot;Failed&quot; due to being &quot;Evicted&quot; due to Memory Pressure. but how can i test for too many &quot;Failed &amp;&amp; Evicted&quot; pods with prometheus alert rules or some other means?</p> <p>I have Prometheus Operator installed, I can see metrics for Failed Pods but not Failed and Evicted</p> <p>kubectl describe pod gives:</p> <pre><code>Name: besteffort-evictme-001 Namespace: skyfii Priority: 0 Node: ip-172-17-2-169.ap-southeast-2.compute.internal/ Start Time: Fri, 24 Sep 2021 15:28:53 +1000 Labels: &lt;none&gt; Annotations: kubernetes.io/psp: eks.privileged Status: Failed Reason: Evicted Message: The node was low on resource: memory. Container termination-demo-container was using 17165108Ki, which exceeds its request of 0. IP: IPs: &lt;none&gt; Containers: </code></pre> <p>the prometheus rule :</p> <pre><code>kube_pod_status_phase{phase=&quot;Failed&quot;} &gt; 0 </code></pre> <p>shows the failed pod</p> <pre><code>kube_pod_status_phase{endpoint=&quot;http&quot;,instance=&quot;172.17.3.141:8080&quot;,job=&quot;kube-state-metrics&quot;,namespace=&quot;skyfii&quot;,phase=&quot;Failed&quot;,pod=&quot;besteffort-evictme-001&quot;,service=&quot;prometheus-kube-state-metrics&quot;} </code></pre> <p>but nothing shows up for</p> <pre><code>kube_pod_container_status_terminated_reason{reason=&quot;Evicted&quot;} &gt; 0 </code></pre> <p>Any Ideas?</p> <p>Thanks Karl</p>
<p>So it seems I need to update my version of <code>kube-prometheus-stack</code> helm chart.</p> <p>The &quot;Evicted&quot; <code>Reason</code> we see in pod description is hanging off podStatus <a href="https://i.stack.imgur.com/Nolv6.png" rel="noreferrer"><img src="https://i.stack.imgur.com/Nolv6.png" alt="enter image description here" /></a></p> <p>newer <code>kube-prometheus-stack</code> versions which brings in the later version (v.2) of kube-state-metrics (v.2) which in turn exposes the <a href="https://github.com/kubernetes/kube-state-metrics/blob/master/docs/pod-metrics.md" rel="noreferrer">kube_pod_status_reason</a></p> <p>I'll upgrade then refactor my prometheus query to use this new metric and post back the answer when I get it working.</p> <p>cheers Karl</p> <p>upgrading to kube-prometheus-stack v 18.1.0 allowed me to do this:- <a href="https://i.stack.imgur.com/LyF8Y.png" rel="noreferrer"><img src="https://i.stack.imgur.com/LyF8Y.png" alt="enter image description here" /></a></p> <p>so I'll be able to craft the query I need now</p> <p>I added this to my prometheus alertmanager rules by adding it to the <code>prometheusAdditionalRulesMap</code> section of the kube-prometheus-stack's Values.yaml</p> <pre><code> - name: kubernetes-container-evictions rules: # Mem pressure evicted pods are left in a Failed state, alert if we see too many failed pods # NB you will need to delete the failed pods after investigating - alert: FailedEvictedPods expr: sum by(namespace, pod) (kube_pod_status_phase{phase=&quot;Failed&quot;} &gt; 0 and on(namespace, pod) kube_pod_status_reason{reason=&quot;Evicted&quot;} &gt; 0) &gt; 0 for: 10m labels: severity: warning annotations: message: 'Failed Evicted pod:{{ $labels.pod }} namespace:{{ $labels.namespace }}' - alert: TooManyEvictedPods expr: sum(kube_pod_status_reason{reason=&quot;Evicted&quot;}) &gt;= 2 labels: severity: high annotations: message: 'Too many Failed Evicted Pods: {{ $value }}' </code></pre> <p>and now I get the alerts I wanted :-)</p>
<p>I want to prevent the Horizontal auto-scaler from scaling down too early.I came across a doc that mentions we can update <code>/etc/kubernetes/manifests/kube-controller-manager.yaml</code> file on master node and edit this flag <code>--horizontal-pod-autoscaler-downscale-stabilization</code>. Is it possible for GKE in Google Cloud ?<br /> As far I know we cannot access the master node on GKE.</p>
<p>There is no way in GKE you can change the flag on the master node as it's a google managed service.</p> <p>You can use other options like custom metrics or custom HPA solutions.</p> <p>For implementing the <strong>custom HPA</strong> solution instead of <strong>default K8s HPA</strong> you can checkout the : <a href="https://github.com/nanit/kubernetes-custom-hpa" rel="nofollow noreferrer">https://github.com/nanit/kubernetes-custom-hpa</a></p> <p>you can check the configuration flag <code>behavior.scaleDownCooldown</code> which takes the time in <strong>seconds</strong> in which the HPA should wait before scaling down again.</p>
<p>I'm totally new to Vault and what I want is to detect when a secret changes and execute some code in response. I've been googling for resources about how to do that but haven't found anything useful. From what I've read and learnt, I think the only way of achieving what I want is by implementing a custom secrets engine. Am I right? Do you know a better way of achieving what I want?</p>
<p>There is no event option in the vault as of now, so on changes, we get notified it's natively changing the Key/value pairs.</p> <p>i would recommend using the polling method if you have any such scenario with the vault.</p> <p>Here is one nice CRD which also does the polling option and syncs the vault secret to Kubernetes secret.</p> <p>This might useful for reference : <a href="https://github.com/DaspawnW/vault-crd" rel="nofollow noreferrer">https://github.com/DaspawnW/vault-crd</a></p>
<p>How to change CPU Limit for namespace <code>kube-system</code> in Azure Kubernetes? My pod could not be deployed successfully due to some pods from namespace <code>kube-system</code> using lots of resource.</p> <p><a href="https://i.stack.imgur.com/8ccf0.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/8ccf0.png" alt="enter image description here" /></a></p>
<p>Posting this as community wiki out of comment, feel free to edit and expand</p> <hr /> <p>In short words, this is not possible to change limits for <code>coreDNS</code> and other critical resources located within <code>kube-system</code> namespace. (Technically it's possible to set custom values, but they will be overwritten shortly and initial state will get back to pre-defined one, below answer from microsoft how exactly it works).</p> <hr /> <p>There's a very similar question to it on <code>microsoft question platform</code> and this is the answer:</p> <blockquote> <p>The deployment coredns runs system critical workload using the CoreDNS project for cluster DNS management and resolution with all 1.12.x and higher clusters. [Reference].</p> <p>If you do a kubectl describe deployment -n kube-system coredns, you will find a very interesting label addonmanager.kubernetes.io/mode=Reconcile</p> <p>Now, addons with label addonmanager.kubernetes.io/mode=Reconcile will be periodically reconciled. Direct manipulation to these addons through apiserver is discouraged because addon-manager will bring them back to the original state. In particular:</p> <ul> <li><p>Addon will be re-created if it is deleted.</p> </li> <li><p>Addon will be reconfigured to the state given by the supplied fields in the template file periodically.</p> </li> <li><p>Addon will be deleted when its manifest file is deleted from the $ADDON_PATH.</p> </li> </ul> <p>The $ADDON_PATH by default is set to /etc/kubernetes/addons/ on the control plane node(s).</p> <p>For more information please check this document.</p> <p>Since AKS is a managed Kubernetes Service you will not be able to access $ADDON_PATH. We strongly recommend against forcing changes to kube-system resources as these are critical for the proper functioning of the cluster.</p> </blockquote> <p>Which was also confirmed in comment by OP:</p> <blockquote> <p>just contacted MS support that we cannot change the limits form kube-system namespace.</p> </blockquote>
<p>I have an ingress resource like the following:</p> <pre class="lang-yaml prettyprint-override"><code>apiVersion: networking.k8s.io/v1 kind: Ingress metadata: name: &quot;app-ingress&quot; labels: app: &quot;app&quot; annotations: kubernetes.io/ingress.class: nginx nginx.ingress.kubernetes.io/backend-protocol: &quot;GRPC&quot; cert-manager.io/cluster-issuer: letsencrypt spec: tls: - hosts: - api.example.com secretName: tls-secret rules: - host: api.example.com http: paths: - path: /grpc pathType: ImplementationSpecific backend: service: name: &quot;app-server&quot; port: number: 50051 - path: /callback pathType: ImplementationSpecific backend: service: name: &quot;app-server&quot; port: number: 80 </code></pre> <p><code>app-server</code> runs two services (on the same pod), a <code>grpc</code> web server and a <code>http</code> web server. To start, a client makes a request to <code>api.example.com/grpc</code>. To fulfill the request, the server makes a request to a third party service, waits for a callback on <code>api.example.com/callback</code>, and then completes the client's request (<code>api.example.com/callback</code> is only accessed by the third party service, not the client).</p> <p>The question is, how can I specifically route <code>api.example.com/callback</code> back to the same pod that made the initial request? Obviously if <code>pod1</code> were to make a request to the third party service and <code>pod2</code> were to receive the callback, <code>pod1</code> would never receive the callback and the client request would have to timeout. I can attach information to the callback I receive from the third party service, so is there a way I could attach some sort of pod id so that kubernetes will route the callback back to the pod that initiated it?</p> <p>I've looked at maybe using <code>StatefulSets</code>, but I'm not sure exactly how this would work. Or would it be better to have sort of &quot;notification pod&quot; that receives callbacks and routes them to the correct pod?</p>
<p>One way would be to user <a href="https://kubernetes.github.io/ingress-nginx/examples/affinity/cookie/" rel="nofollow noreferrer">sticky sessons</a>.<br /> If you want to make sure that connections from a particular client are passed to the same Pod each time, you can select the session affinity based on the client's IP addresses by setting <code>service.spec.sessionAffinity</code> to &quot;ClientIP&quot; (the default is &quot;None&quot;). You can also set the maximum session sticky time by setting <code>service.spec.sessionAffinityConfig.clientIP.timeoutSeconds</code> appropriately (the default value is 10800, which works out to be 3 hours).</p> <p>Another way is to design the Application in away that it doesn't matter which pod receives callback request, the proper pod with the pending client connection will be notified (and provided with data), and send a response back to the client. To communicate requests data you can use some sort of messaging service or distributed in-memory data stores like Redis.</p>
<p>In my /root/.kube/config I have a server: value of &quot;https://my.reverse.proxy:6443&quot;.</p> <p>If I don't set any certificates on the reverse proxy (traffic goes directly to backend and backend certificate is presented, SSL passthrough), I can run a kubectl command successfully (i.e sudo kubectl get pods -o wide -A). But if I set a certificate on the reverse proxy, my kubectl command returns:</p> <pre><code>$ sudo kubectl --insecure-skip-tls-verify get pods -o wide -A error: You must be logged in to the server (Unauthorized) </code></pre> <p>I am not sure why this is happening. Is it because the kubectl is trying to &quot;authenticate&quot; with the reverse proxy certificate, and is only allowed to do so with the back-end certificate?</p> <p>How would I get rid of that error if I want to use a different certificate on the reverse proxy (no SSL passthrough)? What should I do on the client side?</p>
<p>If the issue started after renewing kubernetes certificates, this caused the existing <strong>~/.kube/config</strong> to have outdated keys and certificate values in it.</p> <p>The solution is to replace the values <strong>client-certificate-data</strong> and <strong>client-key-data</strong> in file <strong>~/.kube/config</strong> with the values from the updated file in <strong>/etc/kubernetes/kubelet.conf</strong> of the same name</p>
<p>I want to add a custom tag in Jaeger span, I tried to install Istio on my Kubernetes cluster with this command:</p> <pre><code>istioctl install --set profile=demo --set meshConfig.accessLogFile=/dev/stdout --set meshConfig.outboundTrafficPolicy.mode=REGISTRY_ONLY -f .\tracing.yaml -y </code></pre> <p>and this is <code>tracing.yaml</code>:</p> <pre><code>apiVersion: install.istio.io/v1alpha1 kind: IstioOperator spec: meshConfig: enableTracing: true defaultConfig: tracing: sampling: 100.0 custom_tags: my_tag_header: header: name: test defaultValue: test </code></pre> <p>but there is no <code>test</code> tag in spans: <a href="https://i.stack.imgur.com/LBbFa.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/LBbFa.png" alt="enter image description here" /></a> What should I do?</p>
<p>When using Istio operator you have to initialize it first with</p> <pre class="lang-text prettyprint-override"><code>istioctl operator init </code></pre> <p>By default Istio operator installs and watches only <code>istio-operator</code> namespace. If you want to specify another namespaces for it to watch (for example <em>default</em>), add <code>--watchedNamespaces</code> argument</p> <pre class="lang-text prettyprint-override"><code>istioctl operator init --watchedNamespaces=default </code></pre> <p>With the operator installed, you can now create a mesh by deploying an <code>IstioOperator</code> resource. To install the Istio demo configuration profile using the operator, run the following command:</p> <pre class="lang-text prettyprint-override"><code>kubectl apply -f - &lt;&lt;EOF apiVersion: install.istio.io/v1alpha1 kind: IstioOperator metadata: namespace: istio-system name: example-istiocontrolplane spec: profile: demo EOF </code></pre> <p>Now, with the controller running, you can change the Istio configuration by editing or replacing the <code>IstioOperator</code> resource. The controller will detect the change and respond by updating the Istio installation correspondingly.</p>
<p>I have a main pod that accesses and makes Kubernetes API calls to deploy other pods (the code similar below). It works fine. Now, I don't want to use the config file. I know it's possible with a service account. <a href="https://kubernetes.io/docs/tasks/access-application-cluster/access-cluster/" rel="nofollow noreferrer">https://kubernetes.io/docs/tasks/access-application-cluster/access-cluster/</a>. How do I configure a service account (e.g default service account) that allows my pod to access the APIs?</p> <pre><code>public class KubeConfigFileClientExample { public static void main(String[] args) throws IOException, ApiException { // file path to your KubeConfig String kubeConfigPath = &quot;~/.kube/config&quot;; // loading the out-of-cluster config, a kubeconfig from file-system ApiClient client = ClientBuilder.kubeconfig(KubeConfig.loadKubeConfig(new FileReader(kubeConfigPath))).build(); // set the global default api-client to the in-cluster one from above Configuration.setDefaultApiClient(client); // the CoreV1Api loads default api-client from global configuration. CoreV1Api api = new CoreV1Api(); // invokes the CoreV1Api client V1PodList list = api.listPodForAllNamespaces(null, null, null, null, null, null, null, null, null); System.out.println(&quot;Listing all pods: &quot;); for (V1Pod item : list.getItems()) { System.out.println(item.getMetadata().getName()); } } } </code></pre>
<p>The official Java client has example for <a href="https://github.com/kubernetes-client/java/blob/master/examples/examples-release-13/src/main/java/io/kubernetes/client/examples/InClusterClientExample.java" rel="nofollow noreferrer">in-cluster client example</a>.</p> <p>It is quite similar to your code, you need to use a different <em>ClientBuilder</em>:</p> <pre><code>ApiClient client = ClientBuilder.cluster().build(); </code></pre> <p>and use it like this:</p> <pre><code> // loading the in-cluster config, including: // 1. service-account CA // 2. service-account bearer-token // 3. service-account namespace // 4. master endpoints(ip, port) from pre-set environment variables ApiClient client = ClientBuilder.cluster().build(); // set the global default api-client to the in-cluster one from above Configuration.setDefaultApiClient(client); // the CoreV1Api loads default api-client from global configuration. CoreV1Api api = new CoreV1Api(); </code></pre>
<p>I am trying to host a web app in a container with read only file system. Whenever I try to configure the root file system as read only through the <code>SecurityContext</code> of the container I get the following error:</p> <pre><code> Ports: 80/TCP, 443/TCP Host Ports: 0/TCP, 0/TCP State: Terminated Reason: Error Exit Code: 137 Started: Thu, 23 Sep 2021 18:13:08 +0300 Finished: Thu, 23 Sep 2021 18:13:08 +0300 Ready: False </code></pre> <p>I've tried to achieve the same using an AppArmor profile as follows:</p> <pre><code>profile parser-profile flags=(attach_disconnected) { #include &lt;abstractions/base&gt; ... deny /** wl, ... </code></pre> <p>Unfortunately the result is the same.</p> <p>What I assume is happening is that the container is not capable of saving the files for the web app and fails.</p> <p>In my scenario, I will be running untrusted code and I must make sure that users are not allowed to access the file system.</p> <p>Any ideas of what I am doing wrong and how can I achieve a read only file system?</p> <p>I am using AKS and below is my deployment configuration:</p> <pre><code>apiVersion: v1 kind: Service metadata: name: parser-service spec: selector: app: parser ports: - port: 80 targetPort: 80 protocol: TCP name: http - port: 443 targetPort: 443 protocol: TCP name: https --- apiVersion: apps/v1 kind: Deployment metadata: name: parser-deployment spec: replicas: 5 selector: matchLabels: app: parser template: metadata: labels: app: parser annotations: container.apparmor.security.beta.kubernetes.io/parser: localhost/parser-profile spec: containers: - name: parser image: parser.azurecr.io/parser:latest ports: - containerPort: 80 - containerPort: 443 resources: limits: cpu: &quot;1.20&quot; securityContext: readOnlyRootFilesystem: true </code></pre> <p>Edit: I also tried creating a cluster level PSP which also did not work.</p>
<p>I managed to replicate your issue and achieve read only filesystem with exception for one directory.</p> <p>First, worth to note that you are using both solutions in your deployment - the AppArmor profile and SecurityContext. As AppArmor seems to be much more complex and needs configuration to be done per node I decided to use only SecurityContext as it is working fine.</p> <p>I got this error that you mention in the comment:</p> <pre><code>Failed to create CoreCLR, HRESULT: 0x80004005 </code></pre> <p>This error doesn't say to much, but after some testing I found that it only occurs when you are running the pod which filesytem is read only - the application tries to save files but cannot do so.</p> <p>The app creates some files in the <code>/tmp</code> directory so the solution is to mount <code>/tmp</code> using <a href="https://kubernetes.io/docs/concepts/storage/volumes/" rel="noreferrer">Kubernetes Volumes</a> so it will be read write. In my example I used <a href="https://kubernetes.io/docs/concepts/storage/volumes/#emptydir" rel="noreferrer">emptyDir</a> but you can use any other volume you want as long as it supports writing to it. The deployment configuration (you can see that I added <code>volumeMounts</code> and <code>volumes</code> and the bottom):</p> <pre><code>apiVersion: v1 kind: Service metadata: name: parser-service spec: selector: app: parser ports: - port: 80 targetPort: 80 protocol: TCP name: http - port: 443 targetPort: 443 protocol: TCP name: https --- apiVersion: apps/v1 kind: Deployment metadata: name: parser-deployment spec: replicas: 5 selector: matchLabels: app: parser template: metadata: labels: app: parser spec: containers: - name: parser image: parser.azurecr.io/parser:latest ports: - containerPort: 80 - containerPort: 443 resources: limits: cpu: &quot;1.20&quot; securityContext: readOnlyRootFilesystem: true volumeMounts: - mountPath: /tmp name: temp volumes: - name: temp emptyDir: {} </code></pre> <p>After executing into pod I can see that pod file system is mounted as read only:</p> <pre><code># ls app bin boot dev etc home lib lib64 media mnt opt proc root run sbin srv sys tmp usr var # touch file touch: cannot touch 'file': Read-only file system # mount overlay on / type overlay (ro,...) </code></pre> <p>By running <code>kubectl describe pod {pod-name}</code> I can see that <code>/tmp</code> directory is mounted as read write and it is using <code>temp</code> volume:</p> <pre><code>Mounts: /tmp from temp (rw) </code></pre> <p>Keep in mind if you are using other directories (for example to save files) you need to also mount them the same way as the <code>/tmp</code>.</p>
<p>I got 2 spring app pods deployed in k8 cluster. 1 replica each. Both have their cluster-ip services exposing the services.</p> <ol> <li><em><strong>/upstream/agentLabs/makeotherTierCall</strong></em> should forward to prevlab deployment <em><strong>/agentLabs/makeOtherTierCall</strong></em></li> <li><em><strong>/downstream/basics/hello</strong></em> should forward to newlab deployment <em><strong>/basics/hello</strong></em></li> </ol> <p>I am using ingress-nginx to redirect the traffic with following rules.</p> <p><strong>ingress-service.yml</strong></p> <pre><code>apiVersion: networking.k8s.io/v1 # UPDATE API kind: Ingress metadata: namespace: javaspace name: ingress-service annotations: kubernetes.io/ingress.class: 'nginx' nginx.ingress.kubernetes.io/use-regex: 'true' # ADD ANNOTATION nginx.ingress.kubernetes.io/rewrite-target: /$1 # UPDATE ANNOTATION spec: rules: - http: paths: - path: /upstream?(.*) # UPDATE PATH pathType: Prefix # ADD PATHTYPE backend: service: # UPDATE SERVICE FIELDS name: prevlab-cluster-ip-service port: number: 8080 - path: /downstream?(.*) # UPDATE PATH pathType: Prefix # ADD PATHTYPE backend: service: # UPDATE SERVICE FIELDS name: newlab-cluster-ip-service port: number: 8080 </code></pre> <p>The issue is when I make any call (both 1 and 2) sometimes the ingress controller forwards the traffic correctly and sometimes it doesn't and I get 404. Basically, what I am observing is that alternatively the traffic is getting routed to both cluster-ip services one after the other.</p> <p>for eg. if I make <em>/upstream/agentLabs/makeotherTierCall</em> request 2 times, at first it forwards wrongly to newlab cluster-ip service (giving back 404), and then next it forwards correctly to prevlab cluster-ip service (giving back 200).</p> <p><strong>ingress-nginx controller setup</strong></p> <pre><code>kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/controller-v1.0.1/deploy/static/provider/cloud/deploy.yaml </code></pre> <p><strong>ingress-controller logs</strong></p> <pre><code>192.168.65.3 - - [24/Sep/2021:10:04:21 +0000] &quot;GET /upstream/agentLabs/makeOtherTierCall HTTP/2.0&quot; 200 12 &quot;-&quot; &quot;Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/93.0.4577.82 Safari/537.36&quot; 45 0.008 [javaspace-prevlab-cluster-ip-service-8080] [] 10.1.0.181:8080 12 0.007 200 24ae53531ce4d7109004f81e79534ca4 192.168.65.3 - - [24/Sep/2021:10:04:21 +0000] &quot;GET /upstream/agentLabs/makeOtherTierCall HTTP/2.0&quot; 404 286 &quot;-&quot; &quot;Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/93.0.4577.82 Safari/537.36&quot; 45 0.006 [javaspace-prevlab-cluster-ip-service-8080] [] 10.1.0.179:8080 286 0.005 404 1a32efb3a9dc21cce01b908afeb0248a 192.168.65.3 - - [24/Sep/2021:10:04:22 +0000] &quot;GET /upstream/agentLabs/makeOtherTierCall HTTP/2.0&quot; 200 12 &quot;-&quot; &quot;Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/93.0.4577.82 Safari/537.36&quot; 45 0.007 [javaspace-prevlab-cluster-ip-service-8080] [] 10.1.0.181:8080 12 0.007 200 542bd4abba25be5a416deca1152cb29b 192.168.65.3 - - [24/Sep/2021:10:04:22 +0000] &quot;GET /upstream/agentLabs/makeOtherTierCall HTTP/2.0&quot; 404 286 &quot;-&quot; &quot;Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/93.0.4577.82 Safari/537.36&quot; 45 0.008 [javaspace-prevlab-cluster-ip-service-8080] [] 10.1.0.179:8080 286 0.007 404 aaea8e3bf60dab81ef7454d51863a22d 192.168.65.3 - - [24/Sep/2021:10:07:23 +0000] &quot;GET /downstream/basics/hello HTTP/2.0&quot; 404 306 &quot;-&quot; &quot;Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/93.0.4577.82 Safari/537.36&quot; 35 0.009 [javaspace-newlab-cluster-ip-service-8080] [] 10.1.0.181:8080 306 0.009 404 178bd79cc71b73f7a337a2652322d65f 192.168.65.3 - - [24/Sep/2021:10:07:23 +0000] &quot;GET /downstream/basics/hello HTTP/2.0&quot; 200 12 &quot;-&quot; &quot;Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/93.0.4577.82 Safari/537.36&quot; 35 0.002 [javaspace-newlab-cluster-ip-service-8080] [] 10.1.0.179:8080 12 0.003 200 280d2b7974ae38a467237cc6cf437b98 192.168.65.3 - - [24/Sep/2021:10:07:24 +0000] &quot;GET /downstream/basics/hello HTTP/2.0&quot; 404 306 &quot;-&quot; &quot;Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/93.0.4577.82 Safari/537.36&quot; 35 0.008 [javaspace-newlab-cluster-ip-service-8080] [] 10.1.0.181:8080 306 0.008 404 4e237232b4c53c9bb90e7bb59c15e916 192.168.65.3 - - [24/Sep/2021:10:07:24 +0000] &quot;GET /downstream/basics/hello HTTP/2.0&quot; 200 12 &quot;-&quot; &quot;Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/93.0.4577.82 Safari/537.36&quot; 35 0.003 [javaspace-newlab-cluster-ip-service-8080] [] 10.1.0.179:8080 12 0.002 200 be0cf532a972ec0d783e15869470f579 </code></pre> <p>Using Docker Desktop's Kubernetes. Kubernetes 1.21.2</p> <p><strong>What am I doing wrong here? Is this default behavior? Do I need to do some additional config?</strong></p>
<p>Nevermind. I had done a very small but very stupid mistake. In case someone comes wandering around here: I had used the same label for my 2 backend services. And for each of the cluster-IP services used the same selector. Hence, I was seeing inconsistent behavior.</p>
<p>I have create two secret docker-registrys using with these step:</p> <pre><code>$ kubectl create secret docker-registry my-secret --docker-username=burak --docker-password=deniz --docker-email=burak@... $ kubectl create secret docker-registry secret --docker-username=burak --docker-password=deniz --docker-email=burak@... </code></pre> <p>After these step I tried to get deployment with using that:</p> <pre><code>$ kubectl get deployment </code></pre> <p>and I have faced to that ERROR:</p> <blockquote> <p>Unable to connect to the server: x509: certificate signed by unknown authority (possibly because of "crypto/rsa: verification error" while trying to verify candidate authority certificate "minikubeCA")</p> </blockquote> <p>and When I have tried to delete or get these secret docker-registrys,I faced to same Error.</p> <p>How Can I delete these docker-registrys. Can you help me?.</p> <p>Thank you for your answers.</p>
<p>I had the problem, I used the following steps to delete docker-secrets.</p> <ol> <li>Check available secrets <pre><code>$kubectl get secrets </code></pre> </li> <li>Delete using <em>name</em> : <pre><code>$kubectl delete secrets mydockercredentials </code></pre> </li> </ol> <p>use the above command to delete secrets.</p>
<p>I'm facing a problem with the image <strong>groundnuty/k8s-wait-for</strong>. Project at <a href="https://github.com/groundnuty/k8s-wait-for" rel="nofollow noreferrer">github</a> and repo at <a href="https://hub.docker.com/r/groundnuty/k8s-wait-for" rel="nofollow noreferrer">dockerhub</a>.</p> <p>I'm pretty sure that error is in command arguments, as the init container fails with <strong>Init:CrashLoopBackOff</strong>.</p> <p><strong>About image:</strong> This image is used for init containers, which need to postpone a pod deployment. The script that is in the image waits for the pod or job to complete, after it completes it lets the main container and all replicas start deploying.</p> <p>In my example, it should wait for a job named <code>{{ .Release.Name }}-os-server-migration-{{ .Release.Revision }}</code> to finish, and after it detects it is finished it should let main containers start. Helm templates are used.</p> <p><strong>By my understanding, the job name is <code>{{ .Release.Name }}-os-server-migration-{{ .Release.Revision }}</code> and the second command argument at the init container in deployment.yml needs to be the same so the init container can depend on the named job. Any other opinions or experiences with this approach?</strong></p> <p>There are templates attached.</p> <p><strong>DEPLOYMENT.YML:</strong></p> <pre><code>apiVersion: apps/v1 kind: Deployment metadata: name: {{ .Release.Name }}-os-{{ .Release.Revision }} namespace: {{ .Values.namespace }} labels: app: {{ .Values.fullname }} spec: replicas: {{ .Values.replicaCount }} selector: matchLabels: app: {{ .Values.fullname }} template: metadata: labels: app: {{ .Values.fullname }} spec: {{- with .Values.imagePullSecrets }} imagePullSecrets: {{- toYaml . | nindent 8 }} {{- end }} containers: - name: {{ .Chart.Name }} image: &quot;{{ .Values.image.repository }}:{{ .Values.image.tag }}&quot; imagePullPolicy: {{ .Values.image.pullPolicy }} ports: - name: http containerPort: 8080 resources: {{- toYaml .Values.resources | nindent 12 }} initContainers: - name: &quot;{{ .Chart.Name }}-init&quot; image: &quot;groundnuty/k8s-wait-for:v1.3&quot; imagePullPolicy: &quot;{{ .Values.init.pullPolicy }}&quot; args: - &quot;job&quot; - &quot;{{ .Release.Name }}-os-server-migration-{{ .Release.Revision }}&quot; </code></pre> <p><strong>JOB.YML:</strong></p> <pre><code>apiVersion: batch/v1 kind: Job metadata: name: {{ .Release.Name }}-os-server-migration-{{ .Release.Revision }} namespace: {{ .Values.migration.namespace }} spec: backoffLimit: {{ .Values.migration.backoffLimit }} template: spec: {{- with .Values.migration.imagePullSecrets }} imagePullSecrets: {{- toYaml . | nindent 8 }} {{- end }} containers: - name: {{ .Values.migration.fullname }} image: &quot;{{ .Values.migration.image.repository }}:{{ .Values.migration.image.tag }}&quot; imagePullPolicy: {{ .Values.migration.image.pullPolicy }} command: - sh - /app/migration-entrypoint.sh restartPolicy: {{ .Values.migration.restartPolicy }} </code></pre> <p><strong>LOGS:</strong></p> <pre><code> Normal Scheduled 46s default-scheduler Successfully assigned development/octopus-dev-release-os-1-68cb9549c8-7jggh to minikube Normal Pulled 41s kubelet Successfully pulled image &quot;groundnuty/k8s-wait-for:v1.3&quot; in 4.277517553s Normal Pulled 36s kubelet Successfully pulled image &quot;groundnuty/k8s-wait-for:v1.3&quot; in 3.083126925s Normal Pulling 20s (x3 over 45s) kubelet Pulling image &quot;groundnuty/k8s-wait-for:v1.3&quot; Normal Created 18s (x3 over 41s) kubelet Created container os-init Normal Started 18s (x3 over 40s) kubelet Started container os-init Normal Pulled 18s kubelet Successfully pulled image &quot;groundnuty/k8s-wait-for:v1.3&quot; in 1.827195139s Warning BackOff 4s (x4 over 33s) kubelet Back-off restarting failed container </code></pre> <p><strong>kubectl get all -n development</strong></p> <pre><code>NAME READY STATUS RESTARTS AGE pod/octopus-dev-release-os-1-68cb9549c8-7jggh 0/1 Init:CrashLoopBackOff 2 44s pod/octopus-dev-release-os-1-68cb9549c8-9qbdv 0/1 Init:CrashLoopBackOff 2 44s pod/octopus-dev-release-os-1-68cb9549c8-c8h5k 0/1 Init:Error 2 44s pod/octopus-dev-release-os-migration-1-9wq76 0/1 Completed 0 44s ...... ...... NAME COMPLETIONS DURATION AGE job.batch/octopus-dev-release-os-migration-1 1/1 26s 44s </code></pre>
<p>For anyone facing the same issue, I will explain my fix.</p> <p>Problem was that the containers inside deployment.yaml had no permissions to use Kube API. So, groundnuty/k8s-wait-for:v1.3 container could not check has the job <strong>{{ .Release.Name }}-os-server-migration-{{ .Release.Revision }}</strong> completed or not. That's why init containers instantly failed with CrashLoopError.</p> <p>After adding Service Account, role, and role binding everything worked great, and <strong>groundnuty/k8s-wait-for:v1.3</strong> successfully waited for the job(migration) to finish, in order to let the main container run.</p> <p>Here are the examples of the code for the service account, role, and role binding that solved the issue.</p> <p><strong>sa.yaml</strong></p> <pre><code>apiVersion: v1 kind: ServiceAccount metadata: name: sa-migration namespace: development </code></pre> <p><strong>role.yaml</strong></p> <pre><code>apiVersion: rbac.authorization.k8s.io/v1 kind: Role metadata: name: migration-reader rules: - apiGroups: [&quot;batch&quot;,&quot;extensions&quot;] resources: [&quot;jobs&quot;] verbs: [&quot;get&quot;,&quot;watch&quot;,&quot;list&quot;] </code></pre> <p><strong>role-binding.yaml</strong></p> <pre><code>apiVersion: rbac.authorization.k8s.io/v1 kind: RoleBinding metadata: name: migration-reader subjects: - kind: ServiceAccount name: sa-migration roleRef: kind: Role name: migration-reader apiGroup: rbac.authorization.k8s.io </code></pre>
<p>I'd like to run two instances of <code>k3s</code> on the same machine.</p> <p>Let's say I have already two different master servers.</p> <p>What I'd like to do is to install:</p> <ol> <li>A K3S instance to deal with Master #1.</li> <li>A second instance to deal with Master #2.</li> </ol> <p>First instance will be managed by myself while the second instance will be managed by my customer.</p> <p>Is there a way to setup two instances of K3S on the same machine?</p>
<p>Running multiple instances of k3s is not supported out of the box.<br /> You can however use tools like <a href="https://k3d.io/" rel="nofollow noreferrer">k3d</a> (running inside docker container), or <a href="https://github.com/superseb/multipass-k3s" rel="nofollow noreferrer">multipass-k3s</a> (running inside a VM).</p> <p>chroot jail is not really an option. Rootless K3s is still in experimental stage <sup>[<a href="https://rancher.com/docs/k3s/latest/en/advanced/#running-k3s-with-rootless-mode-experimental" rel="nofollow noreferrer">reference</a>]</sup>, and applications running as root can easily break out of jail.</p>
<p>I have run some standard Azure IaaS kubernetes clusters for 3 years in production (~ 40 nodes). Because of recent corporate security changes and kubernetes design improvements, in particular the management of CSINodes, I decided to move back from Azure file storages to Longhorn. This scenario has been validated on other clusters.</p> <p>In production, I would like to move persistent volume from an initial storage class to another one. Let's say storage_class_1 to storage_class_2.</p> <p>storage_class_1 inherits from Azure File whereas storage_class_2 inherits from longhorn. Persistent volumes are dynamically generated using RabbitMQ operator.</p> <p>When modifying the CRD definition, no new PV is created and old ones are still bound.</p> <pre><code>persistence: storageClassName: storage_class_2 storage: 10Gi </code></pre> <p>I am looking for a way to update the PV without losing any data nor stopping the service. Any idea?</p> <p>Some technical information: Kubernetes : 1.19.8 Docker : 20.10.2 RabbitMQ Cluster Operator : 1.5.0</p>
<p>I have finally found the right sequence:</p> <ol> <li>Delete one PVC because of the nature of replica sets, volumes are persistent</li> <li>Remove the corresponding instance</li> <li>Create a new PVC which refers to the new storage class</li> <li>The Replicaset will automaticall bind the new instance to this new PVC</li> <li>Do it for other replicas</li> </ol>
<p>The API credentials for service accounts are normally mounted in pods as:</p> <pre><code>/var/run/secrets/kubernetes.io/serviceaccount/token </code></pre> <p>This token allows containerized processes in the pod to communicate with the API server.</p> <p>What's the purpose of a pod's service account (<code>serviceAccountName</code>), if <code>automountServiceAccountToken</code> is set to <code>false</code>?</p>
<p><strong>A little of theory:</strong></p> <p>Let's start with what happens when pod should be created.</p> <blockquote> <p>When you create a pod, if you do not specify a service account, it is automatically assigned the default service account in the same namespace</p> </blockquote> <p><a href="https://v1-24.docs.kubernetes.io/docs/tasks/configure-pod-container/configure-service-account/#use-the-default-service-account-to-access-the-api-server" rel="nofollow noreferrer">Reference</a>.</p> <p>So all pods are linked to service account anyway (default or specified in <code>spec</code>).</p> <p>Then API access token is always generated for each service account.</p> <p><code>automountServiceAccountToken</code> flag defines if this token will automatically mounted to the pod after it has been created.</p> <p>There are two options where to set this flag:</p> <ul> <li><p>In a specific service account</p> <pre><code>apiVersion: v1 kind: ServiceAccount metadata: name: build-robot automountServiceAccountToken: false ... </code></pre> </li> <li><p>In a specific pod</p> <pre><code>apiVersion: v1 kind: Pod metadata: name: my-pod spec: serviceAccountName: build-robot automountServiceAccountToken: false ... </code></pre> </li> </ul> <hr /> <p><strong>Answer:</strong></p> <blockquote> <p>What's the purpose of a pod's service account (serviceAccountName), if automountServiceAccountToken is set to false?</p> </blockquote> <p>It may make a difference depending on what processes are involved in pod creation. Good example is in <a href="https://github.com/kubernetes/kubernetes/issues/16779#issuecomment-159656641" rel="nofollow noreferrer">comments in GitHub issue</a> (where this flag eventually came from):</p> <blockquote> <p>There are use cases for still creating a token (for use with external systems) or still associating a service account with a pod (for use with image pull secrets), but being able to opt out of API token automount (either for a particular pod, or for a particular service account) is useful.</p> </blockquote>
<p>Github repo: <a href="https://github.com/oussamabouchikhi/udagram-microservices" rel="nofollow noreferrer">https://github.com/oussamabouchikhi/udagram-microservices</a></p> <p>After I configured the kubectl with the AWS EKS cluster, I deployed the services using these commands</p> <pre><code>kubectl apply -f env-configmap.yaml kubectl apply -f env-secret.yaml kubectl apply -f aws-secret.yaml # this is repeated for all services kubectl apply -f svcname-deploymant.yaml kubectl apply -f svcname-service.yaml </code></pre> <p><a href="https://i.stack.imgur.com/Qpe14.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Qpe14.png" alt="enter image description here" /></a></p> <p>But the pods took hours and still in PENDING state, and when I run the command <code>kubectl describe pod &lt;POD_NAME&gt;</code> I get the follwing info</p> <p>reverseproxy-667b78569b-2c6hv pod: <a href="https://pastebin.com/3xF04SEx" rel="nofollow noreferrer">https://pastebin.com/3xF04SEx</a> <br/> udagram-api-feed-856bbc5c45-jcgtk pod: <a href="https://pastebin.com/5UqB79tU" rel="nofollow noreferrer">https://pastebin.com/5UqB79tU</a> <br/> udagram-api-users-6fbd5cbf4f-qbmdd pod: <a href="https://pastebin.com/Hiqe1LAM" rel="nofollow noreferrer">https://pastebin.com/Hiqe1LAM</a></p>
<p>From your <code>kubectl describe pod &lt;podname&gt;</code></p> <blockquote> <p>Warning FailedScheduling 2m19s (x136 over 158m) default-scheduler 0/2 nodes are available: 2 Too many pods.</p> </blockquote> <p>When you see this, it means that your nodes in AWS EKS is full.</p> <p><strong>To solve this, you need to add more (or bigger) nodes.</strong></p> <p>You can also investigate your nodes, e.g. list your nodes with:</p> <pre><code>kubectl get nodes </code></pre> <p>and investigate a specific node (check how many pods it has <em>capacity</em> for - and how many pods that runs on the node) with:</p> <pre><code>kubectl describe node &lt;node-name&gt; </code></pre>
<p>I started implementing the Kuberenetes for my simple app. I am facing issue when i use <code>NodePort</code>. IF I use <code>LoadBalancer</code> I can open my url. If I use <code>NodePort</code> it will take long time for trying to load and getting error <code>connection refused</code>. Below is my simple yaml file.</p> <pre><code>&gt; POD yaml apiVersion: v1 kind: Pod metadata: name: pod-webapp labels: app: webapp spec: containers: - name: app image: mydockerimage_xxx </code></pre> <pre><code>&gt; service.yaml kind: Service apiVersion: v1 metadata: # Unique key of the Service instance name: service-webapp spec: ports: # Accept traffic sent to port 80 - name: http port: 80 nodePort: 30080 selector: app: webapp type: NodePort </code></pre>
<p>what I found something in GitHub : <a href="https://github.com/kubernetes/minikube/issues/11193" rel="nofollow noreferrer">Kubernetes NodePort</a> which solved my issue partially.</p>
<p>I'm developing <a href="https://github.com/msrumon/microservice-architecture" rel="nofollow noreferrer">this dummy project</a> and trying to make it work locally via <code>Skaffold</code>.</p> <p>There are 3 services in my project (running on ports <code>3001</code>, <code>3002</code> and <code>3003</code> respectively), wired via <code>NATS server</code>.</p> <p>The problem is: I get different kinds of errors each time I run <code>skaffold debug</code>, and one/more service(s) don't work.</p> <p>At times, I don't get any errors, and all services work as expected. The followings are some of the errors:</p> <pre><code>Waited for &lt;...&gt;s due to client-side throttling, not priority and fairness, request: GET:https://kubernetes.docker.internal:6443/api/v1/namespaces/default/pods?labelSelector=app%!D(MISSING). &lt;...&gt;%!C(MISSING)app.kubernetes.io%!F(MISSING)managed-by%!D(MISSING)skaffold%!C(MISSING)skaffold.dev%!F(MISSING)run-id%!D(MISSING)&lt;...&gt;` (from `request.go:668`) - `0/1 nodes are available: 1 Insufficient cpu.` (from deployments) - `UnhandledPromiseRejectionWarning: NatsError: CONNECTION_REFUSED` (from apps) - `UnhandledPromiseRejectionWarning: Error: getaddrinfo EAI_AGAIN nats-service` (from apps) </code></pre> <p>I'm at a loss and can't help myself anymore. I hope someone here will be able to help me out.</p> <p>Thanks in advance.</p> <p>PS: Below is my machine's config, in case it's my machine's fault.</p> <pre><code>Processor: AMD Ryzen 7 1700 (8C/16T) Memory: 2 x 8GB DDR4 2667MHz Graphics: AMD Radeon RX 590 (8GB) OS: Windows 10 Pro 21H1 </code></pre> <pre class="lang-sh prettyprint-override"><code>$ docker version Client: Version: 19.03.12 API version: 1.40 Go version: go1.13.12 Git commit: 0ed913b8- Built: 07/28/2020 16:36:03 OS/Arch: windows/amd64 Experimental: false Server: Docker Engine - Community Engine: Version: 20.10.8 API version: 1.41 (minimum version 1.12) Go version: go1.16.6 Git commit: 75249d8 Built: Fri Jul 30 19:52:10 2021 OS/Arch: linux/amd64 Experimental: false containerd: Version: 1.4.9 GitCommit: e25210fe30a0a703442421b0f60afac609f950a3 runc: Version: 1.0.1 GitCommit: v1.0.1-0-g4144b63 docker-init: Version: 0.19.0 GitCommit: de40ad0 </code></pre> <pre class="lang-sh prettyprint-override"><code>$ kubectl version Client Version: version.Info{Major:&quot;1&quot;, Minor:&quot;22&quot;, GitVersion:&quot;v1.22.2&quot;, GitCommit:&quot;8b5a19147530eaac9476b0ab82980b4088bbc1b2&quot;, GitTreeState:&quot;clean&quot;, BuildDate:&quot;2021-09-15T21:38:50Z&quot;, GoVersion:&quot;go1.16.8&quot;, Compiler:&quot;gc&quot;, Platform:&quot;windows/amd64&quot;} Server Version: version.Info{Major:&quot;1&quot;, Minor:&quot;21&quot;, GitVersion:&quot;v1.21.4&quot;, GitCommit:&quot;3cce4a82b44f032d0cd1a1790e6d2f5a55d20aae&quot;, GitTreeState:&quot;clean&quot;, BuildDate:&quot;2021-08-11T18:10:22Z&quot;, GoVersion:&quot;go1.16.7&quot;, Compiler:&quot;gc&quot;, Platform:&quot;linux/amd64&quot;} </code></pre> <p>I use WSL2 (Debian) and <code>docker-desktop</code> is the context of Kubernetes.</p>
<p>The error say it all:</p> <pre><code>- `0/1 nodes are available: 1 Insufficient cpu.` (from deployments) </code></pre> <p>You are requesting or deploying more apps than your node can handle.<br /> In your deployment units (<code>Deployment</code>, <code>StatefulSet</code>, <code>DeamoSet</code> etc) you define the resources which you require for your application, for example in this pod:</p> <pre class="lang-yaml prettyprint-override"><code>apiVersion: v1 kind: Pod metadata: name: frontend spec: containers: - name: app image: images.my-company.example/app:v4 resources: requests: memory: &quot;64Mi&quot; cpu: &quot;250m&quot; limits: memory: &quot;128Mi&quot; cpu: &quot;500m&quot; - name: log-aggregator image: images.my-company.example/log-aggregator:v6 resources: requests: memory: &quot;64Mi&quot; cpu: &quot;250m&quot; limits: memory: &quot;128Mi&quot; cpu: &quot;500m&quot; </code></pre> <p>This is the relevant section:</p> <pre class="lang-yaml prettyprint-override"><code>resources: requests: memory: &quot;64Mi&quot; cpu: &quot;250m&quot; limits: memory: &quot;128Mi&quot; cpu: &quot;500m&quot; </code></pre> <p>Check your node resources and increase your nodes or resources in order to be able to deploy more services.</p> <hr /> <p><a href="https://i.stack.imgur.com/NVdmZ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/NVdmZ.png" alt="enter image description here" /></a></p>
<p>My question is very short: <strong>how does the process look like to retrieve a ca certificate for an existing Kubernetes cluster to connect gitlab with this cluster?</strong></p> <p>After studying the docs, everything is fine, but I don‘t understand which cluster certificate is meant.</p> <p>Many thanks and have a nice day everyone!</p>
<p>In this <a href="https://docs.gitlab.com/ee/user/project/clusters/add_existing_cluster.html#how-to-add-an-existing-cluster" rel="nofollow noreferrer">gitlab documentation</a> you can find instructions how to add an existing cluster to the gitlab and what do you need to do so.</p> <blockquote> <p><strong>CA certificate</strong> (required) - A valid Kubernetes certificate is needed to authenticate to the cluster. We use the certificate created by default.</p> </blockquote> <p>This is a certificate created by default inside the cluster.</p> <p>All you have to do is get it and this is written in following steps:</p> <blockquote> <p>i. List the secrets with <code>kubectl get secrets</code>, and one should be named similar to <code>default-token-xxxxx</code>. Copy that token name for use below. ii. Get the certificate by running this command:</p> </blockquote> <pre><code>kubectl get secret &lt;secret name&gt; -o jsonpath=&quot;{['data']['ca\.crt']}&quot; | base64 --decode </code></pre> <blockquote> <p>If the command returns the entire certificate chain, you must copy the Root CA certificate and any intermediate certificates at the bottom of the chain. A chain file has following structure:</p> </blockquote> <pre><code> -----BEGIN MY CERTIFICATE----- -----END MY CERTIFICATE----- -----BEGIN INTERMEDIATE CERTIFICATE----- -----END INTERMEDIATE CERTIFICATE----- -----BEGIN INTERMEDIATE CERTIFICATE----- -----END INTERMEDIATE CERTIFICATE----- -----BEGIN ROOT CERTIFICATE----- -----END ROOT CERTIFICATE----- </code></pre>
<p>this is most likely really simple but I can't figure it out for 2 hours now. I have the following Consul Ingress that I want to parameterize through a parent chart:</p> <pre><code>spec: rules: {{- range .Values.uiIngress.hosts }} - host: {{ . }} http: paths: - backend: serviceName: {{ $serviceName }} servicePort: {{ $servicePort }} {{- end -}} {{- if .Values.uiIngress.tls }} tls: {{ toYaml .Values.uiIngress.tls | indent 4 }} {{- end -}} {{- end }} </code></pre> <p>I want to parameterize <code>spec.tls</code> in the above.</p> <p>In the <code>values.yaml</code> file for Consul we have the following template for it:</p> <pre><code>uiIngress: enabled: false annotations: {} hosts: [] tls: {} </code></pre> <p>The closest I got to parameterizing it is the following:</p> <pre><code> uiIngress: tls: - hosts: - "some.domain.com" secretName: "ssl-default" </code></pre> <p>When I do that I get this error though:</p> <p><code>warning: cannot overwrite table with non table for tls (map[])</code></p> <p>Can someone please help, I tried a million things.</p>
<p>If your default configuration values for this chart that are defined in the <code>values.yaml</code> file for Consul has this structure:</p> <pre><code>uiIngress: enabled: false annotations: {} hosts: [] tls: {} </code></pre> <p>And when you are executing <code>helm</code> command you are sending values like this:</p> <pre><code> uiIngress: tls: - hosts: - &quot;some.domain.com&quot; secretName: &quot;ssl-default&quot; </code></pre> <p>The error <code>warning: cannot overwrite table with non table for tls (map[])</code> is happening because of the fact that <code>tls</code> is defined as a dict <code>{}</code> in the <code>values.yaml</code> and you are trying to set value with the type list <code>[]</code>(<code>- hosts:</code>) to it. To fix the warning you can change provided <code>values.yaml</code> format to:</p> <pre><code>uiIngress: enabled: false annotations: {} tls: [] hosts: [] </code></pre>
<p>Where does the NGINX ingress controller stores temporary files?</p> <p>This is the message I receive and I am pretty sure it is storing the file on a volume attached to one of my pods:</p> <pre><code>2021/09/27 20:33:23 [warn] 33#33: *26 a client request body is buffered to a temporary file /var/cache/nginx/client_temp/0000000002, client: 10.42.1.0, server: _, request: &quot;POST /api/adm/os/image HTTP/1.1&quot;, host: &quot;vzredfish.cic.shidevops.com&quot;, referrer: &quot;https://vzredfish.cic.shidevops.com/setting&quot; </code></pre> <p>But when I go into the location <code>/var/cache/nginx/client_temp</code> there is nothing.</p> <p>I checked on the ingress controller pods too and there is another there either.</p> <p>I would like to know how to troubleshoot the issue we have. I'm trying to upload a file directly to the pod memory but instead it uploads it to a temporary location first.</p> <p>Thanks for the help.</p> <p>Danilo</p>
<p>Answering your question indirectly there seems to some ways to skip proxy buffering to achieve your goal of uploading a file directly to the pod memory, I've found an interesting article <a href="https://www.getpagespeed.com/server-setup/nginx/tuning-proxy_buffer_size-in-nginx" rel="nofollow noreferrer">here</a>, have a look at the <em>Disable proxy buffering</em> section.</p>
<p>I'm developing <a href="https://github.com/msrumon/microservice-architecture" rel="nofollow noreferrer">this dummy project</a> and trying to make it work locally via <code>Skaffold</code>.</p> <p>There are 3 services in my project (running on ports <code>3001</code>, <code>3002</code> and <code>3003</code> respectively), wired via <code>NATS server</code>.</p> <p>The problem is: I get different kinds of errors each time I run <code>skaffold debug</code>, and one/more service(s) don't work.</p> <p>At times, I don't get any errors, and all services work as expected. The followings are some of the errors:</p> <pre><code>Waited for &lt;...&gt;s due to client-side throttling, not priority and fairness, request: GET:https://kubernetes.docker.internal:6443/api/v1/namespaces/default/pods?labelSelector=app%!D(MISSING). &lt;...&gt;%!C(MISSING)app.kubernetes.io%!F(MISSING)managed-by%!D(MISSING)skaffold%!C(MISSING)skaffold.dev%!F(MISSING)run-id%!D(MISSING)&lt;...&gt;` (from `request.go:668`) - `0/1 nodes are available: 1 Insufficient cpu.` (from deployments) - `UnhandledPromiseRejectionWarning: NatsError: CONNECTION_REFUSED` (from apps) - `UnhandledPromiseRejectionWarning: Error: getaddrinfo EAI_AGAIN nats-service` (from apps) </code></pre> <p>I'm at a loss and can't help myself anymore. I hope someone here will be able to help me out.</p> <p>Thanks in advance.</p> <p>PS: Below is my machine's config, in case it's my machine's fault.</p> <pre><code>Processor: AMD Ryzen 7 1700 (8C/16T) Memory: 2 x 8GB DDR4 2667MHz Graphics: AMD Radeon RX 590 (8GB) OS: Windows 10 Pro 21H1 </code></pre> <pre class="lang-sh prettyprint-override"><code>$ docker version Client: Version: 19.03.12 API version: 1.40 Go version: go1.13.12 Git commit: 0ed913b8- Built: 07/28/2020 16:36:03 OS/Arch: windows/amd64 Experimental: false Server: Docker Engine - Community Engine: Version: 20.10.8 API version: 1.41 (minimum version 1.12) Go version: go1.16.6 Git commit: 75249d8 Built: Fri Jul 30 19:52:10 2021 OS/Arch: linux/amd64 Experimental: false containerd: Version: 1.4.9 GitCommit: e25210fe30a0a703442421b0f60afac609f950a3 runc: Version: 1.0.1 GitCommit: v1.0.1-0-g4144b63 docker-init: Version: 0.19.0 GitCommit: de40ad0 </code></pre> <pre class="lang-sh prettyprint-override"><code>$ kubectl version Client Version: version.Info{Major:&quot;1&quot;, Minor:&quot;22&quot;, GitVersion:&quot;v1.22.2&quot;, GitCommit:&quot;8b5a19147530eaac9476b0ab82980b4088bbc1b2&quot;, GitTreeState:&quot;clean&quot;, BuildDate:&quot;2021-09-15T21:38:50Z&quot;, GoVersion:&quot;go1.16.8&quot;, Compiler:&quot;gc&quot;, Platform:&quot;windows/amd64&quot;} Server Version: version.Info{Major:&quot;1&quot;, Minor:&quot;21&quot;, GitVersion:&quot;v1.21.4&quot;, GitCommit:&quot;3cce4a82b44f032d0cd1a1790e6d2f5a55d20aae&quot;, GitTreeState:&quot;clean&quot;, BuildDate:&quot;2021-08-11T18:10:22Z&quot;, GoVersion:&quot;go1.16.7&quot;, Compiler:&quot;gc&quot;, Platform:&quot;linux/amd64&quot;} </code></pre> <p>I use WSL2 (Debian) and <code>docker-desktop</code> is the context of Kubernetes.</p>
<pre><code>0/1 nodes are available: 1 Insufficient cpu. (from deployments) </code></pre> <p>This error clearly means your deployment doesn't have sufficient resources to startup.</p> <p>i tried deploying the same on my environment same error, 2 CPU is not enough to start this image.</p> <p>You might need a higher resource or big node to test</p> <p><a href="https://github.com/msrumon/microservice-template/blob/master/k8s/nats.yaml" rel="nofollow noreferrer">https://github.com/msrumon/microservice-template/blob/master/k8s/nats.yaml</a></p>
<h3>TL;DR</h3> <p>java.net.SocketException: Network is unreachable (connect failed) in simple Kubernetes pod that can curl to the internet.</p> <h3>Short Description</h3> <p>I've setup a simple Job object in Kubernetes, which spawns a simple pod to use the Slack-Api to poll for a conversation history via slack.</p> <p>Running this application locally or dockerized works like a charm. But when trying to execute it in Kubernetes I get a</p> <pre><code>java.net.SocketException: Network is unreachable (connect failed) at java.base/java.net.PlainSocketImpl.socketConnect(Native Method) at java.base/java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:399) at java.base/java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:242) at java.base/java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:224) at java.base/java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392) at java.base/java.net.Socket.connect(Socket.java:609) at okhttp3.internal.platform.Platform.connectSocket(Platform.kt:120) </code></pre> <h3>Kubernetes config</h3> <pre class="lang-yaml prettyprint-override"><code>apiVersion: batch/v1beta1 kind: CronJob metadata: name: my-app-job spec: schedule: &quot;*/1 * * * *&quot; jobTemplate: spec: template: spec: containers: - name: name image: myimage imagePullPolicy: Always ports: - containerPort: 443 protocol: TCP - containerPort: 80 protocol: TCP env: - name: http_proxy value: myproxy - name: https_proxy value: myproxy - name: no_proxy value: myproxy restartPolicy: OnFailure </code></pre> <p>Trying to debug what is happening, I noticed that I could curl something from my pod (so there's access to the public internet) but when I try to ping, i get Socket: Operation not permitted.</p> <p>Eg:</p> <pre><code>bash-4.2$ ping www.google.com ping: socket: Operation not permitted bash-4.2$ curl -I www.google.com HTTP/1.1 200 OK content-type: text/html; charset=ISO-8859-1 p3p: CP=&quot;This is not a P3P policy! See g.co/p3phelp for more info.&quot; date: Wed, 29 Sep 2021 09:18:36 GMT server: gws x-xss-protection: 0 x-frame-options: SAMEORIGIN expires: Wed, 29 Sep 2021 09:18:36 GMT cache-control: private set-cookie: XXXXXXXXXXX expires=Thu, 31-Mar-2022 09:18:36 GMT; path=/; domain=.google.com; HttpOnly x-cache: MISS from XXXXXXXXXXX x-cache-lookup: MISS fXXXXXXXXX bash-4.2$ command terminated with exit code 137 </code></pre> <p>I believe that I'm missing some configuration. I tried opening a port with a <code>NodePort</code> service but I had no success. Any ideas how to debug this?</p>
<p>Java does not inherit the proxy settings from the environment.</p> <p>You need to specify the proxy using Java system properties</p> <pre><code>-Dhttp.proxyHost=locahost -Dhttp.proxyPort=9900 </code></pre>
<p>I have what I would consider a common use case but I am really struggling to find a solution:</p> <p>I want to reuse a variable in <code>Kustomize</code> patches in our deployments. Specifically, we are using commit IDs to reference image tags (Use Case A) and k8s Jobs related to the deployments (Use Case B).</p> <p>We use a setup where for each ArgoCD app we have a <code>/base/</code> folder and <code>/overlays/[environment-name]</code>, this base is patched with a <code>kustomization.yaml</code>.</p> <h3>Use Case A:</h3> <p>A very straightforward usage - in <code>/overlays/[environment-name]</code> we have a <code>kustomization.yaml</code> which uses:</p> <pre><code>images: - name: our-aws-repo-url newName: our-aws-repo-url newTag: commit-id </code></pre> <p>Works like a charm since we can re-use this both for the Deployment itself as well as its related Jobs all with one commit reference.</p> <h3>Use Case B:</h3> <p>The problem:</p> <p>We use N Jobs to e.g. do migrations for 0 downtime deployments where we run alembic containers that run the migration and we have a <code>waitforit</code> <code>initContainer</code> that listens for the Job to get completed i.e. when the migration was successful in order to deploy.</p> <p>The problem is now that I need to touch 4 files in one service's overlay to patch the id everywhere (which we use to recognize the Job):</p> <ul> <li>deployment.yaml like so:</li> </ul> <pre><code>- image: groundnuty/k8s-wait-for:v1.4 imagePullPolicy: IfNotPresent args: - &quot;job&quot; - &quot;job-commit-id&quot; </code></pre> <ul> <li>job.yaml itself to change re-trigger of Job for new deployment/potential migration:</li> </ul> <pre><code>apiVersion: batch/v1 kind: Job metadata: name: job-commit-id </code></pre> <ul> <li>kustomization.yaml as described in Use Case A.</li> </ul> <p>What I think should be possible instead is to:</p> <ol> <li>define variable <code>commit-id</code> somehow in kustomization.yaml and</li> <li>for Use Case A &amp; B do something like:</li> </ol> <pre><code>apiVersion: batch/v1 kind: Job metadata: name: job-${commit-id} </code></pre> <pre><code>- image: groundnuty/k8s-wait-for:v1.4 imagePullPolicy: IfNotPresent args: - &quot;job&quot; - &quot;job-${commit-id}&quot; </code></pre> <pre><code>images: - name: our-aws-repo-url newName: our-aws-repo-url newTag: ${commit-id} </code></pre> <p>Goal: when developers do PRs for releases, they should only touch one reference to the commit ID to prevent typos etc. (also easier to review instead of checking commit ID in N places)</p> <p>Caveat: I am sure there is also another way to do migrations instead of Jobs but this is generally a common thing: how to re-use a variable inside kustomize.</p> <p>I know I can reference ENV variable in kustomize but I want to reuse a variable within the manifests.</p>
<blockquote> <p>but I want to reuse a variable within the manifests.</p> </blockquote> <p>This is not how you typically work with Kustomize. Its a good thing that things are <em>declarative</em> and <em>explicit</em> when working with Kustomize.</p> <blockquote> <p>when developers do PRs for releases, they should only touch one reference to the commit ID to prevent typos etc. (also easier to review instead of checking commit ID in N places)</p> </blockquote> <p>yes and no.</p> <p>That there is a change in four places should not be seen as a problem, in my opinion. That there is <em>human toil</em> to update four places <strong>is the problem</strong>.</p> <p>The solution to human toil is typically <strong>automation</strong>. By using <a href="https://github.com/mikefarah/yq" rel="nofollow noreferrer">yq</a> in an automated pipeline (e.g. Jenkins - or a shellscript) can you automate your manifest-update to take a single parameter - this can optionally be automated directly for each build after you have a git &quot;commit id&quot; available. The pipeline need to run four <code>yq</code>-commands to update the four Yaml fields. See e.g. <a href="https://mikefarah.gitbook.io/yq/operators/assign-update" rel="nofollow noreferrer">assign operation</a> and <a href="https://mikefarah.gitbook.io/yq/usage/github-action" rel="nofollow noreferrer">github action - pipeline example</a>. No other variables are needed.</p>
<p>While trying to add/update a dependency to a helm chart I'm getting this error. No helm plugins are installed with the name <code>helm-manager</code>.</p> <pre class="lang-sh prettyprint-override"><code>$ helm dep update Getting updates for unmanaged Helm repositories... ...Unable to get an update from the &quot;https://kubernetes-charts.storage.googleapis.com/&quot; chart repository: failed to fetch https://kubernetes-charts.storage.googleapis.com/index.yaml : 403 Forbidden ...Unable to get an update from the &quot;https://kubernetes-charts.storage.googleapis.com/&quot; chart repository: failed to fetch https://kubernetes-charts.storage.googleapis.com/index.yaml : 403 Forbidden Hang tight while we grab the latest from your chart repositories... ...Successfully got an update from the &quot;bitnami&quot; chart repository Update Complete. Happy Helming! Error: no cached repository for helm-manager-1067d9c6027b8c3f27b49e40521d64be96ea412858d8e45064fa44afd3966ddc found. (try 'helm repo update'): open /Users/&lt;redacted&gt;/Library/Caches/helm/repository/helm-manager-1067d9c6027b8c3f27b49e40521d64be96ea412858d8e45064fa44 afd3966ddc-index.yaml: no such file or directory </code></pre>
<p>The stable and incubator repositories of the Helm charts have been moved to a new location. You must updated URI in charts.yaml (or requirements.yaml) to point to the new repositories in order to let the Helm dependency resolver find the correct location.</p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th>Name</th> <th>Old Location</th> <th>New Location</th> </tr> </thead> <tbody> <tr> <td>stable</td> <td><a href="https://kubernetes-charts.storage.googleapis.com" rel="nofollow noreferrer">https://kubernetes-charts.storage.googleapis.com</a></td> <td><a href="https://charts.helm.sh/stable" rel="nofollow noreferrer">https://charts.helm.sh/stable</a></td> </tr> <tr> <td>incubator</td> <td><a href="https://kubernetes-charts-incubator.storage.googleapis.com" rel="nofollow noreferrer">https://kubernetes-charts-incubator.storage.googleapis.com</a></td> <td><a href="https://charts.helm.sh/incubator" rel="nofollow noreferrer">https://charts.helm.sh/incubator</a></td> </tr> </tbody> </table> </div> <p>After that you should be able to run <code>helm dep update</code> without further modifications.</p>
<p>I want to prevent the Horizontal auto-scaler from scaling down too early.I came across a doc that mentions we can update <code>/etc/kubernetes/manifests/kube-controller-manager.yaml</code> file on master node and edit this flag <code>--horizontal-pod-autoscaler-downscale-stabilization</code>. Is it possible for GKE in Google Cloud ?<br /> As far I know we cannot access the master node on GKE.</p>
<p>Per the Kubernetes official documentation [1] tuning the global HPA settings exposed as flags for the <code>kube-controller-manager</code> component. The flags for the <code>kube-controller-manager</code> are actually read from a configuration tar file when the master is created. The master node is managed by Google and they aren’t configurable by customers, so there’s no way to modify this parameter for now. However, I found this public issue [2]. A feature needs to have a handful of stars and, hopefully, comments from several users about how the feature would be useful, hence, there’s no ETA on implementation. Refer to this document [3].</p> <p>[1] <a href="https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale/#support-for-cooldown-delay" rel="nofollow noreferrer">https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale/#support-for-cooldown-delay</a></p> <p>[2] <a href="https://issuetracker.google.com/issues/117897819" rel="nofollow noreferrer">https://issuetracker.google.com/issues/117897819</a></p> <p>[3] <a href="https://cloud.google.com/support/docs/issue-trackers#feature_requests" rel="nofollow noreferrer">https://cloud.google.com/support/docs/issue-trackers#feature_requests</a></p>
<p>Here is my ingress:</p> <pre><code>apiVersion: networking.k8s.io/v1 kind: Ingress metadata: name: 8link-app-kubernetes-ingress annotations: kubernetes.io/ingress.class: nginx nginx.ingress.kubernetes.io/use-regex: &quot;true&quot; nginx.ingress.kubernetes.io/rewrite-target: / spec: rules: - host: link8.in http: paths: - backend: service: name: link8-app-prod-svc port: number: 80 path: / pathType: Prefix - host: test.link8.in http: paths: - backend: service: name: link8-app-prod-svc port: number: 80 path: / pathType: Prefix </code></pre> <p>In the above ingress, I have the same Front-end service which is defined to be run on both Domain and sub-domain (for the testing), it is working for sub-domain but not for the domain.</p> <p>I get Error 404 on domain path: <a href="https://i.stack.imgur.com/C2uhW.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/C2uhW.png" alt="enter image description here" /></a></p> <p>Following is my DNS settings, where value is my Ingress Address: <a href="https://i.stack.imgur.com/HmtEA.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/HmtEA.png" alt="enter image description here" /></a></p> <p><em><strong>UPDATE:</strong></em></p> <p><a href="https://i.stack.imgur.com/s8Mfv.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/s8Mfv.png" alt="enter image description here" /></a></p>
<p>In order to clear things for anyone, who will try to figure out the answer.</p> <p>The question was answered by the author.</p> <p>The problem was not in <code>Kubernetes</code> resources of any kind, it was a browser-specific issue, clearing the browser storage solved the problem.</p> <blockquote> <p>my problem wasn't related to k8s;<br /> it was working from start.<br /> Just I had to clear everything for my domain in chrome storage</p> </blockquote> <hr /> <p><a href="https://i.stack.imgur.com/4ZILN.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/4ZILN.png" alt="enter image description here" /></a></p>
<p>I'm currently using the Python APIs for Kubernetes and I have to:</p> <ul> <li><p>Retrieve the instance of a custom resource name <code>FADepl</code>.</p> </li> <li><p>Edit the value of that instance.</p> </li> </ul> <p>In the terminal, I would simply list all <code>FADepls</code> with <code>kubectl get fadepl</code> and then edit the right one using <code>kubectl edit fadepl &lt;fadepl_name&gt;</code>. I checked the <a href="https://github.com/kubernetes-client/python/blob/master/kubernetes/README.md" rel="nofollow noreferrer">K8s APIs for Python</a> but I can't find what I need. Is it something I can do with the APIs?</p> <p>Thank you in advance!</p>
<p>You're right. Using <a href="https://github.com/kubernetes-client/python/blob/master/kubernetes/docs/CustomObjectsApi.md#get_namespaced_custom_object" rel="nofollow noreferrer"><strong><code>get_namespaced_custom_object</code></strong></a> you can retrieve the instance. This method returns a namespace scoped custom object. By default it uses a synchronous HTTP request.</p> <p>Since the output of that method returns an object, you can simply replace it using <a href="https://github.com/kubernetes-client/python/blob/master/kubernetes/docs/CustomObjectsApi.md#replace_cluster_custom_object" rel="nofollow noreferrer"><strong><code>replace_cluster_custom_object</code></strong></a>.</p> <p><a href="https://www.programcreek.com/python/?CodeExample=replace+namespaced+custom+object" rel="nofollow noreferrer">Here</a> you can find implementation examples.</p> <p>See also whole list of <a href="https://aiokubernetes.readthedocs.io/en/latest/api_reference.html" rel="nofollow noreferrer">API Reference for Python</a>.</p>
<p>I have pod A (it's actually the kube-scheduler pod) and pod B (a pod that has a REST API that will be invoked by pod A).</p> <p>For this purpose, I created a ClusterIP service.</p> <p>Now, when I exec into pod A to perform the API call to pod B, I get: <code>curl: (6) Could not resolve host: my-svc.default.svc.cluster.local</code></p> <p>I tried to follow the debug instructions mentioned <a href="https://kubernetes.io/docs/tasks/administer-cluster/dns-debugging-resolution/" rel="nofollow noreferrer">here</a>:</p> <pre><code>kubectl exec -i -t dnsutils -- nslookup my-svc.default Server: 10.96.0.10 Address: 10.96.0.10#53 Name: my-svc.default.svc.cluster.local Address: 10.111.181.13 </code></pre> <p>Also:</p> <pre><code>kubectl exec -i -t dnsutils -- nslookup kubernetes.default Server: 10.96.0.10 Address: 10.96.0.10#53 Name: kubernetes.default.svc.cluster.local Address: 10.96.0.1 </code></pre> <p>This seems to be working as expected. However, when I exec into pod A, I get:</p> <pre><code>kubectl exec -it kube-scheduler -n kube-system -- sh /bin # nslookup kubernetes.default Server: 8.8.8.8 Address: 8.8.8.8:53 ** server can't find kubernetes.default: NXDOMAIN ** server can't find kubernetes.default: NXDOMAIN </code></pre> <p>Other debugging steps (inside pod A) include:</p> <pre><code>/bin # cat /etc/resolv.conf nameserver 8.8.8.8 nameserver 172.30.0.1 </code></pre> <p>And:</p> <pre><code>/bin # cat /etc/*-release 3.12.8 NAME=&quot;Alpine Linux&quot; ID=alpine VERSION_ID=3.12.8 PRETTY_NAME=&quot;Alpine Linux v3.12&quot; HOME_URL=&quot;https://alpinelinux.org/&quot; BUG_REPORT_URL=&quot;https://bugs.alpinelinux.org/&quot; </code></pre> <p>There are no useful logs from the coredns pods, either.</p> <pre><code>kubectl logs --namespace=kube-system -l k8s-app=kube-dns .:53 [INFO] plugin/reload: Running configuration MD5 = db32ca3650231d74073ff4cf814959a7 CoreDNS-1.7.0 linux/amd64, go1.14.4, f59c03d .:53 [INFO] plugin/reload: Running configuration MD5 = db32ca3650231d74073ff4cf814959a7 CoreDNS-1.7.0 linux/amd64, go1.14.4, f59c03d </code></pre> <p>From the <a href="https://kubernetes.io/docs/tasks/administer-cluster/dns-debugging-resolution/" rel="nofollow noreferrer">documentation</a>, it seems there is a known issue with Alpine and DNS resolution (even though the version I have is greater than the version they mentioned).</p> <p>Is there a workaround this to enable accessing the service properly from the Alpine pod?</p> <hr /> <p>Edit providing pod A manifest:</p> <pre><code>apiVersion: v1 kind: Pod metadata: creationTimestamp: null labels: component: kube-scheduler tier: control-plane name: kube-scheduler namespace: kube-system spec: containers: - command: - kube-scheduler - --authentication-kubeconfig=/etc/kubernetes/scheduler.conf - --authorization-kubeconfig=/etc/kubernetes/scheduler.conf - --bind-address=127.0.0.1 - --config=/etc/kubernetes/sched-cs.yaml - --port=0 image: localhost:5000/scheduler-plugins/kube-scheduler:latest imagePullPolicy: IfNotPresent livenessProbe: failureThreshold: 8 httpGet: host: 127.0.0.1 path: /healthz port: 10259 scheme: HTTPS initialDelaySeconds: 10 periodSeconds: 10 timeoutSeconds: 15 name: kube-scheduler resources: requests: cpu: 100m startupProbe: failureThreshold: 24 httpGet: host: 127.0.0.1 path: /healthz port: 10259 scheme: HTTPS initialDelaySeconds: 10 periodSeconds: 10 timeoutSeconds: 15 volumeMounts: - mountPath: /etc/kubernetes/scheduler.conf name: kubeconfig readOnly: true - mountPath: /etc/kubernetes/sched-cs.yaml name: sched-cs readOnly: true hostNetwork: true priorityClassName: system-node-critical volumes: - hostPath: path: /etc/kubernetes/scheduler.conf type: FileOrCreate name: kubeconfig - hostPath: path: /etc/kubernetes/sched-cs.yaml type: FileOrCreate name: sched-cs status: {} </code></pre> <hr /> <p>Edit 2: Adding the following lines <strong>manually</strong> to <code>/etc/resolv.conf</code> of Pod A allows me to perform the curl request successfully.</p> <pre><code>nameserver 10.96.0.10 search default.svc.cluster.local svc.cluster.local cluster.local options ndots:5 </code></pre> <p>Wouldn't there be a cleaner/less manual way to achieve the same result?</p>
<p>Try setting the <code>DNSPolicy</code> for pod A (or whatever deployment, statefulset, etc.) defines its template to <code>ClusterFirst</code> or <code>ClusterFirstWithHostNet</code>.</p> <p>The behavior of this setting depends on how your cluster and kubelet are set up, but in most default configurations this will make the kubelet set resolv.conf inside the pod to use the kube-dns service that you manually set in your edit (10.96.0.10), which will forward lookups outside the cluster to the nameservers for the host.</p> <p><a href="https://kubernetes.io/docs/concepts/services-networking/dns-pod-service/#pod-s-dns-policy" rel="nofollow noreferrer">K8s docs</a></p>
<p><code>Fluxcd</code> <code>ImageRepository</code> authentication with <code>AWS Elastic Container Registry</code> Not working on <code>ARM64 graviton</code> node.</p> <p>After debugging I found that the image used in the <code>init container</code> to get cred credentials is not supporting <code>Arm64</code> instances.</p> <pre><code>image name:-bitnami/kubectl </code></pre> <p><strong>doc link:-https://fluxcd.io/docs/guides/image-update/</strong></p>
<p>There are some workarounds, provided on the <code>fluxcd</code> documentation portal:</p> <ul> <li><a href="https://fluxcd.io/docs/guides/image-update/#aws-elastic-container-registry" rel="nofollow noreferrer">AWS Elastic Container Registry</a></li> <li><a href="https://fluxcd.io/docs/guides/image-update/#using-a-json-key-long-lived" rel="nofollow noreferrer">Using a JSON key</a></li> <li><a href="https://fluxcd.io/docs/guides/image-update/#using-static-credentials-long-lived" rel="nofollow noreferrer">Using Static Credentials</a></li> </ul> <h1>AWS Elastic Container Registry</h1> <blockquote> <p>The solution proposed is to create a cronjob that runs every 6 hours which would re-create the <code>docker-registry</code> secret using a new token.</p> </blockquote> <h1>JSON key</h1> <blockquote> <p>A Json key doesn’t expire, so we don’t need a cronjob, we just need to create the secret and reference it in the ImagePolicy. First, create a json key file by following this <a href="https://cloud.google.com/container-registry/docs/advanced-authentication" rel="nofollow noreferrer">documentation</a>. Grant the service account the role of <code>Container Registry Service Agent</code> so that it can access GCR and download the json file.</p> </blockquote> <h1>Static Credentials</h1> <blockquote> <p>Instead of creating the Secret directly into your Kubernetes cluster, encrypt it using <a href="https://fluxcd.io/docs/guides/mozilla-sops/" rel="nofollow noreferrer">Mozilla SOPS</a> or <a href="https://fluxcd.io/docs/guides/sealed-secrets/" rel="nofollow noreferrer">Sealed Secrets</a>, then commit and push the encypted file to git.</p> </blockquote> <blockquote> <p>This Secret should be in the same Namespace as your flux <code>ImageRepository</code> object. Update the <code>ImageRepository.spec.secretRef</code> to point to it.</p> </blockquote>
<p>I have a PV <code>alpha-pv</code> in the kubernetes cluster and have created a PVC matching the PV specs. The PV uses the <code>Storage Class: slow</code>. However, when I check the existence of Storage Class in Cluster there is no Storage Class existing and still my PVC was <code>Bound</code> to the PV.</p> <p>How is this Possible when the Storage Class referred in the PV/PVC does not exists in the cluster?</p> <p>If I don't mention the Storage Class in PVC, I get error message stating Storage Class Set. There is already an existing PV in the cluster which has <code>RWO</code> access modes, <code>1Gi</code> storage size and with the Storage class named <code>slow</code>. But on checking the Storage Class details, there is no Storage Class resource in cluster.</p> <p>If I add the Storage Class name <code>slow</code> in my PVC <code>mysql-alpha-pvc</code>, then the PVC binds to the PV. But I'm not clear how this happens when the Storage Class referred in PV/PVC named <code>slow</code> doesn't exist in the cluster.</p> <p><a href="https://i.stack.imgur.com/a0oJR.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/a0oJR.png" alt="Storage Class Error in PVC" /></a></p> <p><a href="https://i.stack.imgur.com/1qCTl.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/1qCTl.png" alt="PVC Bound to PV even when the Storage class named &quot;slow&quot; does not exists in Cluster " /></a></p>
<h2>Short answer</h2> <p>It depends.</p> <h2>Theory</h2> <p>One of the main purpose of using a <code>storageClass</code> is <a href="https://kubernetes.io/blog/2016/10/dynamic-provisioning-and-storage-in-kubernetes/" rel="nofollow noreferrer">dynamic provisioning</a>. That means that persistent volumes will be automatically provisioned once persistent volume claim requests for the storage: immediately or after pod using this <code>PVC</code> is created. See <a href="https://kubernetes.io/docs/concepts/storage/storage-classes/#volume-binding-mode" rel="nofollow noreferrer">Volume binding mode</a>.</p> <p>Also:</p> <blockquote> <p>A StorageClass provides a way for administrators to describe the &quot;classes&quot; of storage they offer. Different classes might map to quality-of-service levels, or to backup policies, or to arbitrary policies determined by the cluster administrators. Kubernetes itself is unopinionated about what classes represent. This concept is sometimes called &quot;profiles&quot; in other storage systems.</p> </blockquote> <p><a href="https://kubernetes.io/docs/concepts/storage/storage-classes/#introduction" rel="nofollow noreferrer">Reference</a>.</p> <h2>How it works</h2> <p>If for instance kubernetes is used in cloud (Google GKE, Azure AKS or AWS EKS), they have already had predefined <code>storageClasses</code>, for example this is from Google GKE:</p> <pre><code>$ kubectl get storageclasses NAME PROVISIONER RECLAIMPOLICY VOLUMEBINDINGMODE ALLOWVOLUMEEXPANSION AGE premium-rwo pd.csi.storage.gke.io Delete WaitForFirstConsumer true 27d standard (default) kubernetes.io/gce-pd Delete Immediate true 27d standard-rwo pd.csi.storage.gke.io Delete WaitForFirstConsumer true 27d </code></pre> <p>So you can create <code>PVC</code>'s and refer to <code>storageClass</code>, <code>PV</code> will be created for you.</p> <hr /> <p>Another scenario which you faced is you can create <code>PVC</code> and <code>PV</code> with any custom <code>storageClassName</code> only for binding purposes. Usually it's used for testing something locally. This is also called <a href="https://kubernetes.io/docs/concepts/storage/persistent-volumes/#static" rel="nofollow noreferrer">static provisioning</a>.</p> <p>In this case you can create &quot;fake&quot; storage class which won't exist in kubernetes server.</p> <p>Please see <a href="https://kubernetes.io/docs/tasks/configure-pod-container/configure-persistent-volume-storage/" rel="nofollow noreferrer">an example with such type of binding</a>:</p> <blockquote> <p>It defines the StorageClass name manual for the PersistentVolume, which will be used to bind PersistentVolumeClaim requests to this PersistentVolume.</p> </blockquote> <h2>Useful links:</h2> <ul> <li><a href="https://kubernetes.io/docs/concepts/storage/storage-classes/" rel="nofollow noreferrer">Kubernetes storage classes</a></li> <li><a href="https://kubernetes.io/blog/2016/10/dynamic-provisioning-and-storage-in-kubernetes/" rel="nofollow noreferrer">Kubernetes dynamic provisioning</a></li> <li><a href="https://kubernetes.io/docs/concepts/storage/persistent-volumes/" rel="nofollow noreferrer">Kubernetes persistent volumes</a></li> </ul>
<p><code>Istio-citadel</code> pods of <code>istio 1.4.10 helm</code> release, are restarted periodically.</p> <p>2 replicas of <code>istio-citadel</code> are running.</p> <p>This happens once in every 4-5 days, when the number of CSR requests reaches 28.3k and memory reaches 9.8G. Memory increases steadily after the restart until it crashes again. CPU spike is also observed consuming around 10 CPU.</p> <p>Could see the below error log 4 mins before the restart.</p> <pre><code>Sep 27, 2021 @ 12:20:39.3702021-09-27T06:50:39.370213Z error ca.liveness turns unavailable: 1 error occurred: Sep 27, 2021 @ 12:20:39.370 * liveness: rpc error: code = Unavailable desc = all SubConns are in TransientFailure, latest connection error: connection error: desc = &quot;transport: Error while dialing dial tcp &lt;citadel-service-ip&gt;:8060: connect: cannot assign requested address&quot; </code></pre> <p>Want to understand the error message and the reason that could explain periodic restart.</p>
<p>@p10l is right: <code>citadel</code> was replaced by <code>Istio CA</code></p> <p>There is a commit more than year ago: <a href="https://github.com/istio/istio.io/pull/6825" rel="nofollow noreferrer"> replace Citadel with Istio CA by istio-testing · Pull Request #6825 · istio/istio.io</a></p> <p>Also, there are commits in documentation:</p> <ul> <li><a href="https://github.com/istio/istio.io/pull/9624" rel="nofollow noreferrer">Remove citadel reference by jacob-delgado · Pull Request #9624 · istio/istio.io</a></li> <li><a href="https://github.com/istio/istio.io/pull/7872" rel="nofollow noreferrer">Remove citadel from installation instructions by myidpt · Pull Request #7872 · istio/istio.io</a></li> <li><a href="https://github.com/istio/istio.io/pull/7398" rel="nofollow noreferrer">Best-Practices: Remove reference to Citadel. by justinpettit · Pull Request #7398 · istio/istio.io</a></li> </ul> <p>So, i'd suggest to update your <code>istio</code></p>
<p>I have an (internal) K8s deployment (Python, TensorFlow, Guinicorn) with around 60 replicas and an attached K8s service to distribute incoming HTTP requests. Each of these 60 pods can only actually process one HTTP request at a time (because of TensorFlow reasons). Processing a request takes between 1 and 4 seconds. If a second request is sent to a pod while it's still processing one, the second request is just queued in the Gunicorn backlog.</p> <p>Now I'd like to reduce the probability of that queuing happening as much as possible, i.e., have new requests routed to one of the non-occupied pods as long as such a non-occupied one exists.</p> <p>Round-robin would not do the trick, because not every request takes the same amount of time to answer (see above).</p> <p>The Python application itself could make the endpoint used for the ReadinessProbe fail while it's processing a normal request, but as far as I understand, readiness probes are not meant for something that dynamic (K8s would need to poll them multiple times per second).</p> <p>So how could I achieve the goal?</p>
<p>Can't you implement the pub/sub or message broker in between?</p> <p>saver data into a queue based on the ability you worker will fetch the message or data from queue and request will get processed.</p> <p>You can use Redis for creating queues and in queue, you can use pub/sub also possible using the library. i used one before in Node JS however could be possible to implement the same using python also.</p> <p>in 60 replicas ideally worker or we can say scriber will be running.</p> <p>As soon as you get a request one application will publish it and scribers will be continuously working for processing those messages.</p> <p>We also implemented one step further, scaling the worker count automatically depends on the message count in the queue.</p> <p>This library i am using with the Node js : <a href="https://github.com/OptimalBits/bull" rel="nofollow noreferrer">https://github.com/OptimalBits/bull</a></p>
<p>I have a deployment on Minikube for a .Net Core 5 API that is not returning response when I try to invoke it from Postman. When I run a GET from Postman to the exposed port (32580) and endpoint <code>http:// localhost:32580/api/platforms/</code> I get:</p> <pre><code>Error: getaddrinfo ENOTFOUND </code></pre> <p>Oddly enough I was previously getting a <code>Connection refused</code> (before I restarted my Docker desktop). The container works perfectly when I use Docker but once I deployed it to Kubernetes context it no longer works.</p> <p>I am unsure how exactly I can debug the container and get more meaningful error detail.</p> <p>I have tried the following:</p> <ol> <li>Checking status of Deployment (platforms-depl)</li> </ol> <hr /> <pre><code>NAME READY UP-TO-DATE AVAILABLE AGE hello-minikube 1/1 1 1 134d ping-google 0/1 1 0 2d2h platforms-depl 1/1 1 1 115m </code></pre> <ol start="2"> <li>Checking status of Pod (platforms-depl-84d7f5bdc6-sgxcp)</li> </ol> <hr /> <pre><code>NAME READY STATUS RESTARTS AGE hello-minikube-6ddfcc9757-6mfmf 1/1 Running 21 134d ping-google-5f84d66fcc-kbb7j 0/1 ImagePullBackOff 151 2d2h platforms-depl-84d7f5bdc6-sgxcp 1/1 Running 1 115m </code></pre> <ol start="3"> <li>Running <code>kubectl describe pod platforms-depl-84d7f5bdc6-sgxcp</code> gives below output (truncated):</li> </ol> <hr /> <pre><code>Status: Running IP: 172.17.0.3 IPs: IP: 172.17.0.3 Controlled By: ReplicaSet/platforms-depl-84d7f5bdc6 Containers: platformservice: Container ID: docker://a73ce2dc737206e502df94066247299a6dcb6a038087d0f42ffc6e3b9dd194dd Image: golide/platformservice:latest Image ID: docker-pullable://golide/platformservice@sha256:bbed5f1d7238d2c466a6782333f8512d2e464f94aa64d8670214646a81b616c7 Port: &lt;none&gt; Host Port: &lt;none&gt; State: Running Started: Tue, 28 Sep 2021 15:12:22 +0200 Ready: True Restart Count: 0 Environment: &lt;none&gt; Mounts: /var/run/secrets/kubernetes.io/serviceaccount from default-token-rl5kf (ro) Conditions: Type Status Initialized True Ready True ContainersReady True PodScheduled True </code></pre> <ol start="4"> <li><p>When I run <code>docker ps</code> I cannot see the container and it also doesn't appear in the list of running containers in VS Code Docker/Containers extension.</p> </li> <li><p><code>kubectl get services</code> gives me the following:</p> </li> </ol> <hr /> <pre><code>NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE hello-minikube NodePort 10.99.23.44 &lt;none&gt; 8080:31378/TCP 134d kubernetes ClusterIP 10.96.0.1 &lt;none&gt; 443/TCP 134d paymentsapi NodePort 10.111.243.3 &lt;none&gt; 5000:30385/TCP 108d platformnpservice-srv NodePort 10.98.131.95 &lt;none&gt; 80:32580/TCP 2d2h </code></pre> <p>Then tried pinging the ClusterIP:</p> <pre><code>Pinging 10.98.131.95 with 32 bytes of data: Request timed out. Request timed out. Ping statistics for 10.98.131.95: Packets: Sent = 4, Received = 0, Lost = 4 (100% loss), </code></pre> <p>What am I missing?</p> <p>I read in suggestions I have to exec into the pod so that I get meaningful output but I'm not sure of the exact commands to run. I tried:</p> <pre><code>kubectl exec POD -p platforms-depl-84d7f5bdc6-sgxcp </code></pre> <p>only to get error:</p> <pre><code>kubectl exec [POD] [COMMAND] is DEPRECATED and will be removed in a future version. Use kubectl exec [POD] -- [COMMAND] instead. Error from server (NotFound): pods &quot;POD&quot; not found </code></pre> <p>My environment Docker Linux containers with WSL2 on Windows 10.</p> <p>What am I missing?</p>
<p>First thing which is worth to note that generally minikube has a lot of possible <a href="https://minikube.sigs.k8s.io/docs/drivers/" rel="nofollow noreferrer">drivers to choose from</a> - in my case I found the <code>docker</code> drive to be most easiest to use.</p> <p>My setup is:</p> <ul> <li>WSL2</li> <li>Docker Desktop with <a href="https://docs.docker.com/desktop/windows/wsl/" rel="nofollow noreferrer">Docker Desktop WLS 2 backend enabled</a></li> </ul> <p>I used following command to start minikube: <code>minikube start --driver=docker</code>. If you are using other driver I suggest moving to the <code>docker</code> one.</p> <p>Answering your question:</p> <p><em>What am I missing ?</em></p> <p>By setting nodePort service type you are exposing your deployment / replica set using node IP address which not accessible from Windows host (when using <code>docker</code> driver). It's because all Kubernetes cluster resources are setup inside Docker container, which is isolated.</p> <p>However, minikube offers simple solution to make available specified nodePort service to your Windows host. <a href="https://minikube.sigs.k8s.io/docs/commands/service/" rel="nofollow noreferrer">Just run <code>minikube service</code> command which will create a tunnel</a>. Let's check it.</p> <p>You setup <code>platformnpservice-srv</code> service so you need to use this name in <code>minikube service</code> command instead of <code>testmini</code> which I used:</p> <pre><code>minikube service --url testmini 🏃 Starting tunnel for service testmini. |-----------|----------|-------------|------------------------| | NAMESPACE | NAME | TARGET PORT | URL | |-----------|----------|-------------|------------------------| | default | testmini | | http://127.0.0.1:33849 | |-----------|----------|-------------|------------------------| http://127.0.0.1:33849 ❗ Because you are using a Docker driver on linux, the terminal needs to be open to run it. </code></pre> <p>Note the last sentence - we need to keep this terminal window to be open, otherwise the tunnel won't be established. Now, on my Windows host, in the browser I'm opening: <code>http://127.0.0.1:33849/api/platforms</code> website. The output is following:</p> <pre><code>[{&quot;id&quot;:1,&quot;name&quot;:&quot;Dot Net&quot;,&quot;publisher&quot;:&quot;Microsoft&quot;,&quot;cost&quot;:&quot;Free&quot;},{&quot;id&quot;:2,&quot;name&quot;:&quot;Linux&quot;,&quot;publisher&quot;:&quot;Ubuntu&quot;,&quot;cost&quot;:&quot;Free&quot;},{&quot;id&quot;:3,&quot;name&quot;:&quot;Kubernetes&quot;,&quot;publisher&quot;:&quot;CNCF&quot;,&quot;cost&quot;:&quot;Free&quot;},{&quot;id&quot;:4,&quot;name&quot;:&quot;SQL Express&quot;,&quot;publisher&quot;:&quot;Microsoft&quot;,&quot;cost&quot;:&quot;Free&quot;}] </code></pre> <p>Voila! Seems that everything is working properly.</p> <p>Also, other notes:</p> <blockquote> <p>tried pinging the ClusterIP</p> </blockquote> <p>The ClusterIP is <a href="https://kubernetes.io/docs/concepts/services-networking/service/#publishing-services-service-types" rel="nofollow noreferrer">internal address which is only accessible from the cluster</a>, so you can't ping it from Windows host neither WSL2.</p> <blockquote> <p><em>kubectl exec POD -p platforms-depl-84d7f5bdc6-sgxcp</em></p> </blockquote> <p>As output suggests, you need to <a href="https://kubernetes.io/docs/reference/generated/kubectl/kubectl-commands#exec" rel="nofollow noreferrer">specify command you want to exec on the pod</a>. If you just want to get bash shell, use the following:</p> <pre><code>kubectl exec -it platforms-depl-84d7f5bdc6-sgxcp -- sh </code></pre>
<p>I was trying to add permission to view nodes to my admin IAM using information in this article (<a href="https://aws.amazon.com/premiumsupport/knowledge-center/eks-kubernetes-object-access-error/" rel="nofollow noreferrer">https://aws.amazon.com/premiumsupport/knowledge-center/eks-kubernetes-object-access-error/</a>) and ended up saving the configmap with a malformed mapUsers section (didn't include the username at all)</p> <p>Now every kubectl command return an error like this: Error from server (Forbidden): nodes is forbidden: User &quot;&quot; cannot list resource &quot;nodes&quot; in API group &quot;&quot; at the cluster scope</p> <p>How can I circumvent corrupted configmap and regain access to the cluster? I found two questions at Stackoverflow but as I am very new to kubernetes and still buffled as to exactly I need to do.</p> <p><a href="https://stackoverflow.com/questions/59085639/mistakenly-updated-configmap-aws-auth-with-rbac-lost-access-to-the-cluster">Mistakenly updated configmap aws-auth with rbac &amp; lost access to the cluster</a></p> <p>I have an access to root user but kubectl doesn't work for this user, too.</p> <p>Is there another way to authenticate to the cluster?</p> <h2>Update 1</h2> <p>Yesterday I recreated this problem on a new cluster: I still got this error even if I am the root user.</p> <p>The structure of the configmap goes like this:</p> <pre><code>apiVersion: v1 data: mapRoles: &lt;default options&gt; mapUsers: | - userarn: arn:aws:iam::&lt;root id&gt;:root username: #there should be a username value on this line, but it's missing in my configmap; presumable this is the cause groups: - system:bootstrappers - system:nodes </code></pre> <h2>Update 2</h2> <p>Tried to use serviceAccount token, got an error:</p> <pre><code>Error from server (Forbidden): configmaps &quot;aws-auth&quot; is forbidden: User &quot;system:serviceaccount:kube-system:aws-node&quot; cannot get resource &quot;configmaps&quot; in API group &quot;&quot; in the namespace &quot;kube-system&quot; </code></pre>
<p>How did you create your cluster? The IAM user, or IAM role, that you used to actually create it, is grandfathered in as a sysadmin. So long as you use the same credentials that you used for</p> <p><code>aws eks create-cluster</code></p> <p>You can do</p> <p><code>aws eks update-kubeconfig</code>, followed by using kubectl to modify the configmap and give other entites the permissions.</p> <p>You haven't said what you actually tried. Lets do some more troubleshooting-</p> <ol> <li><p><code>system:serviceaccount:kube-system:aws-node</code> this is saying that THIS kubernetes user does not have permission to modify configmaps. But, that is completely correct- it SHOULDNT. What command did you run to get that error? What were the contents of your kubeconfig context to generate that message? Did you run the command from a worker node maybe?</p> </li> <li><p>You said &quot;I have access to the root user&quot;. Access in what way? Through the console? With an <code>AWS_SECRET_ACCESS_KEY</code>? You'll need the second - assuming thats the case run <code>aws iam get-caller-identity</code> and post the results.</p> </li> <li><p>Root user or not, the only user that has guaranteed access to the cluster is the one that created it. Are there ANY OTHER IAM users or roles in your account? Do you have cloudtrail enabled? If so, you could go back and check the logs and verify that it was the root user that issued the create cluster command.</p> </li> <li><p>After running <code>get-caller-identity</code>, remove your .kube/config file and run <code>aws eks update-kubeconfig</code>. Tell us the output from the command, and the contents of the new config file.</p> </li> <li><p>Run <code>kubectl auth can-i '*' '*'</code> with the new config and let us know the result.</p> </li> </ol>
<p>I would like to specify dependent environment variables on a Cloud Run service.</p> <p>If the environment variables have been defined in a <code>.env</code> file it would look like this</p> <pre><code>DATABASE_NAME=my-database DATABASE_USER=root DATABASE_PASSWORD=P4SSw0rd! DATABASE_PORT=5432 DATABASE_HOST=&quot;/socket/my-database-socket&quot; DATABASE_URL=&quot;user=${DATABASE_USER} password=${DATABASE_PASSWORD} dbname=${DATABASE_NAME} host=${DATABASE_HOST}&quot; </code></pre> <p>In this example, <code>DATABASE_URL</code> depends on every other environment variables.</p> <p>To deploy the service I run the following command:</p> <pre><code>gcloud run deploy my-service \ --image gcr.io/my-project/my-image:latest \ --region europe-west1 \ --port 80 \ --platform managed \ --allow-unauthenticated \ --set-env-vars 'DATABASE_NAME=my-database' \ --set-env-vars 'DATABASE_USER=root' \ --set-env-vars 'DATABASE_PASSWORD=P4SSw0rd!' \ --set-env-vars 'DATABASE_PORT=5432' \ --set-env-vars 'DATABASE_HOST=&quot;/socket/my-database-socket&quot;' \ --set-env-vars 'DATABASE_URL=&quot;user=$(DATABASE_USER) password=$(DATABASE_PASSWORD) dbname=$(DATABASE_NAME) host=$(DATABASE_HOST)&quot;' </code></pre> <p>Here is the created YAML definition of the service (some values are omitted)</p> <pre class="lang-yaml prettyprint-override"><code>apiVersion: serving.knative.dev/v1 kind: Service metadata: name: my-service spec: template: metadata: name: ... spec: containerConcurrency: 80 timeoutSeconds: 300 containers: - image: ... ports: - name: http1 containerPort: 80 env: - name: DATABASE_NAME value: my-database - name: DATABASE_USER value: root - name: DATABASE_PASSWORD value: P4SSw0rd! - name: DATABASE_HOST value: /socket/my-database-socket - name: DATABASE_URL value: user=$(DATABASE_USER) password=$(DATABASE_PASSWORD) dbname=$(DATABASE_NAME) host=$(DATABASE_HOST) </code></pre> <p>The problem is that when the service is running, the env vars in <code>DATABASE_URL</code> seem not interpolated.</p> <p>I read that <a href="https://kubernetes.io/docs/tasks/inject-data-application/define-interdependent-environment-variables/" rel="nofollow noreferrer">Kubernetes supports dependent env vars</a> but I can't figure out how to make this run in Cloud Run.</p> <p>I am wondering if it is supported in Cloud Run in the end.</p>
<p>It's likely this may work in Knative open source (which uses Kubernetes to execute pods) but not on Google Cloud Run (fully hosted), which runs on a proprietary execution engine.</p>
<p>Today when I create the PVC and PV in kubernetes cluster v1.15.x, the kubernetes dashboard shows the PVC is in lost state, this is the error message of PVC:</p> <pre><code>this claim is in lost state. </code></pre> <p>this is my PVC define:</p> <pre><code>{ &quot;kind&quot;: &quot;PersistentVolumeClaim&quot;, &quot;apiVersion&quot;: &quot;v1&quot;, &quot;metadata&quot;: { &quot;name&quot;: &quot;zhuolian-report-mysql-pv-claim&quot;, &quot;namespace&quot;: &quot;dabai-uat&quot;, &quot;selfLink&quot;: &quot;/api/v1/namespaces/dabai-uat/persistentvolumeclaims/zhuolian-report-mysql-pv-claim&quot;, &quot;uid&quot;: &quot;3ca3425b-b2dc-4bd7-876f-05f8cbcafcf8&quot;, &quot;resourceVersion&quot;: &quot;106652242&quot;, &quot;creationTimestamp&quot;: &quot;2021-09-26T02:58:32Z&quot;, &quot;annotations&quot;: { &quot;pv.kubernetes.io/bind-completed&quot;: &quot;yes&quot; }, &quot;finalizers&quot;: [ &quot;kubernetes.io/pvc-protection&quot; ] }, &quot;spec&quot;: { &quot;accessModes&quot;: [ &quot;ReadWriteOnce&quot; ], &quot;resources&quot;: { &quot;requests&quot;: { &quot;storage&quot;: &quot;8Gi&quot; } }, &quot;volumeName&quot;: &quot;nfs-zhuolian-report-mysql-pv&quot;, &quot;volumeMode&quot;: &quot;Filesystem&quot; }, &quot;status&quot;: { &quot;phase&quot;: &quot;Lost&quot; } } </code></pre> <p>and this is my PV define in the same namespace:</p> <pre><code>{ &quot;kind&quot;: &quot;PersistentVolume&quot;, &quot;apiVersion&quot;: &quot;v1&quot;, &quot;metadata&quot;: { &quot;name&quot;: &quot;nfs-zhuolian-report-mysql-pv&quot;, &quot;selfLink&quot;: &quot;/api/v1/persistentvolumes/nfs-zhuolian-report-mysql-pv&quot;, &quot;uid&quot;: &quot;86291e89-8360-4d48-bae7-62c3c642e945&quot;, &quot;resourceVersion&quot;: &quot;106652532&quot;, &quot;creationTimestamp&quot;: &quot;2021-09-26T03:01:02Z&quot;, &quot;labels&quot;: { &quot;alicloud-pvname&quot;: &quot;zhuolian-report-data&quot; }, &quot;finalizers&quot;: [ &quot;kubernetes.io/pv-protection&quot; ] }, &quot;spec&quot;: { &quot;capacity&quot;: { &quot;storage&quot;: &quot;8Gi&quot; }, &quot;nfs&quot;: { &quot;server&quot;: &quot;balabala.cn-hongkong.nas.balabala.com&quot;, &quot;path&quot;: &quot;/docker/mysql_zhuolian_report_data&quot; }, &quot;accessModes&quot;: [ &quot;ReadWriteOnce&quot; ], &quot;claimRef&quot;: { &quot;kind&quot;: &quot;PersistentVolumeClaim&quot;, &quot;namespace&quot;: &quot;dabai-uat&quot;, &quot;name&quot;: &quot;zhuolian-report-mysql-pv-claim&quot; }, &quot;persistentVolumeReclaimPolicy&quot;: &quot;Retain&quot;, &quot;mountOptions&quot;: [ &quot;vers=4.0&quot;, &quot;noresvport&quot; ], &quot;volumeMode&quot;: &quot;Filesystem&quot; }, &quot;status&quot;: { &quot;phase&quot;: &quot;Available&quot; } } </code></pre> <p>what should I do do fix this problem? how to avoid problem like this? what may cause this problem?</p>
<p>try to delete the PVC's annoation will make the PVC rebind:</p> <pre><code>&quot;annotations&quot;: { &quot;pv.kubernetes.io/bind-completed&quot;: &quot;yes&quot; }, </code></pre> <p>I copied the PVC from another PVC and forget to remove the annotation.</p>
<p>I've been reading through docs and can't find a clear answer on how to do this.</p> <p>I have an AWS EFS claim and a storage class which i have applied. I have a PV and PVC that are in a namespace and can see the storage class, which i assume is cluster wide.</p> <p>If i try to apply the same PV and PVC manifests to a different namespace i get an error that the storage class is not found.</p> <p>If i then delete these i get the following warning:</p> <pre><code>warning: deleting cluster-scoped resources, not scoped to the provided namespace persistentvolume &quot;efs-pv&quot; deleted </code></pre> <p>This is really confusing.</p> <p>How would i share this efs storage between different namespaces? do i need to make changes to the PV and PVC (at the moment i already have persistentVolumeReclaimPolicy: Retain), and what do i apply to which namespace? what is cluster wide and what is namespace scoped?</p>
<p>Presumed you can do <code>aws efs describe-file-systems</code> to see your EFS is correctly configured and you have the <code>FileSystemId</code> ready for mount.</p> <p>You have also installed the AWS EFS CSI driver and all driver pods are running with no issue.</p> <p>For StorageClass you only create <strong>once</strong> for each type.</p> <p>For PersistentVolume you only create <strong>once</strong> for each mount point (static).</p> <p>In case of simultaneous access from <strong>different</strong> namespaces, you create one PersistentVolumeClaim in each namespace that referred the same StorageClass.</p> <pre><code>... kind: StorageClass metadata: name: my-efs-sc &lt;--- This name MUST be referred across PVC/PC provisioner: efs.csi.aws.com &lt;--- MUST have EFS CSI driver installed ... kind: PersistentVolume spec: storageClassName: my-efs-sc &lt;--- Have you verify the name? ... accessModes: - ReadWriteMany &lt;--- MUST use this mode ... kind: PersistentVolumeClaim metadata: ... namespace: my-namespace-A &lt;--- namespace scope spec: storageClassName: my-efs-sc &lt;--- Have you verify the name? accessModes: - ReadWriteMany &lt;--- MUST use this mode ... kind: PersistentVolumeClaim metadata: ... namespace: my-namespace-B &lt;--- namespace scope spec: storageClassName: my-efs-sc &lt;--- Have you verify the name? accessModes: - ReadWriteMany &lt;--- MUST use this mode ... </code></pre> <p>Check the PVC/PV status with kubectl to ensure all are bound correctly.</p>
<p>I have a pod attached to a daemonset node and which also contains several containers. I want to update the container images inside the pod. Therefore I am curious to know if restarting the the daemonset will do the job (because image Pull Policy is currently set to always) and restarting the daemonset will pull the new updated image. Is it the right way to do such things? Thanks.</p>
<p>Use <code>kubectl set image -n &lt;namespace&gt; daemonset &lt;ds name&gt; &lt;container name&gt;=&lt;image&gt;:&lt;tag&gt;</code> will do the trick and does not require restart command.</p> <p>To see the update status <code>kubectl rollout status -n &lt;namespace&gt; daemonset &lt;ds name&gt;</code></p>
<p>I'm trying to deploy postgres as a <code>StatefulSet</code> on <code>k3d</code>.</p> <p>I set the environment variable <code>POSTGRES_USER</code>, but when I try to connect to the db, it isn't taken into account and I see that authentication has failed. I can login with the password <code>pgpassword</code> and default user <code>postgres</code>.</p> <p>Why isn't the <code>POSTGRES_USER</code> taken into account?</p> <p>This is my yml:</p> <pre class="lang-yaml prettyprint-override"><code>apiVersion: apps/v1 kind: StatefulSet metadata: name: postgresql-db spec: serviceName: postgresql-db-service selector: matchLabels: app: postgresql-db replicas: 2 template: metadata: labels: app: postgresql-db spec: containers: - name: postgresql-db image: postgres:latest volumeMounts: - name: postgresql-db-disk mountPath: /data env: - name: POSTGRES_USER value: pguser - name: POSTGRES_PASSWORD value: pgpassword - name: PGDATA value: /data/pgdata volumes: - name: postgresql-db-disk hostPath: # directory location on host path: /opt/x/projects/tilt_test/data/ # this field is optional type: DirectoryOrCreate </code></pre>
<blockquote> <p>but when i try to connect to the db, it isn't taken into account, and i see that authentication has failed.</p> </blockquote> <p>It works exactly as it should. The <code>POSTGRES_USER</code> and <code>POSTGRES_PASSWORD</code> system variables are used to create the default user and password when creating the database. <strong>If, on the other hand, you intend to log in to an existing user later, you must set and use system variables: <code>PGUSER</code> and <code>PGPASSWORD</code>.</strong> <a href="https://www.postgresql.org/docs/10/libpq-envars.html" rel="nofollow noreferrer">Here</a> is the explanation:</p> <blockquote> <ul> <li><p><code>PGUSER</code> behaves the same as the <a href="https://www.postgresql.org/docs/10/libpq-connect.html#LIBPQ-CONNECT-USER" rel="nofollow noreferrer">user</a> connection parameter.</p> </li> <li><p><code>PGPASSWORD</code> behaves the same as the <a href="https://www.postgresql.org/docs/10/libpq-connect.html#LIBPQ-CONNECT-PASSWORD" rel="nofollow noreferrer">password</a> connection parameter. Use of this environment variable is not recommended for security reasons, as some operating systems allow non-root users to see process environment variables via ps; instead consider using a password file (see <a href="https://www.postgresql.org/docs/10/libpq-pgpass.html" rel="nofollow noreferrer" title="33.15. The Password File">Section 33.15</a>).</p> </li> </ul> </blockquote> <p>You can also find a complete tutorial <a href="https://devopscube.com/deploy-postgresql-statefulset/" rel="nofollow noreferrer">How to Deploy PostgreSQL Statefulset in Kubernetes With High Availability</a>. Additionally, you will find an explanation for <code>POSTGRES_USER</code> and <code>POSTGRES_PASSWORD</code> system variables:</p> <blockquote> <p>POSTGRES_USER: The user that should be created automatically when the Postgres process starts. POSTGRES_PASSWORD: The password for the user created by default.</p> </blockquote> <p>In this case, logging into the database takes place during readiness and liveness probes.</p>
<p>I am trying to adapt the quickstart guide for Mongo Atlas Operator here <a href="https://www.mongodb.com/blog/post/introducing-atlas-operator-kubernetes" rel="nofollow noreferrer">Atlas Operator Quickstart</a> to use secure env variables set in TravisCI.</p> <p>I want to put the quickstart scripts into my deploy.sh, which is triggered from my travis.yaml file.</p> <p>My travis.yaml already sets one global variable like this:</p> <pre><code>env: global: - SHA=$(git rev-parse HEAD) </code></pre> <p>Which is consumed by the deploy.sh file like this:</p> <pre><code>docker build -t mydocker/k8s-client:latest -t mydocker/k8s-client:$SHA -f ./client/Dockerfile ./client </code></pre> <p>but I'm not sure how to pass vars set in the Environment variables bit in the travis Settings to deploy.sh</p> <p><a href="https://i.stack.imgur.com/C3Pyi.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/C3Pyi.png" alt="env vars" /></a></p> <p>This is the section of script I want to pass variables to:</p> <pre><code> kubectl create secret generic mongodb-atlas-operator-api-key \ --from-literal=&quot;orgId=$MY_ORG_ID&quot; \ --from-literal=&quot;publicApiKey=$MY_PUBLIC_API_KEY&quot; \ --from-literal=&quot;privateApiKey=$MY_PRIVATE_API_KEY&quot; \ -n mongodb-atlas-system </code></pre> <p>I'm assuming the --from-literal syntax will just put in the literal string &quot;orgId=$MY_ORG_ID&quot; for example, and I need to use pipe syntax - but can I do something along the lines of this?:</p> <pre><code>echo &quot;$MY_ORG_ID&quot; | kubectl create secret generic mongodb-atlas-operator-api-key --orgId-stdin </code></pre> <p>Or do I need to put something in my travis.yaml before_install script?</p>
<p>Looks like the <code>echo</code> approach is fine, I've found a similar use-case to yours, have a look <a href="https://drew-buckman.medium.com/use-travis-ci-to-automate-the-deployment-of-a-python-app-to-ibm-code-engine-4b534b503055" rel="nofollow noreferrer">here</a>.</p>
<p>When the pod is Evicted by disk issue, I found there are two reasons:</p> <ol> <li>The node had condition: <code>[DiskPressure]</code></li> <li>The node was low on resource: ephemeral-storage. Container NAME was using 16658224Ki, which exceeds its request of 0.</li> </ol> <p>I found <a href="https://kubernetes.io/docs/concepts/scheduling-eviction/node-pressure-eviction/#node-conditions" rel="nofollow noreferrer">Node conditions</a> for <code>DiskPressure</code>.</p> <p>What is the difference?</p>
<p>Both reasons are caused by the same error - that the worker node has ran out of disk space. However, the difference is when they are exactly happening.</p> <p>To answer this question I decided to dig inside <a href="https://github.com/kubernetes/kubernetes" rel="noreferrer">Kubernetes source code</a>.</p> <p>Starting with <code>The node had condition: [DiskPressure]</code> error.</p> <p>We can find that it is used in <code>pkg/kubelet/eviction/helpers.go</code> file, <a href="https://github.com/kubernetes/kubernetes/blob/ea0764452222146c47ec826977f49d7001b0ea8c/pkg/kubelet/eviction/helpers.go#L44" rel="noreferrer">line 44</a>:</p> <pre><code>nodeConditionMessageFmt = &quot;The node had condition: %v. &quot; </code></pre> <p>This variable is used by <code>Admit</code> function in <code>pkg/kubelet/eviction/eviction_manager.go</code> file, <a href="https://github.com/kubernetes/kubernetes/blob/2ba872513da76568274885f8c5736b415a77b0cd/pkg/kubelet/eviction/eviction_manager.go#L137" rel="noreferrer">line 137</a>.</p> <p><code>Admit</code> function is used by <code>canAdmitPod</code> function in <code>pkg/kubelet/kubelet.go</code> file, <a href="https://github.com/kubernetes/kubernetes/blob/047a6b9f861b2cc9dd2eea77da752ac398e7546f/pkg/kubelet/kubelet.go#L1932" rel="noreferrer">line 1932</a>:</p> <p><code>canAdmitPod</code> function is used by <code>HandlePodAdditions</code> function, also in the <code>kubelet.go</code> file, <a href="https://github.com/kubernetes/kubernetes/blob/047a6b9f861b2cc9dd2eea77da752ac398e7546f/pkg/kubelet/kubelet.go#L2195" rel="noreferrer">line 2195</a>.</p> <p>Comments in the code in <code>Admit</code> and <code>canAdmitPod</code> functions:</p> <blockquote> <p>canAdmitPod determines if a pod can be admitted, and gives a reason if it cannot. &quot;pod&quot; is new pod, while &quot;pods&quot; are all admitted pods. The function returns a boolean value indicating whether the pod can be admitted, a brief single-word reason and a message explaining why the pod cannot be admitted.</p> </blockquote> <p>and</p> <blockquote> <p>Check if we can admit the pod; if not, reject it.</p> </blockquote> <p>So based on this analysis we can conclude that <code>The node had condition: [DiskPressure]</code> error message happens when kubelet agent won't admit <strong>new</strong> pods on the node, that means they won't start.</p> <hr /> <p>Now moving on to the second error - <code>The node was low on resource: ephemeral-storage. Container NAME was using 16658224Ki, which exceeds its request of 0</code></p> <p>Similar as before, we can find it in <code>pkg/kubelet/eviction/helpers.go</code> file, <a href="https://github.com/kubernetes/kubernetes/blob/ea0764452222146c47ec826977f49d7001b0ea8c/pkg/kubelet/eviction/helpers.go#L42" rel="noreferrer">line 42</a>:</p> <pre><code>nodeLowMessageFmt = &quot;The node was low on resource: %v. &quot; </code></pre> <p>This variable is used in the same file by <code>evictionMessage</code> function, <a href="https://github.com/kubernetes/kubernetes/blob/ea0764452222146c47ec826977f49d7001b0ea8c/pkg/kubelet/eviction/helpers.go#L1003" rel="noreferrer">line 1003</a>.</p> <p><code>evictionMessage</code> function is used by <code>synchronize</code> function in <code>pkg/kubelet/eviction/eviction_manager.go</code> file, <a href="https://github.com/kubernetes/kubernetes/blob/ea0764452222146c47ec826977f49d7001b0ea8c/pkg/kubelet/eviction/eviction_manager.go#L231" rel="noreferrer">line 231</a></p> <p><code>synchronize</code> function is used by <code>start</code> function, in the same file, <a href="https://github.com/kubernetes/kubernetes/blob/2ba872513da76568274885f8c5736b415a77b0cd/pkg/kubelet/eviction/eviction_manager.go#L177" rel="noreferrer">line 177</a>.</p> <p>Comments in the code in the <code>synchronize</code> and <code>start</code> functions:</p> <blockquote> <p>synchronize is the main control loop that enforces eviction thresholds. Returns the pod that was killed, or nil if no pod was killed.</p> </blockquote> <blockquote> <p>Start starts the control loop to observe and response to low compute resources.</p> </blockquote> <p>So we can conduct that the error <code>The node was low on resource:</code> error message happens when kubelet agent decides to kill currently <strong>running</strong> pods on the node.</p> <hr /> <p>It is worth emphasising that both error messages comes from node conditions (which are set in function <code>synchronize</code>, <a href="https://github.com/kubernetes/kubernetes/blob/2ba872513da76568274885f8c5736b415a77b0cd/pkg/kubelet/eviction/eviction_manager.go#L308" rel="noreferrer">line 308</a>, to the values detected by eviction manager). Then kubelet's agent makes the decisions that results in these two error messages.</p> <hr /> <p><strong>To sum up</strong>:</p> <p>Both errors are due to insufficient disk space, but:</p> <ul> <li><code>The node had condition:</code> error is related to the pods that are <strong>about to start</strong> on the node, but they can't</li> <li><code>The node was low on resource:</code> error is related to the <strong>currently running pods</strong> that must be terminated</li> </ul>
<p><a href="https://github.com/oussamabouchikhi/udagram-microservices" rel="nofollow noreferrer">Github repo</a></p> <p>After I configured the <code>kubectl</code> with the AWS EKS cluster, I deployed the services using these commands:</p> <pre><code>kubectl apply -f env-configmap.yaml kubectl apply -f env-secret.yaml kubectl apply -f aws-secret.yaml # this is repeated for all services kubectl apply -f svcname-deploymant.yaml kubectl apply -f svcname-service.yaml </code></pre> <p><a href="https://i.stack.imgur.com/WT9Bn.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/WT9Bn.png" alt="enter image description here" /></a></p> <p>The other services ran successfully but the reverse proxy returned an error and when I investigated by running the command <code>kubectl describe pod reverseproxy...</code> I got this info:</p> <p><a href="https://pastebin.com/GaREMuyj" rel="nofollow noreferrer">https://pastebin.com/GaREMuyj</a></p> <p><strong>[Edited]</strong></p> <p>After running the command <code>kubectl logs -f reverseproxy-667b78569b-qg7p</code> I get this: <a href="https://i.stack.imgur.com/ixk7s.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ixk7s.png" alt="enter image description here" /></a></p>
<p>As <a href="https://stackoverflow.com/users/10008173/david-maze" title="75,885 reputation">David Maze</a> very rightly pointed out, your problem is not reproducible. You haven't provided all the configuration files, for example. However, the error you received clearly tells about the problem:</p> <pre><code>host not found in upstream &quot;udagram-users: 8080&quot; in /etc/nginx/nginx.conf:11 </code></pre> <p>This error makes it clear that you are trying to connect to host <code>udagram-users: 8080</code> as defined in file <code>/etc/nginx/nginx.conf</code> on line 11.</p> <blockquote> <p>And how can I solve it please?</p> </blockquote> <p>You need to check the connection. (It is also possible that you entered the wrong hostname or port in the config). You mentioned that you are using multiple subnets:</p> <blockquote> <p>it is using 5 subnets</p> </blockquote> <p>In such a situation, it is very likely that there is no connection because the individual components operate on different networks and will never be able to communicate with each other. If you run all your containers on one network, it should work. If, on the other hand, you want to use multiple subnets, you need to ensure container-to-container communication across multiple subnets.</p> <p>See also this <a href="https://stackoverflow.com/questions/33639138/docker-networking-nginx-emerg-host-not-found-in-upstream">similar problem</a> with many possible solutions.</p>
<p>Trying to patch my custom resource to add extra element into an Array.</p> <p>Works fine using kubectl:</p> <pre><code>kubectl patch my-resource default --type=json -p '[ { "op":"add", "path": "/spec/data/-", "value": "3342, 43243.343, 434343" } ]' -v 9 </code></pre> <p>but can't make it work using Python:</p> <pre><code>body = '[ { "op":"add", "path":"/spec/data/-", "value": "3342, 43243.343, 434343" } ]' api_response = api_instance.patch_namespaced_custom_object(group, version, namespace, plural, name, json.loads(body) ) </code></pre> <p>getting Response</p> <pre><code>"status":"Failure","message":"json: cannot unmarshal array into Go value of type map[string]interface {}","code":500 </code></pre> <p>weirdly when I drop [ ] and just pass a {}</p> <pre><code>api_response = api_instance.patch_namespaced_custom_object(group, version, namespace, plural, name, json.loads('{ "spec": { "data": [ "3342, 43243.343, 434343" ] } } ') ) </code></pre> <p>it works, but the effect is not what I want - it overwrites the "data" Array completely, whilst I want to append.</p> <p>What am I missing?</p>
<p>Might be too late for this, but here it goes anyway...</p> <p>Kubernetes Python API supports JSON-merge patching strategy only: <a href="https://github.com/kubernetes-client/python/blob/96dade6021dc2e9ee1430172e1b65d9e9e232b10/kubernetes/client/api/custom_objects_api.py#L2943" rel="nofollow noreferrer">https://github.com/kubernetes-client/python/blob/96dade6021dc2e9ee1430172e1b65d9e9e232b10/kubernetes/client/api/custom_objects_api.py#L2943</a></p> <p>That strategy implies you can't extend arrays: <a href="https://kubernetes.io/docs/tasks/manage-kubernetes-objects/update-api-object-kubectl-patch/#use-a-json-merge-patch-to-update-a-deployment" rel="nofollow noreferrer">https://kubernetes.io/docs/tasks/manage-kubernetes-objects/update-api-object-kubectl-patch/#use-a-json-merge-patch-to-update-a-deployment</a></p>
<p>Iam trying to set up aws cluster. I installed kubectl and configured aws with credentials. When I tried to display pods or any kubectl commands, Iam getting this error</p> <pre><code>revaa@revaa-Lenovo-E41-25:~$ kubectl get pod Unable to connect to the server: dial tcp 10.0.12.77:443: i/o timeout </code></pre> <p>How to resolve this</p>
<p>The ip used is a private, it cannot be accessed outside the aws. Change your cluster's api server endpoint access to public. It worked.</p>
<p>I have the following <code>pv.yaml</code> Kubernetes/Kustomization file:</p> <pre><code>apiVersion: v1 kind: PersistentVolume metadata: name: myapp-common-pv namespace: myapp labels: app.kubernetes.io/name: myapp-common-pv app.kubernetes.io/component: common-pv app.kubernetes.io/part-of: myapp spec: capacity: storage: 30Gi accessModes: - ReadWriteMany nfs: path: /myapp_nfs_share server: &lt;omitted for security purposes&gt; --- apiVersion: v1 kind: PersistentVolumeClaim metadata: name: myapp-common-pvc spec: accessModes: - ReadWriteMany storageClassName: &quot;&quot; volumeName: myapp-common-pv resources: requests: storage: 30gi </code></pre> <p>When I run this I get:</p> <pre><code>persistentvolume/myapp-common-pv unchanged Error from server (BadRequest): error when creating &quot;/Users/myuser/workspace/myapp/k8s/pv&quot;: PersistentVolumeClaim in version &quot;v1&quot; cannot be handled as a PersistentVolumeClaim: v1.PersistentVolumeClaim.Spec: v1.PersistentVolumeClaimSpec.StorageClassName: Resources: v1.ResourceRequirements.Requests: unmarshalerDecoder: quantities must match the regular expression '^([+-]?[0-9.]+)([eEinumkKMGTP]*[-+]?[0-9]*)$', error found in #10 byte of ...|ge&quot;:&quot;30gi&quot;}},&quot;storag|..., bigger context ...|teMany&quot;],&quot;resources&quot;:{&quot;requests&quot;:{&quot;storage&quot;:&quot;30gi&quot;}},&quot;storageClassName&quot;:&quot;&quot;,&quot;volumeName&quot;:&quot;myapp-common|... </code></pre> <p>Above, <code>&lt;omitted for security purposes&gt;</code> <em>is</em> a valid IP address, I just removed it for...security purposes.</p> <p>I'm setting <code>storageClassName: &quot;&quot;</code> due to <a href="https://cloud.google.com/filestore/docs/accessing-fileshares" rel="nofollow noreferrer">this article explaining why its necessary</a>.</p> <p><strong>Can anyone spot what's wrong with my <code>pv.yaml</code> file?</strong> And what I need to do (<em>specifically!</em>) to fix it?</p>
<blockquote> <p>quantities must match the regular expression '^([+-]?[0-9.]+)([eEinumkKMGTP]<em>[-+]?[0-9]</em>)$', error found in #10 byte of ...|ge&quot;:&quot;30gi&quot;}}</p> </blockquote> <p>Change</p> <pre><code>storage: 30gi </code></pre> <p>to</p> <pre><code>storage: 30Gi </code></pre> <p>The <code>Gi</code> part must follow the <a href="https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/#setting-requests-and-limits-for-local-ephemeral-storage" rel="noreferrer">predefined units</a>.</p>
<p>Does the Kubernetes scheduler assign the pods to the nodes one by one in a queue (not in parallel)?</p> <p>Based on <a href="https://kubernetes.io/docs/concepts/scheduling-eviction/scheduler-perf-tuning/#how-the-scheduler-iterates-over-nodes" rel="nofollow noreferrer">this</a>, I guess that might be the case since it is mentioned that the nodes are iterated round robin.</p> <p>I want to make sure that the pod scheduling is not being done in parallel.</p>
<h2>Short answer</h2> <p>Taking into consideration all the processes <code>kube-scheduler</code> performs when it's scheduling the pod, the answer is <strong>yes</strong>.</p> <h2>Scheduler and pods</h2> <blockquote> <p>For <strong>every newly created pod or other unscheduled pods</strong>, kube-scheduler selects an optimal node for them to run on. However, <strong>every container</strong> <strong>in pods</strong> has different requirements for resources and every pod also has different requirements. Therefore, existing nodes need to be filtered according to the specific scheduling requirements.</p> <p>In a cluster, Nodes that meet the scheduling requirements for a Pod are called feasible nodes. If none of the nodes are suitable, the pod remains unscheduled until the scheduler is able to place it.</p> <p>The scheduler finds feasible Nodes for a Pod and then runs a set of functions to score the feasible Nodes and picks a Node with the highest score among the feasible ones to run the Pod. The scheduler then notifies the API server about this decision in a process called binding.</p> </blockquote> <p><a href="https://kubernetes.io/docs/concepts/scheduling-eviction/kube-scheduler" rel="nofollow noreferrer">Reference - kube-scheduler</a>.</p> <blockquote> <p>The scheduler determines which Nodes are valid placements for <strong>each Pod in the scheduling queue</strong> according to constraints and available resources.</p> </blockquote> <p><a href="https://kubernetes.io/docs/reference/command-line-tools-reference/kube-scheduler/#synopsis" rel="nofollow noreferrer">Reference - kube-scheduler - synopsis</a>.</p> <p>In short words, <code>kube-scheduler</code> picks up pods one by one, assess them and its requests, then proceeds to finding appropriate <code>feasible</code> nodes to schedule pods on.</p> <h2>Scheduler and nodes</h2> <p>Mentioned link is related to nodes to give a fair chance to run pods across all <code>feasible</code> nodes.</p> <blockquote> <p>Nodes in a cluster that meet the scheduling requirements of a Pod are called feasible Nodes for the Pod</p> </blockquote> <p>Information here is related to default <code>kube-scheduler</code>, there are solutions which can be used or even it's possible to implement self-written one. Also it's possible to run <a href="https://kubernetes.io/docs/tasks/extend-kubernetes/configure-multiple-schedulers/" rel="nofollow noreferrer">multiple schedulers in cluster</a>.</p> <h2>Useful links:</h2> <ul> <li><a href="https://kubernetes.io/docs/concepts/scheduling-eviction/kube-scheduler/#kube-scheduler-implementation" rel="nofollow noreferrer">Node selection in kube-scheduler</a></li> <li><a href="https://kubernetes.io/docs/concepts/scheduling-eviction/kube-scheduler" rel="nofollow noreferrer">Kubernetes scheduler</a></li> </ul>
<p>I have k8tes cluster in which I am facing issues while mounting the existing volume to the pod in the new deployment. I have the existing deployments where I am mounting the same existing PV and PVCs. But facing issues only new deployment.</p> <p>What could be the reason? How can I mount(NFS) volume to the new deployments because both PV and PVC statuses are bound and claimed respectively?</p>
<p>you can not ideally If your mount mode is set to <strong>ReadWriteOnce</strong>.</p> <p>If you are planning to use the NFS and want to attach multiple PODs to a single mount you have to use the <strong>ReadWriteMany</strong>.</p> <p>Example :</p> <pre><code>--- apiVersion: v1 kind: PersistentVolumeClaim metadata: name: nfs-data spec: accessModes: - ReadWriteMany resources: requests: storage: 2Gi storageClassName: nfs </code></pre> <blockquote> <p>A PersistentVolumeClaim (PVC) is a request for storage by a user. It is similar to a Pod. Pods consume node resources and PVCs consume PV resources. Pods can request specific levels of resources (CPU and Memory). Claims can request specific size and access modes (e.g., they can be mounted ReadWriteOnce, ReadOnlyMany or ReadWriteMany, see AccessModes).</p> </blockquote> <p>Acces mode : <a href="https://kubernetes.io/docs/concepts/storage/persistent-volumes/#access-modes" rel="nofollow noreferrer">https://kubernetes.io/docs/concepts/storage/persistent-volumes/#access-modes</a></p> <p>GKE example : <a href="https://medium.com/platformer-blog/nfs-persistent-volumes-with-kubernetes-a-case-study-ce1ed6e2c266" rel="nofollow noreferrer">https://medium.com/platformer-blog/nfs-persistent-volumes-with-kubernetes-a-case-study-ce1ed6e2c266</a></p>
<p>I am running my docker image in my local machine (executing my performance test based on the arguments provided) with the following command <a href="https://i.stack.imgur.com/tYGgL.png" rel="nofollow noreferrer">like this</a></p> <p>whereas, satheeshpandianj/my-perf-app is my image name and rest (QA Commerce ListMarkets 1 5 Volvo) are arguments passed to this image to run. I have already pushed this image to docker hub. I want to run this docker image in kubernetes. I wrote the deployment yaml file like below.</p> <pre><code>apiVersion: apps/v1 kind: Deployment metadata: labels: app: perf name: perf spec: replicas: 1 selector: matchLabels: app: perf template: metadata: labels: app: perf spec: containers: image: docker.io/satheeshpandianj/my-perf-app name: perf args: [&quot;QA&quot;, &quot;Commerce&quot;, ListMarkets&quot;, 1, 5, &quot;Volvo&quot;] </code></pre> <p>When I am executing &quot;kubectl apply -f perf.yaml&quot;, I am getting a below <a href="https://i.stack.imgur.com/NyWKa.png" rel="nofollow noreferrer">error</a></p> <p>Can someone help me to resolve this error? Or please correct me what changes need to be made in my yaml file. Thanks in advance.</p>
<p>You are getting this error because the spec.containers, expects a list. You have to update your yaml to this:</p> <pre><code>apiVersion: apps/v1 kind: Deployment metadata: labels: app: perf name: perf spec: replicas: 1 selector: matchLabels: app: perf template: metadata: labels: app: perf spec: containers: - image: docker.io/satheeshpandianj/my-perf-app name: perf args: [&quot;QA&quot;, &quot;Commerce&quot;, ListMarkets&quot;, 1, 5, &quot;Volvo&quot;] </code></pre> <p>Yes, only the <code>-</code> is missing</p>
<p>I have an app that get data from a third-party data source, it will send data to my app automatically and I can't filter it, I can only receive all. When data arrive, my app will transmit this data to a rocketmq topic.</p> <p>Now I have to make this app a container and deploy it in k8s deployment with 3 replica. But these pods will all get same data and send to the same rocketmq topic.</p> <p>How do I make this app horizontal scalable without sending duplicate msg to the same rocketmq topic?</p>
<blockquote> <p>Now I have to make this app a container and deploy it in k8s deployment with 3 replica. But these pods will all get same data and send to the same rocketmq topic.</p> </blockquote> <blockquote> <p>There is no request. My app connect to a server and it will send data to app by TCP. Every Pod will connect to that server.</p> </blockquote> <p>If you want to do this with more than one instance, they need to coordinate in some way.</p> <p><a href="https://medium.com/hybrid-cloud-hobbyist/leader-election-architecture-kubernetes-32600da81e3c" rel="nofollow noreferrer">Leader Election pattern</a> is a way to run multiple instances, but only one can be active (e.g. when you read from the same queue). This is a pattern to coordinate - only one instance is active at the time. So this pattern only use your replicas for <em>higher availability</em>.</p> <p>If you want that all your replicas actively work, this can be done with techniques like <a href="https://stackoverflow.com/a/58678622/213269">sharding or partitioning</a>. This is also how e.g. <a href="https://www.instaclustr.com/the-power-of-kafka-partitions-how-to-get-the-most-out-of-your-kafka-cluster/" rel="nofollow noreferrer">Kafka</a> (e.g. similar to a queue) makes <strong>concurrent work</strong> from queues.</p> <p>There are other ways to solve this problem as well, e.g. to implement some form of locks to coordinate - but partitioning or sharding as in Kafka is probably the most &quot;cloud native&quot; solution.</p>
<p>I have deployed my Kubernetes cluster on EKS. I have an ingress-nginx which is exposed via load balancer to route traffic to different services. In ingress-nginx first request goes to auth service for authentication and if it is a valid request then I allow it to move forward. This is done using ingress-nginx annotation <strong>nginx.ingress.kubernetes.io/auth-url</strong>. Auth service is developed using FastAPI. In case of <strong>401</strong> response from fastAPI look like this <a href="https://i.stack.imgur.com/uI2Za.png" rel="nofollow noreferrer">FASTAPI</a></p> <p>But when I use ingress-nginx the response look like this <a href="https://i.stack.imgur.com/wt5UA.png" rel="nofollow noreferrer">INGRESS_NGINX</a></p> <p>Is there a way to get JSON respone from Ingress-nginx? Ingress File</p> <pre><code>apiVersion: networking.k8s.io/v1beta1 kind: Ingress metadata: name: ingress-service annotations: kubernetes.io/ingress.class: 'nginx' nginx.ingress.kubernetes.io/use-regex: 'true' nginx.ingress.kubernetes.io/rewrite-target: /$1 nginx.ingress.kubernetes.io/auth-response-headers: item_id nginx.ingress.kubernetes.io/auth-method: POST nginx.ingress.kubernetes.io/auth-url: http://pth-auth.default.svc.cluster.local:8000/item/1 # UPDATE THIS LINE ABOVE spec: rules: - http: paths: - path: /?(.*) # UPDATE THIS LINE ABOVE backend: serviceName: client-cluster-ip-service servicePort: 3000 - path: /api/?(.*) # UPDATE THIS LINE ABOVE backend: serviceName: server-cluster-ip-service servicePort: 5000 - path: /pth-auth/?(.*) # UPDATE THIS LINE ABOVE backend: serviceName: pth-auth servicePort: 8000 </code></pre>
<p>Here's a solution that worked for me. It allows the auth service to return a custom error message for each request.</p> <p>The caveat is that because nginx can't access auth response body, the <code>pth-auth</code> service needs to put the data in <code>Pth-Auth-Error</code> header (base64-encoded).</p> <p>This example handles 401, 500, and a special case when <code>pth-auth</code> service is unavailable.</p> <pre class="lang-yaml prettyprint-override"><code>apiVersion: networking.k8s.io/v1beta1 kind: Ingress metadata: name: ingress-service annotations: kubernetes.io/ingress.class: 'nginx' nginx.ingress.kubernetes.io/use-regex: 'true' nginx.ingress.kubernetes.io/rewrite-target: /$1 nginx.ingress.kubernetes.io/auth-response-headers: item_id nginx.ingress.kubernetes.io/auth-method: POST nginx.ingress.kubernetes.io/auth-url: http://pth-auth.default.svc.cluster.local:8000/item/1 # UPDATE THIS LINE ABOVE nginx.ingress.kubernetes.io/configuration-snippet: | # Redirect auth errors to custom named locations error_page 401 = @ingress_service_custom_error_401; error_page 500 = @ingress_service_custom_error_500; # Grab data from auth error response auth_request_set $pth_auth_error $upstream_http_pth_auth_error; auth_request_set $pth_auth_error_content_type $upstream_http_content_type; auth_request_set $pth_auth_status $upstream_status; nginx.ingress.kubernetes.io/server-snippet: | location @ingress_service_custom_error_401 { internal; # Decode auth response header set_decode_base64 $pth_auth_error_decoded $pth_auth_error; # Return the error from pth-auth service if any if ($pth_auth_error_decoded != &quot;&quot;){ add_header Content-Type $pth_auth_error_content_type always; return 401 $pth_auth_error_decoded; } # Fall back to default nginx response return 401; } location @ingress_service_custom_error_500 { internal; # Decode auth response header set_decode_base64 $pth_auth_error_decoded $pth_auth_error; # Return the error from pth-auth service if any if ($pth_auth_error_decoded != &quot;&quot;){ add_header Content-Type $pth_auth_error_content_type always; return 500 $pth_auth_error_decoded; } # Return a hardcoded error in case no pth-auth pods are available if ($pth_auth_status = 503){ add_header Content-Type application/json always; return 503 &quot;{\&quot;msg\&quot;:\&quot;pth-auth service is unavailable\&quot;}&quot;; } # Fall back to default nginx response return 500; } spec: rules: - http: paths: - path: /?(.*) # UPDATE THIS LINE ABOVE backend: serviceName: client-cluster-ip-service servicePort: 3000 - path: /api/?(.*) # UPDATE THIS LINE ABOVE backend: serviceName: server-cluster-ip-service servicePort: 5000 - path: /pth-auth/?(.*) # UPDATE THIS LINE ABOVE backend: serviceName: pth-auth servicePort: 8000 </code></pre> <p>Inspired by: <a href="https://stackoverflow.com/a/31485557/99237">https://stackoverflow.com/a/31485557/99237</a></p> <h2>Troubleshooting tips:</h2> <ul> <li><a href="https://github.com/kubernetes/ingress-nginx/blob/main/rootfs/etc/nginx/template/nginx.tmpl" rel="nofollow noreferrer">Here's the template nginx ingress uses when transforming the ingress annotations into nginx config file.</a></li> <li>Connect to the ingress controller pod and look at <code>/etc/nginx/nginx.conf</code> to view the generated nginx config.</li> </ul>
<p>I have a k8s cluster with an ingress nginx as a reverse proxy. I am using letsencrypt to generate TLS certificate</p> <pre><code>apiVersion: cert-manager.io/v1alpha2 kind: ClusterIssuer metadata: name: letsencrypt spec: acme: server: https://acme-v02.api.letsencrypt.org/directory email: ****** privateKeySecretRef: name: letsencrypt solvers: - http01: ingress: class: nginx </code></pre> <p>Everything worked fine for months. Today,</p> <pre><code>$ curl -v --verbose https://myurl </code></pre> <p>returns</p> <pre><code>* Rebuilt URL to: https://myurl/ * Trying 51.103.58.**... * TCP_NODELAY set * Connected to myurl (51.103.58.**) port 443 (#0) * ALPN, offering h2 * ALPN, offering http/1.1 * Cipher selection: ALL:!EXPORT:!EXPORT40:!EXPORT56:!aNULL:!LOW:!RC4:@STRENGTH * successfully set certificate verify locations: * CAfile: /etc/ssl/cert.pem CApath: none * TLSv1.2 (OUT), TLS handshake, Client hello (1): * TLSv1.2 (IN), TLS handshake, Server hello (2): * TLSv1.2 (IN), TLS handshake, Certificate (11): * TLSv1.2 (OUT), TLS alert, Server hello (2): * SSL certificate problem: certificate has expired * stopped the pause stream! * Closing connection 0 curl: (60) SSL certificate problem: certificate has expired More details here: https://curl.haxx.se/docs/sslcerts.html curl performs SSL certificate verification by default, using a &quot;bundle&quot; of Certificate Authority (CA) public keys (CA certs). If the default bundle file isn't adequate, you can specify an alternate file using the --cacert option. If this HTTPS server uses a certificate signed by a CA represented in the bundle, the certificate verification probably failed due to a problem with the certificate (it might be expired, or the name might not match the domain name in the URL). If you'd like to turn off curl's verification of the certificate, use the -k (or --insecure) option. HTTPS-proxy has similar options --proxy-cacert and --proxy-insecure. </code></pre> <p>For 2 other people on my team, error is the same and I have the same error when I use Postman (expired certificate).</p> <p>But for another one, we get no error :</p> <pre><code>* Trying 51.103.58.**... * TCP_NODELAY set * Connected to myurl (51.103.58.**) port 443 (#0) * ALPN, offering h2 * ALPN, offering http/1.1 * successfully set certificate verify locations: * CAfile: /etc/ssl/cert.pem CApath: none * TLSv1.2 (OUT), TLS handshake, Client hello (1): * TLSv1.2 (IN), TLS handshake, Server hello (2): * TLSv1.2 (IN), TLS handshake, Certificate (11): * TLSv1.2 (IN), TLS handshake, Server key exchange (12): * TLSv1.2 (IN), TLS handshake, Server finished (14): * TLSv1.2 (OUT), TLS handshake, Client key exchange (16): * TLSv1.2 (OUT), TLS change cipher, Change cipher spec (1): * TLSv1.2 (OUT), TLS handshake, Finished (20): * TLSv1.2 (IN), TLS change cipher, Change cipher spec (1): * TLSv1.2 (IN), TLS handshake, Finished (20): * SSL connection using TLSv1.2 / ECDHE-RSA-AES128-GCM-SHA256 * ALPN, server accepted to use h2 * Server certificate: * subject: CN=myurl * start date: Jul 24 07:15:13 2021 GMT * expire date: Oct 22 07:15:11 2021 GMT * subjectAltName: host &quot;myurl&quot; matched cert's &quot;myurl&quot; * issuer: C=US; O=Let's Encrypt; CN=R3 * SSL certificate verify ok. * Using HTTP2, server supports multi-use * Connection state changed (HTTP/2 confirmed) * Copying HTTP/2 data in stream buffer to connection buffer after upgrade: len=0 * Using Stream ID: 1 (easy handle 0x7fd9be00d600) &gt; GET / HTTP/2 &gt; Host: myurl &gt; User-Agent: curl/7.64.1 &gt; Accept: */* &gt; * Connection state changed (MAX_CONCURRENT_STREAMS == 128)! &lt; HTTP/2 200 &lt; server: nginx/1.19.1 &lt; date: Thu, 30 Sep 2021 16:11:23 GMT &lt; content-type: application/json; charset=utf-8 &lt; content-length: 56 &lt; vary: Origin, Accept-Encoding &lt; access-control-allow-credentials: true &lt; x-xss-protection: 1; mode=block &lt; x-frame-options: DENY &lt; strict-transport-security: max-age=15724800; includeSubDomains &lt; x-download-options: noopen &lt; x-content-type-options: nosniff &lt; etag: W/&quot;38-3eQD3G7Y0vTkrLR+ExD2u5BSsMc&quot; &lt; * Connection #0 to host myurl left intact {&quot;started&quot;:&quot;2021-09-30T13:30:30.912Z&quot;,&quot;uptime&quot;:9653.048}* Closing connection 0 </code></pre> <p>When I use my web browser to go to the website, everything works fine and the certificate is presented as valid and for now, I get no error in prod or staging environment. (same error on staging)</p> <p>Has anyone an explanation on this ?</p>
<p><em>Warning! Please plan OS upgrade path. The below advice should be applied only in emergency situation to quickly fix a critical system.</em></p> <p>Your team missed OS update or <code>ca-certificates</code> package update. Below solution works on old Debian/Ubuntu systems.</p> <p>First check if you have offending DST Root CA X3 cert present:</p> <pre><code># grep X3 /etc/ca-certificates.conf mozilla/DST_Root_CA_X3.crt </code></pre> <p>Make sure the client OS have the proper ISRG Root X1 present too:</p> <pre><code># grep X1 /etc/ca-certificates.conf mozilla/ISRG_Root_X1.crt </code></pre> <p>This is going to disable X3:</p> <pre><code># sed -i '/^mozilla\/DST_Root_CA_X3/s/^/!/' /etc/ca-certificates.conf &amp;&amp; update-ca-certificates -f </code></pre> <p>Try <code>curl https://yourdomain</code> now, should pass.</p> <p>Again, plan an upgrade please.</p>
<p>We've just received an e-mail from GCP informing us that our clusters are currently using deprecated Beta APIs and that we need to upgrade to the newest API version.</p> <p>We have 3 clusters running multiple resources in multiple namespaces so it would be a bit painful having to go through all of them detecting which ones are obsolete.</p> <p>The ones we control such as services, deployments, horizontalpodautoscalers, poddisruptionbudgets etc, those ones are already updated.</p> <p>But we have many services whose manifest files are automatically generated such as Spinnaker services generated by Halyard, or ElasticSearch generated by Elastic Operator, etc.</p> <p>Is there any way to filter all resources by the API version, or any way to detect deprecated resources across all namespaces?</p>
<p>In order to view which API are supported by your cluster</p> <pre><code># Print out supported API's in the cluster kubectl api-versions </code></pre> <p>In order to view deprecated API, you can use this tool.<br /> it's exactly what you asked for, it will print list of resources with the deprecated API's.</p> <p><a href="https://github.com/doitintl/kube-no-trouble" rel="noreferrer">https://github.com/doitintl/kube-no-trouble</a></p> <pre class="lang-sh prettyprint-override"><code># sample output from the official docs: $./kubent 6:25PM INF &gt;&gt;&gt; Kube No Trouble `kubent` &lt;&lt;&lt; 6:25PM INF Initializing collectors and retrieving data 6:25PM INF Retrieved 103 resources from collector name=Cluster 6:25PM INF Retrieved 132 resources from collector name=&quot;Helm v2&quot; 6:25PM INF Retrieved 0 resources from collector name=&quot;Helm v3&quot; 6:25PM INF Loaded ruleset name=deprecated-1-16.rego 6:25PM INF Loaded ruleset name=deprecated-1-20.rego _____________________________________________________________________ &gt;&gt;&gt; 1.16 Deprecated APIs &lt;&lt;&lt; --------------------------------------------------------------------- KIND NAMESPACE NAME API_VERSION Deployment default nginx-deployment-old apps/v1beta1 Deployment kube-system event-exporter-v0.2.5 apps/v1beta1 Deployment kube-system k8s-snapshots extensions/v1beta1 Deployment kube-system kube-dns extensions/v1beta1 _____________________________________________________________________ &gt;&gt;&gt; 1.20 Deprecated APIs &lt;&lt;&lt; --------------------------------------------------------------------- KIND NAMESPACE NAME API_VERSION Ingress default test-ingress extensions/v1beta1 </code></pre> <hr /> <h3>Installing <code>kubent</code></h3> <pre><code># install `kubent` sh -c &quot;$(curl -sSL 'https://git.io/install-kubent')&quot; </code></pre> <h3>Running <code>kubent</code></h3> <pre><code>kubent </code></pre> <hr /> <p><a href="https://i.stack.imgur.com/NTZc4.png" rel="noreferrer"><img src="https://i.stack.imgur.com/NTZc4.png" alt="enter image description here" /></a></p> <hr /> <h3>Additional Similar tools:</h3> <ul> <li><a href="https://github.com/FairwindsOps/pluto" rel="noreferrer">https://github.com/FairwindsOps/pluto</a></li> <li><a href="https://github.com/derailed/popeye" rel="noreferrer">https://github.com/derailed/popeye</a></li> </ul>
<p>I'm new with Azure infrastructure and I'm trying to deploy Jenkins on AKS and be able to preserve all of my Jenkins data if the container stopped working and I run with a permissions issue for my newly created PVC.</p> <p>I want to change the permissions for a specific folder and files in the PVC and the &quot;chmod&quot; command looks like running but doesn't do anything and the permissions are still set to 777 instead of my wanted permissions.</p> <p>I have noticed that the Storage Class default permissions value for dirs and files are 777 but I need some specific files to be with other permissions.</p> <p>Can I do this or there is any other option to do this?</p>
<blockquote> <p>I want to change the permissions for a specific folder and files in the PVC and the &quot;chmod&quot; command looks like running but doesn't do anything and the permissions are still set to 777 instead of my wanted permissions.</p> </blockquote> <p>If you want to configure permissions in Kubernetes, you must use the <a href="https://kubernetes.io/docs/tasks/configure-pod-container/security-context/" rel="nofollow noreferrer">security context</a>:</p> <blockquote> <p>A security context defines privilege and access control settings for a Pod or Container. Security context settings include, but are not limited to:</p> <ul> <li><p>Discretionary Access Control: Permission to access an object, like a file, is based on <a href="https://wiki.archlinux.org/index.php/users_and_groups" rel="nofollow noreferrer">user ID (UID) and group ID (GID)</a>.</p> </li> <li><p><a href="https://en.wikipedia.org/wiki/Security-Enhanced_Linux" rel="nofollow noreferrer">Security Enhanced Linux (SELinux)</a>: Objects are assigned security labels.</p> </li> <li><p>Running as privileged or unprivileged.</p> </li> <li><p><a href="https://linux-audit.com/linux-capabilities-hardening-linux-binaries-by-removing-setuid/" rel="nofollow noreferrer">Linux Capabilities</a>: Give a process some privileges, but not all the privileges of the root user.</p> </li> <li><p><a href="https://kubernetes.io/docs/tutorials/clusters/apparmor/" rel="nofollow noreferrer">AppArmor</a>: Use program profiles to restrict the capabilities of individual programs.</p> </li> <li><p><a href="https://kubernetes.io/docs/tutorials/clusters/seccomp/" rel="nofollow noreferrer">Seccomp</a>: Filter a process's system calls.</p> </li> <li><p>AllowPrivilegeEscalation: Controls whether a process can gain more privileges than its parent process. This bool directly controls whether the <a href="https://www.kernel.org/doc/Documentation/prctl/no_new_privs.txt" rel="nofollow noreferrer"><code>no_new_privs</code></a> flag gets set on the container process. AllowPrivilegeEscalation is true always when the container is: 1) run as Privileged OR 2) has <code>CAP_SYS_ADMIN</code>.</p> </li> <li><p>readOnlyRootFilesystem: Mounts the container's root filesystem as read-only.</p> </li> </ul> <p>The above bullets are not a complete set of security context settings -- please see <a href="https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.22/#securitycontext-v1-core" rel="nofollow noreferrer">SecurityContext</a> for a comprehensive list.</p> <p>For more information about security mechanisms in Linux, see <a href="https://www.linux.com/learn/overview-linux-kernel-security-features" rel="nofollow noreferrer">Overview of Linux Kernel Security Features</a></p> </blockquote> <p>In your case, if you want to grant permissions for a specific object (e.g. a file), you can use <a href="https://kubernetes.io/blog/2018/07/18/11-ways-not-to-get-hacked/#8-run-containers-as-a-non-root-user" rel="nofollow noreferrer">Discretionary Access Control</a>:</p> <blockquote> <p><strong>Containers that run as root frequently have far more permissions than their workload requires which, in case of compromise, could help an attacker further their attack.</strong></p> <p>Containers still rely on the traditional Unix security model (called <a href="https://www.linux.com/learn/overview-linux-kernel-security-features" rel="nofollow noreferrer">discretionary access control</a> or DAC) - everything is a file, and permissions are granted to users and groups.</p> </blockquote> <p>You can also <a href="https://kubernetes.io/docs/tasks/configure-pod-container/security-context/#configure-volume-permission-and-ownership-change-policy-for-pods" rel="nofollow noreferrer">configure volume permission and ownership change policy for Pods</a>.</p> <p>See also:</p> <ul> <li><a href="https://medium.com/kubernetes-tutorials/defining-privileges-and-access-control-settings-for-pods-and-containers-in-kubernetes-2cef08fc62b7" rel="nofollow noreferrer">Defining Privileges and Access Control Settings for Pods and Containers in Kubernetes</a></li> <li><a href="https://kubernetes.io/blog/2018/07/18/11-ways-not-to-get-hacked/#8-run-containers-as-a-non-root-user" rel="nofollow noreferrer">11 Ways (Not) to Get Hacked</a></li> </ul>
<p>I am having below questions related to Ingress resource in Kubernetes</p> <ol> <li>Can a single Ingress controller (ex: NginxIngress Controller) be mapped to multiple Ingress resources?</li> <li>If the Ingress resources are mapped to single namespace, how to requested be routed in case of multiple ingress resources?</li> <li>Is the Ingress resource mapped to unique hostname?</li> <li>Is the ingress controller (ex: Nginx Ingress controller) bound to a namespace or is it a cluster level resource?</li> </ol>
<ol> <li>Yes, it's possible, you can have a look here: <a href="https://stackoverflow.com/questions/65171303/is-it-possible-to-have-multiple-ingress-resources-with-a-single-gke-ingress-cont">Is it possible to have multiple ingress resources with a single GKE ingress controller</a></li> <li>Considering ingress resources are ingress rules:</li> </ol> <blockquote> <p>If you create an Ingress resource without any hosts defined in the rules, then any web traffic to the IP address of your Ingress controller can be matched without a name based virtual host being required.</p> <p>For example, the following Ingress routes traffic requested for first.bar.com to service1, second.bar.com to service2, and any traffic to the IP address without a hostname defined in request (that is, without a request header being presented) to service3.</p> </blockquote> <p><a href="https://kubernetes.io/docs/concepts/services-networking/ingress/#name-based-virtual-hosting" rel="nofollow noreferrer">Name based virtual hosting</a></p> <p>3.</p> <blockquote> <p>An optional host. In this example, no host is specified, so the rule applies to all inbound HTTP traffic through the IP address specified. If a host is provided (for example, foo.bar.com), the rules apply to that host.</p> </blockquote> <p><a href="https://kubernetes.io/docs/concepts/services-networking/ingress/#ingress-rules" rel="nofollow noreferrer">Ingress rules</a></p> <p>4.</p> <blockquote> <p>Parameters field has a scope and namespace field that can be used to reference a namespace-specific resource for configuration of an Ingress class. Scope field defaults to Cluster, meaning, the default is cluster-scoped resource. Setting Scope to Namespace and setting the Namespace field will reference a parameters resource in a specific namespace:</p> <p>Namespace-scoped parameters avoid the need for a cluster-scoped CustomResourceDefinition for a parameters resource. This further avoids RBAC-related resources that would otherwise be required to grant permissions to cluster-scoped resources.</p> </blockquote> <p><a href="https://kubernetes.io/docs/concepts/services-networking/ingress/#namespace-scoped-parameters" rel="nofollow noreferrer">Namespace-scoped parameters</a></p>
<p>I wish to filter Filebeat autodiscover using Kubernetes Namespaces.</p> <p>Kubernetes is running on EKS v1.20.7</p> <p>ECK versions:</p> <ul> <li>Elasticsearch v7.7.0</li> <li>Kibana v7.7.0</li> <li>Filebeat v7.10.0</li> </ul> <p>Filtering is not working based on the following config:</p> <pre><code>filebeatConfig: filebeat.yml: |- filebeat.autodiscover: providers: - type: kubernetes node: ${NODE_NAME} hints.enabled: true templates: - condition.or: - equals: kubernetes.namespace: &quot;ingress&quot; - equals: kubernetes.namespace: &quot;kube-system&quot; config: - type: container paths: - /var/lib/docker/containers/*/${data.kubernetes.container.id}-json.log exclude_lines: [&quot;^\\s+[\\-`('.|_]&quot;] processors: - add_cloud_metadata: ~ - add_host_metadata: ~ cloud: id: '${ELASTIC_CLOUD_ID}' cloud: auth: '${ELASTIC_CLOUD_AUTH}' output: elasticsearch: enabled: true hosts: &quot;elasticsearch-es-http.monitoring.svc.cluster.local:9200&quot; username: '${ELASTICSEARCH_USERNAME}' password: '${ELASTICSEARCH_PASSWORD}' protocol: https ssl: verification_mode: &quot;none&quot; setup.ilm.enabled: auto setup.ilm.rollover_alias: &quot;filebeat-testing-v8-%{[agent.version]}&quot; setup.ilm.pattern: &quot;{now/d}-000001&quot; </code></pre> <p>Then when the index is queried via the Dev Console it returns both the &quot;ingress&quot; and &quot;monitoring&quot; namespaces, which it shouldn't.</p> <p>Query:</p> <pre><code>GET filebeat-testing-v8-7.10.0-2021.09.29-000001/_search { // Identify all Kubernetes namespaces in this Filebeat index &quot;size&quot;: 0, // Don't return any documents, just aggregation &quot;aggs&quot; : { &quot;distinctValues&quot; : { &quot;terms&quot; : { &quot;field&quot; : &quot;kubernetes.namespace&quot;, // Field to be aggregated &quot;size&quot; : 5000000 // How many unique values to return } } } } </code></pre> <p>Response:</p> <pre><code>{ &quot;took&quot; : 3, &quot;timed_out&quot; : false, &quot;_shards&quot; : { &quot;total&quot; : 1, &quot;successful&quot; : 1, &quot;skipped&quot; : 0, &quot;failed&quot; : 0 }, &quot;hits&quot; : { &quot;total&quot; : { &quot;value&quot; : 10000, &quot;relation&quot; : &quot;gte&quot; }, &quot;max_score&quot; : null, &quot;hits&quot; : [ ] }, &quot;aggregations&quot; : { &quot;distinctValues&quot; : { &quot;doc_count_error_upper_bound&quot; : 0, &quot;sum_other_doc_count&quot; : 0, &quot;buckets&quot; : [ { &quot;key&quot; : &quot;monitoring&quot;, &quot;doc_count&quot; : 25093 }, { &quot;key&quot; : &quot;ingress&quot;, &quot;doc_count&quot; : 6041 }, { &quot;key&quot; : &quot;kube-system&quot;, &quot;doc_count&quot; : 132 }, { &quot;key&quot; : &quot;vault-agent&quot;, &quot;doc_count&quot; : 9 } ] } } } </code></pre> <p>Any ideas or pointers on why this is not filtering correctly, would be much appreciated.</p>
<p>The working config is :</p> <pre><code>filebeatConfig: filebeat.yml: |- filebeat.autodiscover: providers: - type: kubernetes node: ${NODE_NAME} hints.enabled: true templates: - config: - type: container paths: - /var/lib/docker/containers/*/${data.kubernetes.container.id}-json.log exclude_lines: [&quot;^\\s+[\\-`('.|_]&quot;] processors: - drop_event.when.not.or: - equals.kubernetes.namespace: &quot;ingress&quot; - equals.kubernetes.namespace: &quot;kube-system&quot; processors: - add_cloud_metadata: ~ - add_host_metadata: ~ cloud: id: '${ELASTIC_CLOUD_ID}' cloud: auth: '${ELASTIC_CLOUD_AUTH}' output: elasticsearch: enabled: true hosts: &quot;elasticsearch-es-http.monitoring.svc.cluster.local:9200&quot; username: '${ELASTICSEARCH_USERNAME}' password: '${ELASTICSEARCH_PASSWORD}' protocol: https ssl: verification_mode: &quot;none&quot; setup.ilm.enabled: auto setup.ilm.rollover_alias: &quot;filebeat-testing-v8-%{[agent.version]}&quot; setup.ilm.pattern: &quot;{now/d}-000001&quot; </code></pre>
<p>I have a Docker image that contains an application in python, running in Kubernetes as a deployment, I want to pass to that application some data. I used env vars but I would like to use annotations but I'm not sure how to read them, I saw that <code>V1ObjectMeta</code> has a field called <code>annotations</code> but I'm a bit lost of how to call it.</p> <p>For example:</p> <p>If my pod has this:</p> <pre><code>template: metadata: annotations: foo: &quot;var&quot; </code></pre> <p>How to read <code>foo: var</code> using the python program that is running inside the pod using the Kubernetes library?</p>
<p>All you need is to get the pod object from Kubernetes API. It has the same structure as in <code>YAML</code> format, so once you have the data, the rest is trivial. See below:</p> <pre class="lang-py prettyprint-override"><code>from kubernetes import client, config config.load_incluster_config() c = client.CoreV1Api() pod = c.read_namespaced_pod(name=&quot;my-pod-name&quot;, namespace=&quot;my-namespace&quot;) print(pod.metadata.annotations[&quot;foo&quot;]) </code></pre>
<p>This example is specifically about Nextcloud, although I had the same (unsolved issue) in the past with others.</p> <p>What I simply want to do, is to access nextcloud under <code>www.myserver.com/nextcloud</code>.</p> <p>I am able to kind of accessing Nextcloud front page with my present setup, but everything that's not directly under the basepath, is broken. Images and JS for instance.</p> <p>Sure enough, I can manually enter in my browser web address something like <code>www.myserver.com/nextcloud/core/css/guest.css</code>, and it's there. But the issue is that the front page from Nextcloud, tries to access everything under: <code>www.myserver.com/core/css/guest.css</code></p> <p>Here is my ingress:</p> <pre><code>apiVersion: networking.k8s.io/v1 kind: Ingress metadata: name: nextcloud namespace: homeserver annotations: kubernetes.io/ingress.class: nginx cert-manager.io/cluster-issuer: letsencrypt-staging nginx.ingress.kubernetes.io/configuration-snippet: | proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection $http_connection; nginx.ingress.kubernetes.io/rewrite-target: /$2 spec: rules: - host: www.myserver.com http: paths: - path: /nextcloud(/|$)(.*) pathType: Prefix backend: service: name: nextcloud port: number: 80 </code></pre>
<p>You should have to use the relative path in backend or HTML if you are using that.</p> <p>However you can do one thing</p> <p>if your all request getting by the application at : <code>www.myserver.com/core</code> and there is no other folder exist or endpoint</p> <p>you can create some redirection rules like :</p> <pre><code>www.myserver.com/core -&gt; www.myserver.com/nextcloud/ </code></pre> <p>once redirect redirected to new URL further another ingress that you have created will take care of the path and serve.</p> <p>Ingrss example</p> <pre><code>metadata: name: ingress-test annotations: kubernetes.io/ingress.class: &quot;nginx&quot; nginx.ingress.kubernetes.io/enable-rewrite-log: &quot;true&quot; nginx.ingress.kubernetes.io/location-snippet: | location = /core/ { proxy_pass http://[hostname]/nextcloud/; } spec: </code></pre> <p>still, it depends on your application config and structure.</p>
<p>we are currently still running our Kubernetes cluster in region <code>europe-west2</code> (London) but have to use a new ipaddress for an ingress on the cluster from <code>europe-west3</code> (Frankfurt).</p> <p>After trying to deploy our new ingress on the cluster in region <code>europe-west2</code> I get the following error:</p> <pre><code>the given static IP name xyz doesn't translate to an existing static IP. </code></pre> <p>I assume that ingress only has access to regional IP addresses in the same region.</p> <p>I use the following annotation:</p> <pre><code> annotations: kubernetes.io/ingress.regional-static-ip-name: xyz </code></pre> <p>Does anybody have an idea how to use the IP address from <code>europe-west3</code> on an ingress in <code>europe-west2</code>?</p> <p>Cheers</p>
<p>I've tried to replicate your issue but couldn't find any solution.</p> <p>However, note that from the <a href="https://cloud.google.com/kubernetes-engine/docs/tutorials/configuring-domain-name-static-ip#use_an_ingress" rel="nofollow noreferrer">official documentation</a>:</p> <blockquote> <p>Regional IP addresses do not work with Ingress.</p> <p>To learn more about how to use Ingress to expose your applications to the internet, refer to the Setting up HTTP(S) Load Balancing with Ingress tutorial.</p> </blockquote> <p>And please refer to the similar issues and the useful answers under it:</p> <ul> <li><p><a href="https://stackoverflow.com/a/63257182/16860542">Issue 1</a></p> </li> <li><p><a href="https://stackoverflow.com/a/40164860/16860542">Issue 2</a></p> </li> </ul>
<p>You can simply interact with K8s using its REST API. For example to get pods:</p> <pre><code>curl http://IPADDR/api/v1/pods </code></pre> <p>However I can't find any example of authentication based only on curl or REST. All the examples show the usage of <code>kubectl</code> as proxy or as a way to get credentials.</p> <p>If I already own the <code>.kubeconfig</code>, and nothing else, is there any way to send the HTTP requests directly (e.g. with a token) without using <code>kubectl</code>?</p>
<p>The <code>kubeconfig</code> file you download when you first install the cluster includes a client certificate and key. For example:</p> <pre><code>clusters: - cluster: certificate-authority-data: ... server: https://api.cluster1.ocp.virt:6443 name: cluster1 contexts: - context: cluster: cluster1 user: admin name: admin current-context: admin preferences: {} users: - name: admin user: client-certificate-data: ... client-key-data: ... </code></pre> <p>If you extract the <code>client-certificate-data</code> and <code>client-key-data</code> to files, you can use them to authenticate with curl. To extract the data:</p> <pre><code>$ yq -r '.users[0].user.&quot;client-certificate-data&quot;' kubeconfig | base64 -d &gt; cert $ yq -r '.users[0].user.&quot;client-key-data&quot;' kubeconfig | base64 -d &gt; key </code></pre> <p>And then using <code>curl</code>:</p> <pre><code>$ curl -k --cert cert --key key \ 'https://api.cluster1.ocp.virt:6443/api/v1/namespaces/default/pods?limit=500' { &quot;kind&quot;: &quot;PodList&quot;, &quot;apiVersion&quot;: &quot;v1&quot;, &quot;metadata&quot;: { &quot;resourceVersion&quot;: &quot;22022&quot; }, &quot;items&quot;: [] </code></pre> <hr /> <p>Alternately, if your <code>.kubeconfig</code> has tokens in it, like this:</p> <pre><code>[...] users: - name: your_username/api-clustername-domain:6443 user: token: sha256~... </code></pre> <p>Then you can use that token as a bearer token:</p> <pre><code>$ curl -k https://api.mycluster.mydomain:6443/ -H 'Authorization: Bearer sha256~...' </code></pre> <p>...but note that those tokens typically expire after some time, while the certificates should work indefinitely (unless they are revoked somehow).</p>
<p>I'm using Google Cloud Build to CI/CD my application, which rely on multiple cronjobs. The first step of my build is like:</p> <pre class="lang-yaml prettyprint-override"><code> # validate k8s manifests - id: validate-k8s name: quay.io/fairwinds/polaris:1.2.1 entrypoint: polaris args: - audit - --audit-path - ./devops/k8s/cronjobs/worker-foo.yaml - --set-exit-code-on-danger - --set-exit-code-below-score - &quot;87&quot; </code></pre> <p>I'm using <a href="https://polaris.docs.fairwinds.com/checks/security/" rel="nofollow noreferrer">Polaris</a> to enforce best security practices. For each cronjob, I have a deployment manifest that is like:</p> <pre class="lang-yaml prettyprint-override"><code>apiVersion: batch/v1beta1 kind: CronJob metadata: name: worker-foo namespace: foo spec: schedule: &quot;30 1-5,20-23 * * *&quot; concurrencyPolicy: Forbid jobTemplate: spec: backoffLimit: 3 template: spec: hostIPC: false hostPID: false hostNetwork: false volumes: - name: foo-sa secret: secretName: foo-sa - name: foo-secrets secret: secretName: foo-secrets - name: tmp-pod emptyDir: {} restartPolicy: OnFailure containers: - name: worker-foo image: gcr.io/bar/foo:latest imagePullPolicy: &quot;Always&quot; resources: requests: memory: &quot;512M&quot; cpu: &quot;50m&quot; limits: memory: &quot;6000M&quot; cpu: &quot;500m&quot; volumeMounts: - name: foo-sa mountPath: /var/secrets/foo-sa - mountPath: /tmp/pod name: tmp-pod command: [&quot;/bin/bash&quot;, &quot;-c&quot;] args: - | timeout --kill-after=10500 10500 python foo/foo/foo.py --prod; </code></pre> <p>I found <a href="https://blog.aquasec.com/kubernetess-policy" rel="nofollow noreferrer">here</a> that the hierarchy of HostIPC parameter in manifest file is “spec.jobTemplate.spec.template.spec.HostIPC”, but it does not seem to conform Polaris validation:</p> <pre><code>Step #0 - &quot;validate-k8s&quot;: &quot;Results&quot;: [ Step #0 - &quot;validate-k8s&quot;: { Step #0 - &quot;validate-k8s&quot;: &quot;Name&quot;: &quot;worker-foo&quot;, Step #0 - &quot;validate-k8s&quot;: &quot;Namespace&quot;: &quot;foo&quot;, Step #0 - &quot;validate-k8s&quot;: &quot;Kind&quot;: &quot;CronJob&quot;, Step #0 - &quot;validate-k8s&quot;: &quot;Results&quot;: {}, Step #0 - &quot;validate-k8s&quot;: &quot;PodResult&quot;: { Step #0 - &quot;validate-k8s&quot;: &quot;Name&quot;: &quot;&quot;, Step #0 - &quot;validate-k8s&quot;: &quot;Results&quot;: { Step #0 - &quot;validate-k8s&quot;: &quot;hostIPCSet&quot;: { Step #0 - &quot;validate-k8s&quot;: &quot;ID&quot;: &quot;hostIPCSet&quot;, Step #0 - &quot;validate-k8s&quot;: &quot;Message&quot;: &quot;Host IPC is not configured&quot;, Step #0 - &quot;validate-k8s&quot;: &quot;Success&quot;: true, Step #0 - &quot;validate-k8s&quot;: &quot;Severity&quot;: &quot;danger&quot;, Step #0 - &quot;validate-k8s&quot;: &quot;Category&quot;: &quot;Security&quot; Step #0 - &quot;validate-k8s&quot;: }, Step #0 - &quot;validate-k8s&quot;: &quot;hostNetworkSet&quot;: { Step #0 - &quot;validate-k8s&quot;: &quot;ID&quot;: &quot;hostNetworkSet&quot;, Step #0 - &quot;validate-k8s&quot;: &quot;Message&quot;: &quot;Host network is not configured&quot;, Step #0 - &quot;validate-k8s&quot;: &quot;Success&quot;: true, Step #0 - &quot;validate-k8s&quot;: &quot;Severity&quot;: &quot;warning&quot;, Step #0 - &quot;validate-k8s&quot;: &quot;Category&quot;: &quot;Networking&quot; Step #0 - &quot;validate-k8s&quot;: }, Step #0 - &quot;validate-k8s&quot;: &quot;hostPIDSet&quot;: { Step #0 - &quot;validate-k8s&quot;: &quot;ID&quot;: &quot;hostPIDSet&quot;, Step #0 - &quot;validate-k8s&quot;: &quot;Message&quot;: &quot;Host PID is not configured&quot;, Step #0 - &quot;validate-k8s&quot;: &quot;Success&quot;: true, Step #0 - &quot;validate-k8s&quot;: &quot;Severity&quot;: &quot;danger&quot;, Step #0 - &quot;validate-k8s&quot;: &quot;Category&quot;: &quot;Security&quot; Step #0 - &quot;validate-k8s&quot;: } Step #0 - &quot;validate-k8s&quot;: }, </code></pre> <p>What I'm missing here? How should I declare HostIPC and HostPID params in order to satisfy Polaris validation?</p> <p>Possibly related issue: <a href="https://github.com/FairwindsOps/polaris/issues/328" rel="nofollow noreferrer">https://github.com/FairwindsOps/polaris/issues/328</a></p>
<p>Polaris may be asking you to explicitly set those attributes to false. Try this:</p> <pre><code>... jobTemplate: spec: backoffLimit: 3 template: spec: hostIPC: false hostNetwork: false hostPID: false ... containers: - worker-foo ... ... </code></pre>
<p>Trying to set a custom seccomp profile when using <code>kubectl apply</code> and despite the file being there in the container, the pod will not start with the following error:</p> <pre><code>Error: failed to create containerd container: cannot load seccomp profile &quot;/var/lib/kubelet/seccomp/custom_profile.json&quot;: open /var/lib/kubelet/seccomp/custom_profile.json: no such file or directory </code></pre> <p><strong>K8 deployment YAML</strong></p> <pre><code>... containers: - name: container-name image: container-image:version securityContext: seccompProfile: type: Localhost localhostProfile: custom_profile.json ... </code></pre> <p>The file is copied when the container is created and going into the shell of the pod I can see that it does exist there (when not trying to load it and the pod starts)</p> <p><strong>Dockerfile</strong></p> <pre><code>... COPY custom_profile.json /var/lib/kubelet/seccomp/custom_profile.json ... </code></pre> <p>I have also tried changing the owner (<code>chown</code>) and running with root privileges but as long as the <code>localhostProfile: custom_profile.json</code> line is in the YAML then the same error appears again.</p> <p>What am I missing that is preventing the file from being found? Something missing in the YAML, something missing in the container/dockerfile?</p> <p>The following article is what got me this far but still not able to set the profile: <a href="https://docs.openshift.com/container-platform/4.8/security/seccomp-profiles.html" rel="nofollow noreferrer">https://docs.openshift.com/container-platform/4.8/security/seccomp-profiles.html</a></p>
<p>If <code>type: Localhost</code> seccomp profile is used, then the <code>seccomp</code> profiles must be present over the node on which the pod is getting scheduled. Also, the path is relative to the path <code>/var/lib/kubelet/seccomp</code>. Here <code>/var/lib/kubelet/</code> is the default path for <code>kubelet</code> config.</p> <p>Here is the related snippet from official <a href="https://kubernetes.io/docs/concepts/policy/pod-security-policy/#seccomp" rel="nofollow noreferrer">documentation</a>:</p> <blockquote> <p><code>localhost/&lt;path&gt;</code> - Specify a profile as a file on the node located at &lt;seccomp_root&gt;/, where &lt;seccomp_root&gt; is defined via the <code>--seccomp-profile-root</code> flag on the Kubelet. If the <code>--seccomp-profile-root</code> flag is not defined, the default path will be used, which is /seccomp where is specified by the --root-dir flag.</p> </blockquote> <p><strong>Example-1</strong>: For the following to work , a <code>custom_profile.json</code> file must be present at <code>/var/lib/kubelet/seccomp</code> path on the node.</p> <pre><code>securityContext: seccompProfile: type: Localhost localhostProfile: custom_profile.json </code></pre> <p><strong>Example-2</strong>: For the following to work , a <code>custom_profile.json</code> file must be present at <code>/var/lib/kubelet/seccomp/profiles</code> path on the node.</p> <pre><code>securityContext: seccompProfile: type: Localhost localhostProfile: profiles/custom_profile.json </code></pre> <p><strong>Here is a minimal working example:</strong></p> <p><code>seccomp</code> profiles are copied on the worker node.</p> <pre><code>ps@worker-node:~$ sudo ls -lrt /var/lib/kubelet/seccomp/profiles [sudo] password for ps: total 12 -rw-r--r-- 1 root root 39 Sep 10 13:54 audit.json -rw-r--r-- 1 root root 41 Sep 10 13:54 violation.json -rw-r--r-- 1 root root 1657 Sep 10 13:54 fine-grained.json ps@worker-node:~$ </code></pre> <p>Create the pod with the following path, notice the path is relative to <code>/var/lib/kubelet/seccomp</code>.</p> <pre><code>apiVersion: v1 kind: Pod metadata: name: audit-pod labels: app: audit-pod spec: securityContext: seccompProfile: type: Localhost localhostProfile: profiles/audit.json containers: - name: test-container image: nginx securityContext: allowPrivilegeEscalation: false </code></pre>
<p>I have a k8s cluster with an ingress nginx as a reverse proxy. I am using letsencrypt to generate TLS certificate</p> <pre><code>apiVersion: cert-manager.io/v1alpha2 kind: ClusterIssuer metadata: name: letsencrypt spec: acme: server: https://acme-v02.api.letsencrypt.org/directory email: ****** privateKeySecretRef: name: letsencrypt solvers: - http01: ingress: class: nginx </code></pre> <p>Everything worked fine for months. Today,</p> <pre><code>$ curl -v --verbose https://myurl </code></pre> <p>returns</p> <pre><code>* Rebuilt URL to: https://myurl/ * Trying 51.103.58.**... * TCP_NODELAY set * Connected to myurl (51.103.58.**) port 443 (#0) * ALPN, offering h2 * ALPN, offering http/1.1 * Cipher selection: ALL:!EXPORT:!EXPORT40:!EXPORT56:!aNULL:!LOW:!RC4:@STRENGTH * successfully set certificate verify locations: * CAfile: /etc/ssl/cert.pem CApath: none * TLSv1.2 (OUT), TLS handshake, Client hello (1): * TLSv1.2 (IN), TLS handshake, Server hello (2): * TLSv1.2 (IN), TLS handshake, Certificate (11): * TLSv1.2 (OUT), TLS alert, Server hello (2): * SSL certificate problem: certificate has expired * stopped the pause stream! * Closing connection 0 curl: (60) SSL certificate problem: certificate has expired More details here: https://curl.haxx.se/docs/sslcerts.html curl performs SSL certificate verification by default, using a &quot;bundle&quot; of Certificate Authority (CA) public keys (CA certs). If the default bundle file isn't adequate, you can specify an alternate file using the --cacert option. If this HTTPS server uses a certificate signed by a CA represented in the bundle, the certificate verification probably failed due to a problem with the certificate (it might be expired, or the name might not match the domain name in the URL). If you'd like to turn off curl's verification of the certificate, use the -k (or --insecure) option. HTTPS-proxy has similar options --proxy-cacert and --proxy-insecure. </code></pre> <p>For 2 other people on my team, error is the same and I have the same error when I use Postman (expired certificate).</p> <p>But for another one, we get no error :</p> <pre><code>* Trying 51.103.58.**... * TCP_NODELAY set * Connected to myurl (51.103.58.**) port 443 (#0) * ALPN, offering h2 * ALPN, offering http/1.1 * successfully set certificate verify locations: * CAfile: /etc/ssl/cert.pem CApath: none * TLSv1.2 (OUT), TLS handshake, Client hello (1): * TLSv1.2 (IN), TLS handshake, Server hello (2): * TLSv1.2 (IN), TLS handshake, Certificate (11): * TLSv1.2 (IN), TLS handshake, Server key exchange (12): * TLSv1.2 (IN), TLS handshake, Server finished (14): * TLSv1.2 (OUT), TLS handshake, Client key exchange (16): * TLSv1.2 (OUT), TLS change cipher, Change cipher spec (1): * TLSv1.2 (OUT), TLS handshake, Finished (20): * TLSv1.2 (IN), TLS change cipher, Change cipher spec (1): * TLSv1.2 (IN), TLS handshake, Finished (20): * SSL connection using TLSv1.2 / ECDHE-RSA-AES128-GCM-SHA256 * ALPN, server accepted to use h2 * Server certificate: * subject: CN=myurl * start date: Jul 24 07:15:13 2021 GMT * expire date: Oct 22 07:15:11 2021 GMT * subjectAltName: host &quot;myurl&quot; matched cert's &quot;myurl&quot; * issuer: C=US; O=Let's Encrypt; CN=R3 * SSL certificate verify ok. * Using HTTP2, server supports multi-use * Connection state changed (HTTP/2 confirmed) * Copying HTTP/2 data in stream buffer to connection buffer after upgrade: len=0 * Using Stream ID: 1 (easy handle 0x7fd9be00d600) &gt; GET / HTTP/2 &gt; Host: myurl &gt; User-Agent: curl/7.64.1 &gt; Accept: */* &gt; * Connection state changed (MAX_CONCURRENT_STREAMS == 128)! &lt; HTTP/2 200 &lt; server: nginx/1.19.1 &lt; date: Thu, 30 Sep 2021 16:11:23 GMT &lt; content-type: application/json; charset=utf-8 &lt; content-length: 56 &lt; vary: Origin, Accept-Encoding &lt; access-control-allow-credentials: true &lt; x-xss-protection: 1; mode=block &lt; x-frame-options: DENY &lt; strict-transport-security: max-age=15724800; includeSubDomains &lt; x-download-options: noopen &lt; x-content-type-options: nosniff &lt; etag: W/&quot;38-3eQD3G7Y0vTkrLR+ExD2u5BSsMc&quot; &lt; * Connection #0 to host myurl left intact {&quot;started&quot;:&quot;2021-09-30T13:30:30.912Z&quot;,&quot;uptime&quot;:9653.048}* Closing connection 0 </code></pre> <p>When I use my web browser to go to the website, everything works fine and the certificate is presented as valid and for now, I get no error in prod or staging environment. (same error on staging)</p> <p>Has anyone an explanation on this ?</p>
<p>This is related to the expired DST Root CA X3, which expired Sep 30 14:01:15 2021 GMT.</p> <p>The DST CA Root X3 certificate is part of the &quot;cacert-bundle&quot;. As of today the &quot;cacert-bundle&quot; can be found here: <a href="https://curl.se/docs/caextract.html" rel="nofollow noreferrer">https://curl.se/docs/caextract.html</a> as part of the bundle <a href="https://curl.se/ca/cacert.pem" rel="nofollow noreferrer">https://curl.se/ca/cacert.pem</a>.</p> <p>The expired certificate is:</p> <pre><code>Certificate: Data: Version: 3 (0x2) Serial Number: 44:af:b0:80:d6:a3:27:ba:89:30:39:86:2e:f8:40:6b Signature Algorithm: sha1WithRSAEncryption Issuer: O=Digital Signature Trust Co., CN=DST Root CA X3 Validity Not Before: Sep 30 21:12:19 2000 GMT Not After : Sep 30 14:01:15 2021 GMT Subject: O=Digital Signature Trust Co., CN=DST Root CA X3 Subject Public Key Info: Public Key Algorithm: rsaEncryption Public-Key: (2048 bit) </code></pre> <p>Which is used to verify peer in curl calls to websites using Let's Encrypt issued certificates.</p> <p>Here's a detailed solution to your problem: <a href="https://stackoverflow.com/a/69411107/1549092">https://stackoverflow.com/a/69411107/1549092</a></p> <p>Let's Encrypt formal address of the issue can be found here: <a href="https://letsencrypt.org/docs/dst-root-ca-x3-expiration-september-2021/" rel="nofollow noreferrer">https://letsencrypt.org/docs/dst-root-ca-x3-expiration-september-2021/</a></p>
<p>We run gitlab-ee-12.10.12.0 under docker and use kubernetes to manage the gitlab-runner</p> <p>All of a sudden a couple of days ago, all my pipelines, in all my projects, stopped working. NOTHING CHANGED except I pushed some code. Yet ALL projects (even those with no repo changes) are failing. I've looked at every certificate I can find anywhere in the system and they're all good so it wasn't a cert expiry. Disk space is at 45% so it's not that. Nobody logged into the server. Nobody touched any admin screens. One code push triggered the pipeline successfully, next one didn't. I've looked at everything. I've updated the docker images for gitlab and gitlab-runner. I've deleted every kubernetes pod I can find in the namespace and let them get relaunched (my go-to for solving k8s problems :-) ).</p> <p>Every pipeline run in every project now says this:</p> <pre><code>Running with gitlab-runner 14.3.2 (e0218c92) on Kubernetes Runner vXpkH225 Preparing the &quot;kubernetes&quot; executor 00:00 Using Kubernetes namespace: gitlab Using Kubernetes executor with image lxnsok01.wg.dir.telstra.com:9000/broadworks-build:latest ... Using attach strategy to execute scripts... Preparing environment 00:00 ERROR: Error cleaning up configmap: resource name may not be empty ERROR: Job failed (system failure): prepare environment: setting up build pod: error setting ownerReferences: configmaps &quot;runner-vxpkh225-project-47-concurrent-0-scripts9ds4c&quot; is forbidden: User &quot;system:serviceaccount:gitlab:gitlab&quot; cannot update resource &quot;configmaps&quot; in API group &quot;&quot; in the namespace &quot;gitlab&quot;. Check https://docs.gitlab.com/runner/shells/index.html#shell-profile-loading for more information </code></pre> <p>That URL talks about bash logout scripts containing bad things. But nothing changed. At least we didn't change anything. I believe the second error implying that the user doesn't have permissions is not correct. It seems to just be saying that the user couldn't do it. The primary error being the previous one about the configmaps clean up. Again, no serviceaccounts, roles, rolebindings, etc have changed in any way.</p> <p>So I'm trying to work out what may CAUSE that error. What does it MEAN? What resource name is empty? Where can I find out?</p> <p>I've checked the output from &quot;docker container logs &quot; and it says exactly what's in the error above. No more, no less.</p> <p>The only thing I can think of is perhaps 14.3.2 of gitlab-runner doesn't like my k8s or the config. Going back and checking, it seems this has changed. Previous working pipelines ran in 14.1.</p> <p>So two questions then: 1) Any ideas how to fix the problem (eg update some config, clear some crud, whatever) and 2) How to I get gitlab to use a runner other than :latest?</p>
<p>Turns out something DID change. gitlab-runner changed and kubernetes pulled gitlab/gitlab-runner:latest between runs. Seems gitlab-runner 14.3 has a problem with my kubernetes. I went back through my pipelines and the last successful one was using 14.1</p> <p>So, after a day of working through it, I edited the relevant k8s deployment to redefine the image tag used for gitlab-runner to :v14.1.0 which is the last one that worked for me.</p> <p>Maybe I'll wait a few weeks and try a later one (now that I know how to easily change that tag) and see if the issue gets fixed. And perhaps go raise an issue on gitlab-runner</p>
<p>I'm trying to set some alarms based on replica set metrics but Prometheus cannot find <a href="https://github.com/kubernetes/kube-state-metrics/blob/master/docs/replicaset-metrics.md" rel="nofollow noreferrer">replicaset kube state metrics</a> while browsing expressions. What would be the problem with that? On Prometheus dashboard, I can see lots of metrics, which is in kube state metrics repo, but replica sets. Any ideas?</p> <p>Kube state metrics version: v1.9.7</p> <p>Update:</p> <p>For example, I can see most of <a href="https://github.com/kubernetes/kube-state-metrics/blob/master/docs/deployment-metrics.md" rel="nofollow noreferrer">deployment metrics</a> on the dashboard, but no metrics for replica sets.</p> <p><a href="https://i.stack.imgur.com/W2GXB.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/W2GXB.png" alt="enter image description here" /></a></p>
<p>This is a community wiki answer posted for better clarity. Feel free to expand it.</p> <p>As @ cosmos-1905-14 described, he checked the kube-state-metric logs and found that the ServiceAccount did not have sufficient rights to access the ReplicaSets. After he added the necessary rights, the issue was resolved.</p>
<p>So I am deploying an EMR application using EKS, following the EMR-EKS workshop by AWS, declaring the Fargate profile.</p> <p>I tried everything to be serverless, so even my EKS Cluster runs on Fargate (kube-sytem, default, etc).</p> <p>I created a custom namespace with a Fargate profile, and submit a Spark job. The job stayed at Pending status.</p> <p>When I added some managed nodegroups, the job was submitted successfully.</p> <p>I tried submitting very light jobs and by the time I removed the managed node groups, spark jobs stay at pending status.</p> <pre><code>Events: Type Reason Age From Message ---- ------ ---- ---- ------- Warning FailedScheduling 33s (x7 over 5m43s) default-scheduler 0/2 nodes are available: 2 node(s) had taint {eks.amazonaws.com/compute-type: fargate}, that the pod didn't tolerate. </code></pre> <p><strong>eksworkshop-eksctl.yaml</strong></p> <pre><code>apiVersion: eksctl.io/v1alpha5 kind: ClusterConfig metadata: name: eksworkshop-eksctl region: ${AWS_REGION} version: &quot;1.21&quot; availabilityZones: [&quot;${AZS[0]}&quot;, &quot;${AZS[1]}&quot;, &quot;${AZS[2]}&quot;, &quot;${AZS[3]}&quot;] fargateProfiles: - name: default selectors: # All workloads in the &quot;default&quot; Kubernetes namespace will be # scheduled onto Fargate: - namespace: default # All workloads in the &quot;kube-system&quot; Kubernetes namespace will be # scheduled onto Fargate: - namespace: kube-system </code></pre> <p>Create the EKS cluster:</p> <pre><code>eksctl create cluster -f eksworkshop-eksctl.yaml </code></pre> <p>Create namespace and fargate profile:</p> <pre><code>kubectl create namespace spark eksctl create fargateprofile --cluster eksworkshop-eksctl --name emr \ --namespace spark --labels type=etl </code></pre> <p>Create virtual cluster:</p> <p>I have already added the labels under sparkSubmitParameters, but it is still stuck in Pending state. :( Is there additional configuration I need to add when creating virtual cluster:</p> <pre><code>aws emr-containers create-virtual-cluster \ --name eksworkshop-eksctl \ --container-provider '{ &quot;id&quot;: &quot;eksworkshop-eksctl&quot;, &quot;type&quot;: &quot;EKS&quot;, &quot;info&quot;: { &quot;eksInfo&quot;: { &quot;namespace&quot;: &quot;spark&quot; } } }' </code></pre> <p>Submit the spark job:</p> <pre><code>aws emr-containers start-job-run --virtual-cluster-id $VIRTUAL_CLUSTER_ID --name spark-pi-logging --execution-role-arn $EMR_ROLE_ARN --release-label emr-6.2.0-latest --job-driver '{ &quot;sparkSubmitJobDriver&quot;: { &quot;entryPoint&quot;: &quot;s3://aws-data-analytics-workshops/emr-eks-workshop/scripts/pi.py&quot;, &quot;sparkSubmitParameters&quot;: &quot;--conf spark.kubernetes.driver.label.type=etl --conf spark.kubernetes.executor.label.type=etl --conf spark.executor.instances=2 --conf spark.executor.memory=2G --conf spark.executor.cores=2 --conf spark.driver.cores=1&quot; } }' --configuration-overrides '{ &quot;applicationConfiguration&quot;: [ { &quot;classification&quot;: &quot;spark-defaults&quot;, &quot;properties&quot;: { &quot;spark.driver.memory&quot;:&quot;2G&quot; } } ], &quot;monitoringConfiguration&quot;: { &quot;cloudWatchMonitoringConfiguration&quot;: { &quot;logGroupName&quot;: &quot;/emr-containers/jobs&quot;, &quot;logStreamNamePrefix&quot;: &quot;emr-eks-workshop&quot; }, &quot;s3MonitoringConfiguration&quot;: { &quot;logUri&quot;: &quot;'&quot;$s3DemoBucket&quot;'/logs/&quot; } } }' </code></pre> <p>For EKS cluster, is NodeGroup must be declared and is mandatory, and we can't run Spark Job just be using Fargate only?</p>
<p>Your situation:</p> <p><code>...created fargate-profile with the same namespace: Job completed</code></p> <p><code>... created fargate-profile with the same namespace but with labels...Job stucked in Pending </code></p> <p>If a namespace is associated with &gt;1 profile, EKS will randomly choose a profile. When it picks a profile that requires a label and your spark job don't have it - it goes into pending state since there is no other node group in your cluster.</p> <p><code>Is it required to have 2 profiles, one with label, and one with no label</code></p> <p>No, in fact you should not do this. To run job on a profile with labels your job <code>sparkSubmitParameters</code> must specify the label:</p> <p><code>&quot;sparkSubmitParameters&quot;: &quot;...--conf spark.kubernetes.driver.label.&lt;label key&gt;=&lt;value&gt; --conf spark.kubernetes.executor.label.&lt;label key&gt;=&lt;value&gt;...&quot;</code></p> <p>You don't need &gt;1 Fargate profile unless you need to distinguish spark jobs by Fargate profile selector.</p>
<p>I have one laravel docker container which is build with a custom nginx + php-fpm docker image.</p> <p>I have deployed successfully to a k8s cluster and can access properly, also logging into the pod and running <code>env</code> I can see all the environment variables being set successfully from my k8s <code>configmap</code></p> <p>In the laravel code I read the environment variables like this: For example at <code>SomeController.php</code> have the following code:</p> <pre><code>$apiCode = env('API_CODE'); // also tried like this $apiCode = getenv('API_CODE'); still not successful in fetching </code></pre> <p>My problem and this question is that the env vars are always read empty inside the php code even though inside the pod with <code>env</code> command I can see them properly set, somehow the php code cannot find them.</p> <p>(I am not caching laravel config so that case we can exclude, also tried with the command <code>php artisan config:clear</code> beforehand, still same result cannot fetch the env vars within the php)</p> <p>In the kubernetes definition yml I attach the configmap to env variables like below and see them defined properly inside pod:</p> <pre><code>apiVersion: apps/v1 kind: Deployment metadata: name: api labels: tier: api spec: replicas: 1 selector: matchLabels: tier: api template: metadata: labels: tier: api spec: containers: - name: api image: somenging-fpm-image:latest ports: - containerPort: 80 envFrom: - configMapRef: name: api-config-env-file </code></pre> <p>For the moment I am lost and without any idea why this might happen.</p> <p>I thought initially that maybe configmap was created late after pod started (php fpm somehow process then did not pick on start the env)</p> <p>To verify and exclude that case, I destroyed the pod and recreated the deployment+pod in order to use the already existing configmap, and still the result was the same php did not pick up the env vars that were present in pod</p> <p>I could log into pod by <code>kubectl exec -it [podnamehere] /bin/bash</code> and run <code>env</code> there and could see properly env vars set from my configmap <code>api-config-env-file</code>, but the code would always have them empty not be able to read them</p>
<p>I encountered this problems only when there are <code>redis</code> or caching system.</p> <p>But you already state that</p> <blockquote> <p>(I am not caching laravel config so that case we can exclude, also tried with the command php artisan config:clear beforehand, still same result cannot fetch the env vars within the php)</p> </blockquote> <p>So double check if you run any command like <code>php artisan optimize</code>. It will save the cache to redis, and the laravel application will pick the setting up from there.</p> <p>Just to make sure you don't miss anything.</p> <p>Try: <code>php artisan optimize:clear</code></p> <p>This command will do the following:</p> <pre class="lang-sh prettyprint-override"><code>Cached events cleared! Compiled views cleared! Application cache cleared! Route cache cleared! Configuration cache cleared! Compiled services and packages files removed! Caches cleared successfully! </code></pre>
<p>I'm creating a pod for Databse server first and then an application server pod in openshift. And I'm doing it in Jenkinsfile, with openshift deployments handled by Kustomize.</p> <p>And the database routeurl varibale -DATABASE_DYNAMIC_ROUTEURL is in jenkinsfile.</p> <p>Below are my manifest files for deployment.</p> <p><strong>kustomization.yaml</strong></p> <pre><code>kind: Kustomization resources: - deployment.yaml </code></pre> <p><strong>deployment.yaml</strong></p> <pre><code>apiVersion: apps/v1 kind: Deployment metadata: name: myapp spec: progressDeadlineSeconds: 30 replicas: 1 selector: matchLabels: app: myapp template: metadata: labels: app: myapp spec: containers: - name: myapp image: myregistry.com/myapp:5c3dda6b ports: - containerPort: 80 imagePullPolicy: Always env: - name: DATABASE_DYNAMIC_ROUTEURL value:https://xyz-1234-databaseurl.com imagePullSecrets: - name: myregistry.com-registry-key readinessProbe: httpGet: path: / port: 8080 </code></pre> <p>I tried using kustomize patch to replace the value but it's not understanding the exact position to replace the value.</p> <pre><code>- patch: - op: replace path: /spec/template/spec/containers/0/image/0/value value: DATABASE_DYNAMIC_ROUTEURL </code></pre> <p>I am new to kustomize, can someone suggest which approach is good to implement the dynamic environment variable in deployment.yaml of application server file. Thanks in advance</p>
<p>You can try out something like</p> <pre><code>apiVersion: apps/v1 kind: Deployment metadata: name: demo labels: app: demo spec: selector: matchLabels: app: demo template: metadata: name: demo annotations: {} # initially unset. You may provide default values if you wish. labels: app: demo spec: containers: - name: demo image: demoimage env: - name: DOTNET_ENVIRONMENT valueFrom: fieldRef: fieldPath: metadata.annotations['environment'] </code></pre> <p><strong>kustomization.yaml</strong> file</p> <pre><code>- op: replace path: /spec/template/metadata/annotations/environment value: Production </code></pre> <p>You can also use the <strong>config map</strong> to store the environment config and add or inject it further to deployment.</p> <p>You can checkout this nice article : <a href="https://blog.stack-labs.com/code/kustomize-101/" rel="nofollow noreferrer">https://blog.stack-labs.com/code/kustomize-101/</a></p>
<p>I want to start practicing with k8s for the CKAD exam. I run on ubuntu 18.04. I noticed everywhere that I need to download <em>Virtualbox</em> for <em>minikube</em>. I believe that <em>VB</em> is needed in case I don't start my cluster with a driver but if I use the <em>Docker</em> driver when I start my cluster shouldn't that be enough? Is microk8s a better option?</p>
<p>It seems that the preferred way is use --driver=docker driver instead of --driver=none for minikube, although <strong>it is technically not baremetal</strong> as it is significantly easier to configure and does not require root access. The ‘none’ driver is recommended for advanced users only. (info below from <a href="https://minikube.sigs.k8s.io/docs/drivers/docker/" rel="nofollow noreferrer">https://minikube.sigs.k8s.io/docs/drivers/docker/</a>)</p> <p>docker Overview</p> <p>The Docker driver allows you to install Kubernetes into an existing Docker install. On Linux, this does not require virtualization to be enabled. Requirements</p> <ul> <li><p>Install Docker 18.09 or higher</p> </li> <li><p>amd64 or arm64 system.</p> </li> </ul> <p>Usage</p> <p>Start a cluster using the docker driver:</p> <pre><code>minikube start --driver=docker </code></pre> <p>To make docker the default driver:</p> <pre><code>minikube config set driver docker </code></pre>
<p>Below is the report for liveness &amp; readiness after running <code>kubectl -n mynamespace describe pod pod1</code>:</p> <pre><code>Liveness: http-get http://:8080/a/b/c/.well-known/heartbeat delay=3s timeout=3s period=10s #success=1 #failure=3 Readiness: http-get http://:8080/a/b/c/.well-known/heartbeat delay=3s timeout=3s period=10s #success=1 #failure=3 </code></pre> <hr /> <ol> <li><p>Is this the valid(working) url? <code>http://:80/</code></p> </li> <li><p>What does <code>#success=1 #failure=3</code> mean?</p> </li> </ol>
<p>The results are completely right:</p> <ul> <li>http://:8080 indicates that it will try an http-get in port 8080 inside your pod</li> <li>#success=1 indicates a success threshold of 1 (the default), so the first time it gets an answer it will mark the pod as live or ready</li> <li>#failure=3 indicates a failure threshold of 3 (the default again), so the third time the call fails will mark it unready or try to restart it.</li> </ul> <p>See the official docs: <a href="https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-startup-probes/#configure-probes" rel="nofollow noreferrer">https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-startup-probes/#configure-probes</a></p> <p>You may try to execute this command to see how the probes are configured:</p> <pre class="lang-bash prettyprint-override"><code>kubectl -n mynamespace get pod pod1 -o yaml </code></pre>
<p>I have a service providing an API that I want to only be accessible over <code>https</code>. I don't want <code>http</code> to redirect to <code>https</code> because that will expose credentials and the caller won't notice. Better to get an error response.</p> <p>How to do I configure my ingress.yaml? Note that I want to maintain the default 308 redirect from <code>http</code> to <code>https</code> for other services in the same cluster.</p> <p>Thanks.</p>
<p>In the <a href="https://kubernetes.github.io/ingress-nginx/user-guide/nginx-configuration/annotations/#server-side-https-enforcement-through-redirect" rel="nofollow noreferrer">documentation</a>: you can read the following sentence about HTTPS enforcement through redirect:</p> <blockquote> <p>By default the controller redirects (308) to HTTPS if TLS is enabled for that ingress. If you want to disable this behavior globally, you can use <code>ssl-redirect: &quot;false&quot;</code> 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> <blockquote> <p>To configure this feature for specific ingress resources, you can use the nginx.ingress.kubernetes.io/ssl-redirect: &quot;false&quot; annotation in the particular resource.</p> </blockquote> <p>You can also create two separate configurations: one with http and https and the other one only for http.</p> <p>Using <a href="https://kubernetes.github.io/ingress-nginx/user-guide/multiple-ingress/" rel="nofollow noreferrer"><code>kubernetes.io/ingress.class</code></a> annotation you can choose the ingress controller to be used.</p> <blockquote> <p>This mechanism also provides users the ability to run <em>multiple</em> NGINX ingress controllers (e.g. one which serves public traffic, one which serves &quot;internal&quot; traffic).</p> </blockquote> <p>See also <a href="https://stackoverflow.com/questions/56302606/kubernetes-ingress-nginx-how-can-i-disable-listening-on-https-if-no-tls-config">this</a> and <a href="https://stackoverflow.com/questions/50087544/disable-ssl-redirect-for-kubernetes-nginx-ingress/50087545">this</a> similar questions.</p>
<p>I've stumbled upon a problem when using some more complex argo workflows with initialization and clean-up logic. We are running some initialization in one of the initial steps of the workflow (e.g. creation of some resources) and we'd like to perform a clean-up regardless of the status of the workflow. <code>onExit</code> template seems to be an ideal solution (I think that clean-up is even mentioned in argo documentation as predestined for tasks of the <code>onExit</code> template).</p> <p>However, I haven't found a way yet to pass some values to it. For example - let's say that in the initialization phase we created some resource with id <code>some-random-unique-id</code> and we'd like to let the <code>onExit</code> container know what resources it needs to clean up.</p> <p>We tried the <code>outputs</code> of some steps, but it seems that <code>steps</code> are unknown in the <code>onExit</code> template.</p> <p>Is there a built-in argo mechanism to pass this kind of data? We'd like to avoid some external services (like key-value storage service that would hold the context).</p>
<p>You can mark output parameters as global using the <code>globalName</code> field. A global output parameter, assuming it has been set, can be accessed from anywhere in the Workflow, including in an exit handler.</p> <p>The example file for writing and consuming global output parameters should contain all the information you need to use global output parameters in an exit handler.</p> <p><a href="https://github.com/argoproj/argo-workflows/blob/master/examples/global-outputs.yaml" rel="nofollow noreferrer">https://github.com/argoproj/argo-workflows/blob/master/examples/global-outputs.yaml</a></p>
<p>I have a few applications hosted on a single <code>Amazon Load Balancer</code>, at different endpoints on the <code>ALB</code> etc. This is server and generated through <code>Kubernetes EKS</code>.</p> <pre><code> - path: /* backend: serviceName: ssl-redirect servicePort: use-annotation - path: /a/* backend: serviceName: service-1 servicePort: 8080 - path: /b/* backend: serviceName: service-2 servicePort: 8085 </code></pre> <p>For the <code>/*</code> path, I have it route to a <code>Vue UI</code> application.</p> <p>This application has a few routes, with client side routing. These routes work fine when done through the <code>UI</code>. I want to be able to link directly to these client side routes through the URL bar, or at least redirect to the root <code>UI</code>. However, when I try to hit it directly, and just route to the <code>UI</code> component in the ingress:</p> <pre><code> - path: /path1/* backend: serviceName: ui servicePort: 80 - path: /path2/* backend: serviceName: ui servicePort: 80 - path: /* backend: serviceName: ui servicePort: 80 </code></pre> <p>The regular <code>UI</code> route still works, however <code>/path1</code> and <code>/path2</code> return 404. The other applications in this ingress return fine (<code>/path a</code> and <code>/path b</code>, <code>/service-1</code> and <code>/service-2</code>).</p>
<p>Server-side and client side routings are completely different.</p> <p>You want to make server-side routing. I.e, server-side rules should exist. Server app doesn't know neither <code>/path1</code> nor <code>/path2</code>. Therefore, you get <code>404</code> from the server.</p>
<p>I would like to access a Windows file share share (SMB3) from a docker container, but I do not want to compromise the security of the host machine. All the guides I have read state that I need to use either the <code>--privileged</code> flag or <code>--cap-add SYS_ADMIN</code> capability.</p> <p>Here is the command I use:</p> <blockquote> <p>mount -t cifs -o username='some_account@mydomain.internal',password='some_password' //192.168.123.123/MyShare /mnt/myshare</p> </blockquote> <p>Which results in the message:</p> <blockquote> <p>Unable to apply new capability set.</p> </blockquote> <p>When I apply the <code>--cap-add SYS_ADMIN</code> capability the mount command works fine, but I understand this exposes the host to obvious security vulnerabilities.</p> <p>I have also read the suggestion in this StackOverflow question (<a href="https://stackoverflow.com/questions/27989751/mount-smb-cifs-share-within-a-docker-container">Mount SMB/CIFS share within a Docker container</a>) to mount the volume locally on the server that runs docker. This is undesirable for two reasons, firstly, the container is orchestrated by a Rancher Kubernetes cluster and I don't know how to achieve what is described by nPcomp using Rancher, and two, this means the volume is accessible to the docker host. I'd prefer only the container have access to this share via the credentials given to it via secrets.</p> <p>My question is: is there way to mount a CIFS/SMB3 share in a docker container (within Kubernetes) without exposing the host to privilege escalation vulnerabilities and protecting the credentials? Many thanks.</p>
<p>After more research I have figured out how to do this. There is a Container Storage Interface (CSI) driver for SMB called <strong>SMB CSI Driver for Kubernetes</strong> (<a href="https://github.com/kubernetes-csi/csi-driver-smb" rel="noreferrer">https://github.com/kubernetes-csi/csi-driver-smb</a>).</p> <p>After installing the CSI driver using helm (<a href="https://github.com/kubernetes-csi/csi-driver-smb/tree/master/charts" rel="noreferrer">https://github.com/kubernetes-csi/csi-driver-smb/tree/master/charts</a>) you can follow the example at <a href="https://github.com/kubernetes-csi/csi-driver-smb/blob/master/deploy/example/e2e_usage.md" rel="noreferrer">https://github.com/kubernetes-csi/csi-driver-smb/blob/master/deploy/example/e2e_usage.md</a> (<strong>Option #2 Create PV/PVC</strong>) to create a Persistent Volume (PV) and Persistent Volume Claim (PVC) which mounts the SMB3 share.</p> <p>Then you create your container and give it the relevant Persistent Volume Claim, specifying you want to mount it as /mnt/myshare etc.</p> <p>I tested this and it gets deployed to multiple worker nodes automatically and works well, without needing the <code>privileged</code> flag or <code>--cap-add SYS_ADMIN</code> to be given to the containers.</p> <p>This supports SMB3 and even authentication &amp; encryption. To enable encryption go to your Windows Server &gt; File and Storage Services, select the share, Properties &gt; Settings &gt; Encrypt Data Access.</p> <p>Wireshark shows all the SMB traffic is encrypted. Only thing I don't recall is if you have to install <code>cifs-utils</code> manually first, since I had already done this on all my nodes I wasn't able to test.</p> <p>Hope this helps somebody.</p>
<p>I have a k8s cluster running locally on an arm Mac. I have client and server pods. The client is a React frontend. The server is an express server connecting to a mongodb Atlas cluster.</p> <p>So far the images build fine and all pods are running.</p> <p>The problem is the internal port routing is not working. All I see is</p> <pre><code>GET http://localhost:5000/ net::ERR_CONNECTION_REFUSED </code></pre> <p>And the referrer policy in the networking tab suggests a CORS error:</p> <pre><code>Referrer Policy: strict-origin-when-cross-origin </code></pre> <p>I'm not sure what I need to do to get my client to fetch on a certain port? So far I have this, which works outside of k8s:</p> <pre><code>const getAllUsers = () =&gt; { fetch(&quot;http://localhost:5000/&quot;) .then((res) =&gt; res.text()) .then((res) =&gt; { return setUsers(JSON.parse(res)); }); }; </code></pre> <p>The server has this code to handle the request:</p> <pre><code> app.get(&quot;/&quot;, (req, res) =&gt; { usersCollection .find() .toArray() .then((results) =&gt; { res.json(results); }) .catch((error) =&gt; console.error(error)); }); </code></pre> <p>My server cluster ip service is like this:</p> <pre><code>apiVersion: v1 kind: Service metadata: name: server-cluster-ip-service spec: type: ClusterIP selector: component: server ports: - port: 5000 targetPort: 5000 </code></pre> <p>And my server deployment is like this:</p> <pre><code>apiVersion: apps/v1 kind: Deployment metadata: name: server-deployment spec: replicas: 3 selector: matchLabels: component: server template: metadata: labels: component: server spec: containers: - name: server image: mydocker/k8s-server ports: - containerPort: 5000 env: - name: REDIS_HOST value: redis-cluster-ip-service - name: REDIS_PORT value: &quot;6379&quot; </code></pre> <p>When I log out the server deployment logs I get:</p> <pre><code>&gt; express_mongodb@1.0.0 dev /app &gt; nodemon server.js [nodemon] 2.0.12 [nodemon] to restart at any time, enter `rs` [nodemon] watching path(s): *.* [nodemon] watching extensions: js,mjs,json [nodemon] starting `node server.js` Connected to Database listening on 5000 </code></pre> <p>Which is great - it's listening on the port I specified with</p> <pre><code> app.listen(PORT, function () { console.log(&quot;listening on 5000&quot;); }); </code></pre> <p>There's something I'm not getting here. The first thing I want to do is make sure my server is connected to my client on port 5000 - what am I doing wrong?</p> <p>EDIT: After a long time looking at CORS error fixes, maybe it isn't a CORS error? I curl the service ip with:</p> <pre><code>curl my.ip.##.## </code></pre> <p>Then try:</p> <pre><code>curl localhost:5000 </code></pre> <p>But the requests time out.</p> <p>I use <code>kubectl describe service server-cluster-ip-service</code></p> <p>and get back</p> <pre><code>Name: server-cluster-ip-service Namespace: default Labels: &lt;none&gt; Annotations: &lt;none&gt; Selector: component=server Type: ClusterIP IP Family Policy: SingleStack IP Families: IPv4 IP: 10.###.##.## IPs: 10.###.##.## Port: &lt;unset&gt; 5000/TCP TargetPort: 5000/TCP Endpoints: 172.##.#.##:5000,172.##.#.##,172.##.#.## Session Affinity: None Events: &lt;none&gt; </code></pre>
<p>Ideally, you should be using the service name to communicate with different services inside the cluster.</p> <p>If you react server want to talk with the express server, you have to the <code>express-service-name</code> as host into the <strong>react</strong> service. Kubernetes will auto manage the resolution.</p> <p>so for you, it will be <code>server-cluster-ip-service</code></p> <pre><code>const getAllUsers = () =&gt; { fetch(&quot;http://server-cluster-ip-service:5000/&quot;) .then((res) =&gt; res.text()) .then((res) =&gt; { return setUsers(JSON.parse(res)); }); }; </code></pre> <p>As in a single machine or in a host all services can talk to each other on <strong>localhost</strong> the same way in Kubernetes cluster services uses the service name to solve each other.</p> <p>Reference document DNS for services &amp; POD: <a href="https://kubernetes.io/docs/concepts/services-networking/dns-pod-service/" rel="nofollow noreferrer">https://kubernetes.io/docs/concepts/services-networking/dns-pod-service/</a></p> <p>You express cluster POD or application will run on <code>0.0.0.0/0</code> and port <code>5000</code> and there will be one <strong>Kubernetes service</strong> as your created now with <code>target port 5000</code>.</p> <p>Your client or other application internally will call this service by <strong>service name</strong> and request redirected to container (POD) of the express server.</p>
<p>I'm trying to deploy a hello world container in kubernetes using Pulumi and GCP</p> <p>Basically I just want this local helloworld container to be deployed in an existing k8s cluster on GCP made following <a href="https://www.pulumi.com/docs/tutorials/gcp/gcp-ts-gke-hello-world/" rel="nofollow noreferrer">this tutorial</a>.</p> <p>Deploying local images is what is done in <a href="https://www.pulumi.com/docs/guides/crosswalk/kubernetes/apps/" rel="nofollow noreferrer">this other example</a>, however I need to add registry information which causes an error: <code>Property 'repositoryUrl' does not exist on type 'Promise&lt;GetRegistryRepositoryResult&gt;'.</code></p> <pre><code>const registry = gcp.container.getRegistryRepository(); // Build a Docker image from a local Dockerfile context in the // './mydockerimg' directory, and push it to the registry. //const registry = gcp.container.getRegistryRepository(); const customImage = &quot;mydockerimg&quot;; const appImage = new docker.Image(customImage, { // imageName: pulumi.interpolate`${registry.repositoryUrl}/${customImage}:v1.0.0`, imageName: &quot;mydockerimg&quot;, build: { context: `./${customImage}`, }, }); // Create a k8s provider. // NOT NEEDED // Create a Deployment of the built container. const appLabels_helloworld = { app: customImage }; const appDeployment = new k8s.apps.v1.Deployment(&quot;app&quot;, { spec: { selector: { matchLabels: appLabels_helloworld }, replicas: 1, template: { metadata: { labels: appLabels_helloworld }, spec: { containers: [{ name: customImage, image: appImage.imageName, ports: [{name: &quot;http&quot;, containerPort: 80}], }], } }, } }, { provider: clusterProvider }); </code></pre> <p>When I just use <code>imageName: &quot;mydockerimg&quot;,</code> rather than a registry, pulumi accepts the upgrade, but then I have a docker push error:</p> <pre><code>error: Error: ' docker push mydockerimg:4aff09801cccc271a8182a3eb3bc46a25764fdbb5332230c6aa707e3b90c4d4e' failed with exit code 1 The push refers to repository [docker.io/library/mydockerimg] </code></pre> <p>Any help?</p> <hr /> <p><strong>EDIT:</strong> After applying Yaron Idan's suggestion below, <code>pulumi up</code> is working, but still not exporting the app, being unable to push.</p> <pre><code>const gcrLocation = registry.then(registry =&gt; registry.repositoryUrl); ... imageName: pulumi.interpolate`${gcrLocation}/${customImage}:v1.0.0`, ... export const appDeploymentName = appDeployment.metadata.apply(m =&gt; m.name); </code></pre> <p>The error:</p> <pre><code> Error: ' docker push gcr.io/XXX' failed with exit code 1 </code></pre> <p>After some more investigation I have error: name unknown: Buckets(projectID,artifacts.napoleongamesassignment.appspot.com)</p> <p>after trying to <code>docker push gcr.io/myprojectID/myrstudio:latest</code>,</p> <p>created <a href="https://stackoverflow.com/questions/69431077/docker-push-to-google-cloud-gcp-fails-with-name-unknown-buckets">another question</a></p>
<p>It looks like you're trying to extract the repository URL from the promise instead of it's resolution.<br /> Going by this <a href="https://www.pulumi.com/docs/reference/pkg/gcp/container/getregistryrepository/" rel="nofollow noreferrer">example</a> from the Pulumi docs, it looks like changing your code from</p> <pre><code>imageName: pulumi.interpolate`${registry.repositoryUrl}/${customImage}:v1.0.0`, </code></pre> <p>to</p> <pre><code>imageName: pulumi.interpolate`${registry.then(foo =&gt; foo.repositoryUrl)}/${customImage}:v1.0.0`, </code></pre> <p>Might give you the results you're looking for.</p>
<p>I have set up my application to be served by a Kubernetes NGINX ingress in AKS. Today while experimenting with the Azure API management, I tried to set it up so that all the traffic to the ingress controller would go through the API management. I pointed its backend service to the current public address of the ingress controller but I was wondering when I make the ingress controller private or remove it altogether to rely on the Kubernetes services instead, how API management could access it and how I would define the backend service in API management. By the way, while provisioning the API management instance, I added a new subnet to the existing virtual network of the AKS instance so they are in the same network.</p>
<p>There are two modes of <a href="https://learn.microsoft.com/en-us/azure/api-management/api-management-using-with-vnet" rel="nofollow noreferrer">deploying API Management into a VNet</a> – External and Internal.</p> <p>If API consumers do not reside in the cluster VNet, the External mode (Fig below) should be used. In this mode, the API Management gateway is injected into the cluster VNet but accessible from public internet via an external load balancer. It helps to hide the cluster completely while still allowing external clients to consume the microservices. Additionally, you can use Azure networking capabilities such as Network Security Groups (NSG) to restrict network traffic.</p> <p><a href="https://i.stack.imgur.com/N6Usy.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/N6Usy.png" alt="enter image description here" /></a></p> <p>If all API consumers reside within the cluster VNet, then the Internal mode (Figure below) could be used. In this mode, the API Management gateway is injected into the cluster VNET and accessible only from within this VNet via an internal load balancer. There is no way to reach the API Management gateway or the AKS cluster from public internet.</p> <p><a href="https://i.stack.imgur.com/IbA1Q.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/IbA1Q.png" alt="enter image description here" /></a></p> <p><strong>In both cases, the AKS cluster is not publicly visible</strong>. The Ingress Controller may not be necessary. Depending on your scenario and configuration, authentication might still be required between API Management and your microservices. For instance, if a Service Mesh is adopted, it always requires mutual TLS authentication.</p> <p>Pros:</p> <ul> <li>The most secure option because the AKS cluster has no public endpoint</li> <li>Simplifies cluster configuration since it has no public endpoint</li> <li>Ability to hide both API Management and AKS inside the VNet using the Internal mode</li> <li>Ability to control network traffic using Azure networking capabilities such as Network Security Groups (NSG)</li> </ul> <p>Cons:</p> <ul> <li>Increases complexity of deploying and configuring API Management to work inside the VNet</li> </ul> <p><a href="https://learn.microsoft.com/en-us/azure/api-management/api-management-kubernetes#option-3-deploy-apim-inside-the-cluster-vnet" rel="nofollow noreferrer">Reference</a></p> <hr /> <p>To restrict access to your applications in Azure Kubernetes Service (AKS), you can create and use an internal load balancer. An internal load balancer makes a Kubernetes service accessible only to applications running in the same virtual network as the Kubernetes cluster.</p> <p>You can either expose your the backends on the AKS cluster through <a href="https://learn.microsoft.com/en-us/azure/aks/ingress-internal-ip" rel="nofollow noreferrer">internal Ingress</a> or simply using <a href="https://learn.microsoft.com/en-us/azure/aks/internal-lb" rel="nofollow noreferrer">Services of type internal load balancer</a>.</p> <p>You can then point the API Gateway's backend to the internal Ingress' Private IP address or the internal load balancers Service's EXTERNAL IP (which would also be a private IP address). These private IP addresses are accessible within the Virtual Network and any connected network (i.e. Azure virtual networks connected through peering or Vnet-to-Vnet Gateway, or on-premises networks connected to the AKS Vnet). In your case, if the API Gateway is deployed in the same Virtual Network then, it should be able to access these private IP addresses. If the API Gateway is deployed in a different Virtual Network, please connect it to the AKS virtual network using <a href="https://azure.microsoft.com/en-in/blog/vnet-peering-and-vpn-gateways/" rel="nofollow noreferrer">VNET Peering or Vnet-to-Vnet Gateway</a>, depending on your use-case.</p>
<p>In the below yaml syntax:</p> <pre><code> readinessProbe: httpGet: path: /index.html port: 80 initialDelaySeconds: 3 timeoutSeconds: 3 periodSeconds: 10 failureThreshold: 3 </code></pre> <hr /> <p>Readiness probe is used during initial deployments of Pod.</p> <ol> <li><p>For rolling out new version of application, using rolling deployment strategy, Is readiness probe used for rolling deployment?</p> </li> <li><p><code>path</code> &amp; <code>port</code> field allows to input url &amp; port number of a specific service, but not dependent service. how to verify, if dependent service is also ready?</p> </li> </ol>
<blockquote> <p>using rolling deployment strategy, Is readiness probe used for rolling deployment?</p> </blockquote> <p>Yes, the new version of Pods is rolled out and older Pods are not terminated until the new version has Pods in <em>ready</em> state.</p> <p>E.g. if you roll out a new version, that has a bug so that the Pods does not become ready - the old Pods will still be running and the traffic is only routed to the <em>ready</em> old Pods.</p> <p>Also, if you don't specify a <em>readinessProbe</em>, the <em>process</em> status is used, e.g. a <em>process</em> that terminates will not be seen as <em>ready</em>.</p> <blockquote> <p>how to verify, if dependent service is also ready?</p> </blockquote> <p>You can configure a custom <em>readinessProbe</em>, e.g. a http-endpoint on <code>/healtz</code> and it is up to you what logic you want to use in the implementation of that endpoint. A http response code of 2xx is seen as <em>ready</em>.</p>
<pre><code>kubectl create secret docker-registry $SECRET_NAME \ --dry-run=client \ --docker-server=&quot;$ECR_REGISTRY&quot; \ --docker-username=AWS \ --docker-password=&quot;$(&lt;/token/ecr-token)&quot; \ -o yaml </code></pre> <p>file token/ecr-token is in place but still not able to populate in --docker-password</p>
<p>The <code>$(&lt; /path/to/a/file)</code> syntax is a special form of command substitution that is supported by several UNIX shells, including <a href="https://docs.oracle.com/cd/E36784_01/html/E36870/ksh-1.html" rel="nofollow noreferrer">ksh</a> (Oracle online documentation), <a href="https://www.gnu.org/savannah-checkouts/gnu/bash/manual/html_node/Command-Substitution.html#Command-Substitution" rel="nofollow noreferrer">bash</a>, and <a href="https://zsh.sourceforge.io/Doc/Release/Expansion.html#Command-Substitution" rel="nofollow noreferrer">zsh</a>. It attempts to open the listed file and then reads the contents of that file in place of the <code>$(&lt; ...)</code>. It is distinct from command substitution in that it does not execute the given file or its contents.</p> <p>See more details at this UNIX &amp; Linux Q/A: <a href="https://unix.stackexchange.com/q/189749/117549">Understanding Bash's Read-a-File Command Substitution</a>.</p> <p>Note that your command specifies an <em>absolute</em> file path of <code>/token/ecr-token</code> but then later describe a <em>relative</em> path of <code>token/ecr-token</code>. If you're using a relative path in the command-line, that file will need to exist relative to your current working directory. Of course, the file must be readable by the current user for the contents to be read.</p> <p>If your shell does not support this feature, a workaround is to use <code>$(cat /path/to/a/file)</code>, for instance:</p> <pre class="lang-sh prettyprint-override"><code>kubectl create secret docker-registry &quot;$SECRET_NAME&quot; \ --dry-run=client \ --docker-server=&quot;$ECR_REGISTRY&quot; \ --docker-username=AWS \ --docker-password=&quot;$(cat /token/ecr-token)&quot; \ -o yaml </code></pre>
<p>Pod lifecycle is managed by Kubelet in data plane.</p> <p>As per the definition: If the liveness probe fails, the kubelet kills the container</p> <p>Pod is just a container with dedicated network namespace &amp; IPC namespace with a sandbox container.</p> <hr /> <p>Say, if the Pod is single app container Pod, then upon liveness failure:</p> <ul> <li>Does kubelet kill the Pod?</li> </ul> <p>or</p> <ul> <li>Does kubelet kill the container (only) within the Pod?</li> </ul>
<p>A pod is indeed the smallest element in Kubernetes, but that does not mean it is in fact &quot;empty&quot; without a container.</p> <p>In order to spawn a pod and therefore the container elements needed to attach further containers a very small container is created using the <code>pause</code> image. This is used to allocate an IP that is then used for the pod. Afterward the init-containers or runtime container declared for the pod are started.</p> <p>If the lifeness probe fails, the container is restarted. The pod survives this. This is even important: You might want to get the logs of the crashed/restarted container afterwards. This would not be possible, if the pod was destroyed and recreated.</p>
<p>After deploying to <code>AWS EKS</code> I get this error <br/></p> <p>Gtihub repo: <a href="https://github.com/oussamabouchikhi/udagram-microservices" rel="nofollow noreferrer">https://github.com/oussamabouchikhi/udagram-microservices</a></p> <p><br/>Steps to reproduce</p> <ol> <li>Create <code>AWS EKS</code> cluster and node groups</li> <li>Configure <code>EKS</code> cluster with <code>kubectl</code></li> <li>Deploy to <code>EKS</code> cluster (secrets first, then other services, then reverserproxy) <br/>. <code>kubectl apply -f env-secret.yaml</code> <br/>. <code>kubectl apply -f aws-secret.yaml</code> <br/>. <code>kubectl apply -f env-configmap.yaml</code> <br/>. ... <br/>. <code>kubectl apply -f reverseproxy-deployment.yaml</code> <br/>. <code>kubectl apply -f reverseproxy-service.yaml</code></li> </ol> <p><a href="https://i.stack.imgur.com/bQGqF.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/bQGqF.png" alt="enter image description here" /></a></p> <p>nginx-config</p> <pre><code>worker_processes 1; events { worker_connections 1024; } error_log /dev/stdout debug; http { sendfile on; upstream users { server udagram-users:8080; } upstream feed { server udagram-feed:8080; } proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Host $server_name; server { listen 8080; location /api/v0/feed { resolver 8.8.8.8; proxy_pass http://feed; } location /api/v0/users { resolver 8.8.8.8; proxy_pass http://users; } } } </code></pre> <p>docker-compose</p> <pre><code>version: '3' services: reverseproxy: image: oussamabouchikhi/reverseproxy ports: - 8080:8080 restart: always depends_on: - udagram-users - udagram-feed networks: - example-net udagram-users: image: oussamabouchikhi/udagram-api-users volumes: - $HOME/.aws:/root/.aws environment: POSTGRES_USERNAME: $POSTGRES_USERNAME POSTGRES_PASSWORD: $POSTGRES_PASSWORD POSTGRES_DB: $POSTGRES_DB POSTGRES_HOST: $POSTGRES_HOST AWS_REGION: $AWS_REGION AWS_PROFILE: $AWS_PROFILE AWS_MEDIA_BUCKET: $AWS_BUCKET JWT_SECRET: $JWT_SECRET URL: $URL networks: - example-net udagram-feed: image: oussamabouchikhi/udagram-api-feed volumes: - $HOME/.aws:/root/.aws environment: POSTGRES_USERNAME: $POSTGRES_USERNAME POSTGRES_PASSWORD: $POSTGRES_PASSWORD POSTGRES_DB: $POSTGRES_DB POSTGRES_HOST: $POSTGRES_HOST AWS_REGION: $AWS_REGION AWS_PROFILE: $AWS_PROFILE AWS_MEDIA_BUCKET: $AWS_BUCKET JWT_SECRET: $JWT_SECRET URL: $URL networks: - example-net udagram-frontend: image: oussamabouchikhi/udagram-frontend ports: - '8100:80' networks: - example-net networks: example-net: external: true </code></pre> <p>reverseproxy-deployment</p> <pre><code>apiVersion: apps/v1 kind: Deployment metadata: labels: service: reverseproxy name: reverseproxy spec: replicas: 1 selector: matchLabels: service: reverseproxy template: metadata: labels: service: reverseproxy spec: containers: - image: oussamabouchikhi/reverseproxy:latest name: reverseproxy imagePullPolicy: Always resources: requests: memory: '64Mi' cpu: '250m' limits: memory: '1024Mi' cpu: '500m' ports: - containerPort: 8080 restartPolicy: Always </code></pre> <p>reverseproxy-service</p> <pre><code>apiVersion: v1 kind: Service metadata: labels: service: reverseproxy name: reverseproxy spec: ports: - name: &quot;8080&quot; port: 8080 targetPort: 8080 selector: service: reverseproxy type: LoadBalancer </code></pre>
<h1>Use <code>resolver</code> in <code>nginx</code> config</h1> <p>The <code>nginx</code> <a href="https://nginx.org/en/docs/http/ngx_http_core_module.html#resolver" rel="nofollow noreferrer"><code>resolver</code></a> directive is required.</p> <p>Nginx is a multiplexing server (many connections in one OS process), so each call of system resolver will stop processing all connections till the resolver answer is received. That's why Nginx implemented its own internal non-blocking resolver.</p> <p>If your config file has static <code>DNS</code> names (not generated), and you do not care about track IP changes without <code>nginx reload</code>, you don't need <code>nginx</code>'s resolver. In this case all <code>DNS</code> names will be resolved on startup. <code>Nginx</code>'s resolver</p> <p><code>Nginx</code> <code>resolver</code> directive should be used, if you want to resolve domain name in runtime without <code>nginx</code> reload.</p> <p>E.g.:</p> <pre><code>location /my_uri { resolver kube-dns.kube-system valid=10s; ... } </code></pre> <pre><code>location /my_uri { resolver 127.0.0.1:53 ipv6=off valid=10s; ... } </code></pre> <h1>Use the same network (not your case, but still worth noting)</h1> <p>Containers you are trying to link may not be on the same network. You may want to put them all on the same network.</p> <p>In your case subnets are the same, it's ok:</p> <p><code>docker-compose</code></p> <pre><code>version: '3' services: reverseproxy: ... networks: - example-net udagram-users: ... networks: - example-net udagram-feed: ... networks: - example-net udagram-frontend: ... networks: - example-net networks: example-net: external: true </code></pre>
<p>We have several resources deployed as part of a helm (v3) chart. Some time ago, I made changes to resources deployed by that helm chart manually, via <code>kubectl</code>. This caused some drift between the values in the yaml resources deployed by the helm release (as show by <code>helm get values &lt;release&gt;</code>) and what is actually deployed in the cluster</p> <p>Example: <code>kubectl describe deployment &lt;deployment&gt;</code> shows an updated image that was manually applied via a <code>kubectl re-apply</code>. Whereas <code>helm show values &lt;release&gt;</code> shows the original image used by helm for said deployment.</p> <p>I realize that I should have performed a <code>helm upgrade</code> with a modified values.yaml file to execute the image change, but I am wondering if there is a way for me to sync the state of the values I manually updated with the values in the helm release. The goal is to create a new default <code>values.yaml</code> that reflect the current state of the cluster resources.</p> <p>Thanks!</p>
<p>This is a community wiki answer posted for better visibility. Feel free to expand it.</p> <p>According to the <a href="https://github.com/helm/helm/issues/2730" rel="nofollow noreferrer">Helm issue 2730</a> this feature will not be added in the Helm, as it is outside of the scope of the project.</p> <p>It looks like there is no existing tool right from the Helm, that would help to port/adapt the life kubernetes resource back into existing or new helm charts/releases.</p> <p>Based on this, you can use one of the following options:</p> <ol> <li>As suggested by @David Maze. The <a href="https://github.com/databus23/helm-diff" rel="nofollow noreferrer">Helm Diff Plugin</a> will show you the difference between the chart output and the cluster, but then you need to manually update values.yaml and templates.</li> <li>The <a href="https://github.com/HamzaZo/helm-adopt" rel="nofollow noreferrer">helm-adopt plugin</a> is a helm plugin to adopt existing k8s resources into a new generated helm chart.</li> </ol>
<p>I'm using <a href="https://github.com/prometheus-community/helm-charts/tree/main/charts/prometheus" rel="nofollow noreferrer">prometheus-community/prometheus</a> chart</p> <p>I'd like to add the following labels automatically to any alert manager rule firing</p> <ul> <li>env=<strong>prod</strong></li> <li>cluster=<strong>project-prod-eks</strong></li> </ul> <p>so that I don't these labels manually to each alert rule.</p> <pre class="lang-yaml prettyprint-override"><code> - alert: NGINXTooMany400s expr: 100 * ( sum( nginx_ingress_controller_requests{status=~&quot;4.+&quot;} ) / sum(nginx_ingress_controller_requests) ) &gt; 5 for: 1m labels: severity: warning env: prod cluster: project-prod-eks &lt;---------------HOW to inject them? annotations: description: Too many 4XXs summary: More than 5% of all requests returned 4XX, this requires your attention </code></pre> <p>so that I can do something like</p> <pre><code> - alert: NGINXTooMany400s expr: 100 * ( sum( nginx_ingress_controller_requests{status=~&quot;4.+&quot;} ) / sum(nginx_ingress_controller_requests) ) &gt; 5 for: 1m labels: severity: warning annotations: description: Too many 4XXs on {{ $labels.env }} / {{ $labels.cluster }} &lt;----- THIS summary: More than 5% of all requests returned 4XX, this requires your attention </code></pre> <h3>Any ideas?</h3>
<p>You can add <code>external_labels</code> to your <a href="https://prometheus.io/docs/prometheus/latest/configuration/configuration/" rel="nofollow noreferrer">prometheus.yml</a>:</p> <pre class="lang-yaml prettyprint-override"><code>global: # The labels to add to any time series or alerts when communicating with # external systems (federation, remote storage, Alertmanager). external_labels: env: prod cluster: project-prod-eks </code></pre> <p>The community chart has it in <a href="https://github.com/prometheus-community/helm-charts/blob/main/charts/prometheus/values.yaml#L1345" rel="nofollow noreferrer">values.yml</a>:</p> <pre class="lang-yaml prettyprint-override"><code>serverFiles: prometheus.yml: global: external_labels: foo: bar ... </code></pre>
<p>I have created a helm chart named "abc" with the command <code>helm create abc</code> Now when I install this chart, all the kuberenets resources created will have a name containing "abc".</p> <p>Now I have to rename the chart "abc" to "xyz". If i use <code>helm install --name xyz ./abc</code> only the chart name is changed to xyz. The resources inside it remain with "abc".</p> <p>I need to rename the entire chart (with its resources) to be renamed. Do I have any option for it?</p>
<p>I met this problem many times and I found the simplest solution. Just 2 steps:</p> <ol> <li>find and replace the name in the chart files.</li> <li>rename chart directory name</li> </ol> <p>Very simple if your chart name is quite unique.</p> <p>By default chart name is used in the files: <strong>Chart.yaml, templates_helpers.tpl</strong></p>
<p>I have a persistent volume defined as</p> <pre><code>apiVersion: v1 kind: PersistentVolumeClaim metadata: name: ghost-cms-content spec: accessModes: - ReadWriteOnce resources: requests: storage: 5Gi storageClassName: do-block-storage </code></pre> <p>and a deployment defined as</p> <pre><code>--- kind: Deployment apiVersion: apps/v1 metadata: name: ghost-cms spec: replicas: 4 strategy: type: RollingUpdate rollingUpdate: maxSurge: 1 maxUnavailable: 1 selector: matchLabels: app: ghost-cms tier: frontend template: metadata: labels: app: ghost-cms tier: frontend spec: topologySpreadConstraints: - maxSkew: 1 topologyKey: topology.kubernetes.io/region whenUnsatisfiable: ScheduleAnyway labelSelector: matchLabels: app: ghost-cms tier: frontend containers: - name: ghost-cms image: ghost:4.6-alpine imagePullPolicy: Always ports: - containerPort: 2368 volumeMounts: - mountPath: /var/lib/ghost/content name: content env: - name: url value: https://ghost.site resources: requests: cpu: 100m memory: 128Mi limits: cpu: 250m memory: 256Mi volumes: - name: content persistentVolumeClaim: claimName: ghost-cms-content </code></pre> <p>but each replica appears to have a unique volume that is not shared with the rest of the replicas. For instance, when I create a text file inside <code>/var/lib/ghost/content</code> in one of the pods, I don't see it in the volume of the other pods. What am I doing wrong?</p>
<p>PVC with permission</p> <pre><code>accessModes: - ReadWriteOnce </code></pre> <p>Each pod will get the one volume or PVC, as it's readwrite once.</p> <p>If you want to keep shared volume across replicas you can use the <strong>NFS</strong> with <strong>accessMode</strong> <strong>ReadWriteMany</strong></p> <pre><code> accessModes: - ReadWriteMany </code></pre> <p>Read more at : <a href="https://kubernetes.io/docs/concepts/storage/persistent-volumes/#access-modes" rel="nofollow noreferrer">https://kubernetes.io/docs/concepts/storage/persistent-volumes/#access-modes</a></p> <p>Example : <a href="https://medium.com/asl19-developers/create-readwritemany-persistentvolumeclaims-on-your-kubernetes-cluster-3a8db51f98e3" rel="nofollow noreferrer">https://medium.com/asl19-developers/create-readwritemany-persistentvolumeclaims-on-your-kubernetes-cluster-3a8db51f98e3</a></p> <p>You can also use <strong>Minio</strong>, <strong>GlusterFS</strong> to creeat the <strong>NFS</strong> or any managed service like <strong>GCP filestore</strong> providing <strong>NFS</strong> and attach that to POD.</p> <p>GKE example : <a href="https://medium.com/@Sushil_Kumar/readwritemany-persistent-volumes-in-google-kubernetes-engine-a0b93e203180" rel="nofollow noreferrer">https://medium.com/@Sushil_Kumar/readwritemany-persistent-volumes-in-google-kubernetes-engine-a0b93e203180</a></p>