Question
stringlengths 65
39.6k
| Answer
stringlengths 38
29.1k
|
---|---|
<p>How to resolve the error no module named pandas when one node (in Airflow's DAG) is successful in using it(pandas) and the other is not?</p>
<p>I am unable to deduce as to why I am getting an error no module named pandas.</p>
<p>I have checked via <code>pip3 freeze</code> and yes, the desired pandas version does show up.</p>
<p>I have deployed this using docker on a kubernetes cluster.</p>
| <p><a href="https://github.com/apache/incubator-airflow/blob/v1-10-stable/setup.py#L292" rel="nofollow noreferrer">Pandas is generally required</a>, and sometimes used in some hooks to return dataframes. Well, it's possible that Airflow was installed with <code>pip</code> and not <code>pip3</code> possibly being added as a Python 2 module and not a Python 3 module (though, using <code>pip</code> should have installed Pandas when one looks at the <a href="https://github.com/apache/incubator-airflow/blob/v1-10-stable/setup.py#L292" rel="nofollow noreferrer"><code>setup.py</code></a>).</p>
<p>Which Operator in your DAG is giving this error?
Do you have any PythonVirtualEnvironmentOperators or BashOperators running <code>python</code> from the command line (and thus possibly not sharing the same environment that you're checking has <code>pandas</code>)?</p>
|
<p>I tried to install ibm-eventstreams-dev v 0.1.2 into my Mac. </p>
<p>After I installed eventstreams into my Mac, there's always several pods that can't run. It includes three kafka pods: es-ibm-es-kafka-sts-0/1/2, es-ibm-es-ui-deploy-69758d9dfd-kc2zx, es-ibm-es-ui-oauth2-client-reg-pgvq6 and there also have a failed job named es-ibm-es-ui-oauth2-client-reg. </p>
<p>You can see the details in the follow images:
<a href="https://i.stack.imgur.com/Qg3MB.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Qg3MB.png" alt="enter image description here"></a></p>
<p><a href="https://i.stack.imgur.com/n3YpQ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/n3YpQ.png" alt="enter image description here"></a></p>
<p><a href="https://i.stack.imgur.com/h4ZBu.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/h4ZBu.png" alt="enter image description here"></a></p>
<p>So I have two questions about the ibm-event-stream:</p>
<ul>
<li><p>Does ibm-eventstreams-dev only supported on ICP? Can I install it on my local environment without ICP environment?</p></li>
<li><p>How could I solve the ui pods problem in the ibm-eventstreams-dev? </p></li>
<li><p>what's wrong with the kafka pods? what's the status message "CrashLoopBackOff" means?</p></li>
</ul>
<p>My environment details:</p>
<ul>
<li>kubernetes 1.11.1</li>
<li>helm : stable 2.10.0</li>
<li>a cluster have three nodes, each nodes is a virtual macine.</li>
</ul>
<p>Please help me, Thanks a lot!</p>
| <blockquote>
<p>So I have two questions about the ibm-event-stream:<br>
Does ibm-eventstreams-dev only supported on ICP? Can I install it on my local environment without ICP environment?</p>
</blockquote>
<p>Event Streams will only run on IBM Cloud Private (ICP). That's because ICP provides more than just a Kubernetes environment. For example, authentication and user management for Event Streams is provided by the ICP platform. </p>
<p>That's what the es-ibm-es-ui-oauth2-client-reg job that is failing for you is trying to do - set up the OAuth integration with ICP. And that'll be why it failed for you in Kubernetes on your Mac - because some of the dependencies that Event Streams has will be missing. </p>
<blockquote>
<p>How could I solve the ui pods problem in the ibm-eventstreams-dev? </p>
</blockquote>
<p>I'm afraid you won't be able to fix this in just K8S on your Mac - all of the problems that you describe are a result of bits of ICP that Event Streams depends on being missing.</p>
<p>You can get a Community Edition of ICP (at no charge) from <a href="https://www.ibm.com/account/reg/us-en/signup?formid=urx-20295" rel="nofollow noreferrer">https://www.ibm.com/account/reg/us-en/signup?formid=urx-20295</a> - which would let you give it a try. </p>
|
<p>I hope it's ok to ask for your advice.</p>
<p>The problem in a nutshell: my pipeline cannot pull private images from GHCR.IO into Okteto Kubernetes, but public images from the same private repo work.</p>
<p>I'm on Windows 10 and use WSL2-Ubuntu 20.04 LTS with kinD for development and tried minikube too.</p>
<p>I get an error in Okteto which says that the image pull is “unauthorized” -> “imagePullBackOff”.</p>
<p>Things I did:browsed Stack Overflow, RTFM, Okteto FAQ, download the Okteto kubeconfig, pulled my hair out and spent more hours than I would like to admit – still no success yet.</p>
<p>For whatever reason I cannot create a “kubectl secret” that works. When logged-in to ghcr.io via “docker login --username” I can pull private images locally.</p>
<p>No matter what I’ve tried I still get the error “unauthorized” when trying to pull a private image in Okteto.</p>
<p>My Setup with latest updates:</p>
<ul>
<li>Windows 10 Pro</li>
<li>JetBrains Rider IDE</li>
<li>WSL2-Ubuntu 20.04 LTS</li>
<li>ASP.NET Core MVC app</li>
<li>.NET 6 SDK</li>
<li>Docker</li>
<li>kinD</li>
<li>minikube</li>
<li>Chocolatey</li>
<li>Homebrew</li>
</ul>
<p>Setup kinD</p>
<pre><code>kind create cluster --name my-name
kubectl create my-namespace
// create a secret to pull images from ghcr.io
kubectl create secret docker-registry my-secret -n my-namespace --docker-username="my-username" --docker-password="my-password" --docker-email="my-email" --docker-server="https://ghcr.io"
// patch local service account
kubectl patch serviceaccount default -p '{"imagePullSecrets": [{"name": "my-secret"}]}'
</code></pre>
<p>kubernetes.yaml</p>
<pre><code>apiVersion: apps/v1
kind: Deployment
metadata:
name: okteto-repo
namespace: my-namespace
spec:
replicas: 1
selector:
matchLabels:
app: okteto-repo
template:
metadata:
labels:
app: okteto-repo
spec:
containers:
- name: okteto-repo
image: ghcr.io/user/okteto-repo:latest
ports:
- containerPort: 80
imagePullSecrets:
- name: my-secret
---
apiVersion: v1
kind: Service
metadata:
name: okteto-repo
annotations:
dev.okteto.com/auto-ingress: "true"
spec:
type: ClusterIP
selector:
app: okteto-repo
ports:
- protocol: TCP
port: 8080
targetPort: 80
</code></pre>
<p>Do you have an idea why it doesn't work and what I could do?</p>
<p>Thanks a lot my dear friends, every input is highly appreciated!</p>
<p>Hope you guys have great holidays.</p>
<p>Cheers,
Michael</p>
| <p>I was able to pull a private image by doing the following:</p>
<ol>
<li>Create a personal token in GitHub with <code>repo</code> access.</li>
<li>Build and push the image to GitHub's Container registry (I used <code>okteto build -t ghcr.io/rberrelleza/go-getting-started:0.0.1</code>)</li>
<li>Download my <a href="https://okteto.com/docs/reference/cli/#update-kubeconfig" rel="noreferrer">kubeconfig credentials</a> from Okteto Cloud by running <code>okteto context update-kubeconfig</code>.</li>
<li>Create a secret with my credentials: <code>kubectl create secret docker-registry gh-regcred --docker-server=ghcr.io --docker-username=rberrelleza --docker-password=ghp_XXXXXX</code></li>
<li>Patched the default account to include the secret as an image pull secret: <code>kubectl patch serviceaccount default -p '{"imagePullSecrets": [{"name": "gh-regcred"}]}'</code></li>
<li>Updated the image name in the kubernetes manifest</li>
<li>Created the deployment (<code>kubectl apply -f k8s.yaml</code>)</li>
</ol>
<p>These is what my kubernetes resources looks like, in case it helps:</p>
<pre><code># k8s.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: hello-world
spec:
replicas: 1
selector:
matchLabels:
app: hello-world
template:
metadata:
labels:
app: hello-world
spec:
containers:
- image: ghcr.io/rberrelleza/go-getting-started:0.0.1
name: hello-world
---
apiVersion: v1
kind: Service
metadata:
name: hello-world
annotations:
dev.okteto.com/auto-ingress: "true"
spec:
type: ClusterIP
ports:
- name: "hello-world"
port: 8080
selector:
app: hello-world
</code></pre>
<pre><code># default SA
apiVersion: v1
imagePullSecrets:
- name: gh-regcred
- name: okteto-regcred
kind: ServiceAccount
metadata:
creationTimestamp: "2021-05-21T22:26:38Z"
name: default
namespace: rberrelleza
resourceVersion: "405042662"
uid: 2b6a6eef-2ce7-40d3-841a-c0a5497279f7
secrets:
- name: default-token-7tm42
</code></pre>
|
<p>I've been using the kubectl to upload Airflow workflows to the kubernetes (/usr/local/airflow/dags) manually. It is possible to do this without using the kubectl? by using a python script? or something else? If it's possible would you be able to share your source? or your python script? Thanks, Appreciate</p>
| <p>This totally depends on your setup. E.G. We use AWS and so we have the DAGs syncing from an S3 bucket path every 5 minutes. We just put dags into S3. I see that some Kubernetes setups use a kind of shared volume defined by a git repository, that might also work. Airflow itself (the webserver(s), worker(s), nor scheduler) does not offer any hook to upload into the DAG directory.</p>
|
<p>I'm trying to deploy okteto environment on Visual Studio Code to use Remote Development on Kubernetes.</p>
<p>Following the official steps (<a href="https://okteto.com/blog/remote-kubernetes-development/" rel="nofollow noreferrer">https://okteto.com/blog/remote-kubernetes-development/</a>), I executed "Okteto: up" and selected manifest(vscode-remote-go/okteto.yml), but got this error:</p>
<pre><code>Installing dependencies...
x couldn't download syncthing, please try again
</code></pre>
<p>By changing the log level, I also got these logs:</p>
<pre><code>C:\Users\user\AppData\Local\Programs\okteto.exe up -f 'c:\Workspace\...my_project...\vscode-remote-go\okteto.yml' --remote '22100' --loglevel=debug
time="2021-09-13T14:09:32+09:00" level=info msg="starting up command"
time="2021-09-13T14:09:32+09:00" level=info msg="failed to get latest version from github: fail to get releases from github: Get \"https://api.github.com/repos/okteto/okteto/releases?per_page=5\": dial tcp: lookup api.github.com: no such host"
Installing dependencies...
time="2021-09-13T14:09:32+09:00" level=info msg="installing syncthing for windows/amd64"
time="2021-09-13T14:09:32+09:00" level=info msg="failed to download syncthing, retrying: failed to download syncthing from https://github.com/syncthing/syncthing/releases/download/v1.10.0/syncthing-windows-amd64-v1.10.0.zip: Get \"https://github.com/syncthing/syncthing/releases/download/v1.10.0/syncthing-windows-amd64-v1.10.0.zip\": dial tcp: lookup github.com: no such host"
time="2021-09-13T14:09:33+09:00" level=info msg="installing syncthing for windows/amd64"
time="2021-09-13T14:09:33+09:00" level=info msg="failed to download syncthing, retrying: failed to download syncthing from https://github.com/syncthing/syncthing/releases/download/v1.10.0/syncthing-windows-amd64-v1.10.0.zip: Get \"https://github.com/syncthing/syncthing/releases/download/v1.10.0/syncthing-windows-amd64-v1.10.0.zip\": dial tcp: lookup github.com: no such host"
time="2021-09-13T14:09:34+09:00" level=info msg="installing syncthing for windows/amd64"
time="2021-09-13T14:09:34+09:00" level=info msg="failed to upgrade syncthing: failed to download syncthing from https://github.com/syncthing/syncthing/releases/download/v1.10.0/syncthing-windows-amd64-v1.10.0.zip: Get \"https://github.com/syncthing/syncthing/releases/download/v1.10.0/syncthing-windows-amd64-v1.10.0.zip\": dial tcp: lookup github.com: no such host"
time="2021-09-13T14:09:34+09:00" level=info msg="couldn't download syncthing, please try again"
x couldn't download syncthing, please try again
</code></pre>
<p>This environment is behind my corporate proxy, and okteto.exe may not use Windows proxy setting. When I directly enter the URL (<a href="https://github.com/syncthing/syncthing/releases/download/v1.10.0/syncthing-windows-amd64-v1.10.0.zip" rel="nofollow noreferrer">https://github.com/syncthing/syncthing/releases/download/v1.10.0/syncthing-windows-amd64-v1.10.0.zip</a>) it can be downloaded using proxy.</p>
<p>Is it possible to use okteto behind proxy?</p>
| <p>Using a proxy is not currently supported in the Okteto. We're looking into it though.</p>
<p>For now, a workaround is to manually download the syncthing binary and save it as<code>%HOME%\.okteto\syncthing.exe</code></p>
|
<p>Is there currently a way to serve websockets from an application deployed on Okteto cloud given the okteto-specific limitations around <code>Ingress</code>es and <code>Service</code>s ?</p>
<hr>
<p>I've read that this would only be possible using a <code>Service</code> or <code>Ingress</code> of type <code>LoadBalancer</code>, so that is what I've tried.</p>
<p>But, according to the <a href="https://okteto.com/docs/cloud/build" rel="nofollow noreferrer">Okteto docs</a>, <code>Service</code>s of type <code>LoadBalancer</code> (or <code>NodePort</code>) are managed. In practice they seem to get transformed automatically into a <code>ClusterIP Service</code>, + exposed to the internet on an automatic URL.</p>
<p>Do these handle only <code>HTTP</code> requests ? Or is there a way to make them handle other kinds of connections based on TCP or UDP (like websockets) ?</p>
| <p>You don't need a LoadBalancer to use WebSockets, they can be served from an Ingress with a ClusterIP as well (this is what Okteto Cloud uses for our endpoints). This setup supports HTTPS, WebSockets and even GRPC-based endpoints.</p>
<p><a href="https://github.com/okteto/node-websocket" rel="nofollow noreferrer">This sample</a> shows you how to use WebSockets on a Node app deployed in Okteto Cloud, hope it helps! (it uses okteto-generated Kubernetes manifests, but you can also bring your own).</p>
|
<p>I was working on Jenkins for many days and deploy my services to Kubernetes.</p>
<p>I recently came across Jenkins X, I also found a Helm chart for Jenkins through which I can host Jenkins in Kubernetes. Now I'm confused if they both are same?</p>
| <p>No they are different. I assume the helm chart you found installs and configure Jenkins on Kubernetes - perhaps configured with some agents to run builds. </p>
<p>Jenkins X is a kubernetes native implementation of CI/CD, it uses some components of Jenkins, but has a lot more to it (for example, applications, environments, review apps, deployments and so on) for running apps ON kubernetes in a CI/CD fashion. The Jenkins helm chart likely sets up a single server. </p>
<p>edit: in the time since, Jenkins X has evolved a lot. It is now build using he Tekton engine for pipeline by default, and has many moving parts, so is quite different from running a more classic like Jenkins master/agent setup in a Kubernetes cluster. </p>
|
<p>Recently, I tried to setup Jenkins X on a kubernetes cluster. However there exists some problem during installation. </p>
<p>There are several options in <code>jx create cluster</code> such as aks(create with AKS), aws(create with AWS), minikube(create with Minikube) and etc.</p>
<p>However there is no option which create a cluster with local kubernetes cluster. I want to setup Jenkins X with my own cluster. </p>
<p>Can I get some advice?</p>
<p>Thanks.</p>
| <p>when you have your cluster setup such that you can run <code>kubectl</code> commands against it, you can run <code>jx boot</code> to setup your jx installation. You don't need to use <code>jx create cluster</code> as your cluster already exists. </p>
|
<p>I'm creating a custom resource definition (CRD) with an associated controller using <a href="https://github.com/kubernetes-sigs/kubebuilder" rel="nofollow noreferrer">kubebuilder</a>. My controller reconcile loop creates a deployment sub-resource and parents it to the custom resource using <code> controllerutil.SetControllerReference(&myResource, deployment, r.Scheme)</code>. I've also configured my reconciler so "own" the sub-resource, as follows:</p>
<pre class="lang-golang prettyprint-override"><code>// SetupWithManager sets up the controller with the Manager.
func (r *MyResourceReconciler) SetupWithManager(mgr ctrl.Manager) error {
return ctrl.NewControllerManagedBy(mgr).
For(&mygroupv1alpha1.MyResource{}).
Owns(&appsv1.Deployment{}).
Complete(r)
}
</code></pre>
<p>However, when I run my controller locally using <code>make run</code>, I noticed that deleting the my CR (the root object) doesn't cause the Deployment sub-resource to get garbage collected. I also noticed that deleting the Deployment sub-resource doesn't trigger my reconciler to run. Why is this? Is there something I'm not doing or is this possibly a limitation of local development/testing?</p>
| <p>Using @coderanger's hint, I could see that the <code>metadata.ownerReferences</code> weren't being set correctly when running the following command:</p>
<pre class="lang-sh prettyprint-override"><code>kubectl get deployments sample-deployment -o yaml
</code></pre>
<p>The problem was my controller's reconcile code. I was calling <code>controllerutil.SetControllerReference(&myResource, deployment, r.Scheme)</code> only after I'd already created and persisted the Deployment.</p>
<p><strong>Buggy code</strong></p>
<pre class="lang-golang prettyprint-override"><code>log.Info("Creating a deployment")
deployment := &appsv1.Deployment{
ObjectMeta: metav1.ObjectMeta{
Name: deploymentName,
Namespace: myResource.Namespace,
},
Spec: deploymentSpec,
}
if err = r.Create(ctx, deployment); err != nil {
log.Error(err, "Failed to create deployment")
if errors.IsInvalid(err) {
// Don't retry on validation errors
err = nil
}
return ctrl.Result{}, err
}
// Establish the parent-child relationship between my resource and the deployment
log.Info("Making my resource a parent of the deployment")
if err = controllerutil.SetControllerReference(&myResource, deployment, r.Scheme); err != nil {
log.Error(err, "Failed to set deployment controller reference")
return ctrl.Result{}, err
}
</code></pre>
<p>To fix it, I needed to swap the order of the call to <code>r.Create</code> and <code>controllerutil.SetControllerReference</code>:</p>
<p><strong>Working code</strong></p>
<pre class="lang-golang prettyprint-override"><code>log.Info("Creating a deployment")
deployment := &appsv1.Deployment{
ObjectMeta: metav1.ObjectMeta{
Name: deploymentName,
Namespace: myResource.Namespace,
},
Spec: deploymentSpec,
}
// Establish the parent-child relationship between my resource and the deployment
log.Info("Making my resource a parent of the deployment")
if err = controllerutil.SetControllerReference(&myResource, deployment, r.Scheme); err != nil {
log.Error(err, "Failed to set deployment controller reference")
return ctrl.Result{}, err
}
// Create the deployment with the parent/child relationship configured
if err = r.Create(ctx, deployment); err != nil {
log.Error(err, "Failed to create deployment")
if errors.IsInvalid(err) {
// Don't retry on validation errors
err = nil
}
return ctrl.Result{}, err
}
</code></pre>
<p>I was able to confirm that this worked by looking at the <code>metadata.ownerReferences</code> YAML data for my created deployment (using the command referenced above).</p>
<pre class="lang-yaml prettyprint-override"><code>apiVersion: apps/v1
kind: Deployment
metadata:
annotations:
deployment.kubernetes.io/revision: "1"
creationTimestamp: "2021-08-02T16:22:04Z"
generation: 1
name: sample-deployment
namespace: default
ownerReferences:
- apiVersion: resources.mydomain.io/v1alpha1
blockOwnerDeletion: true
controller: true
kind: MyResource
name: myresource-sample
uid: 6ebb146c-afc7-4601-bd75-58efc29beac9
resourceVersion: "569913"
uid: d9a4496f-7418-4831-ab87-4804dcd1f8aa
</code></pre>
|
<p>I have deployed Azure Durable Http Triggered Function app in Azure Kubernetes Service. I used Visual Studio Code to create the function app. I have followed instructions from this this <a href="https://dev.to/anirudhgarg_99/scale-up-and-down-a-http-triggered-function-app-in-kubernetes-using-keda-4m42" rel="nofollow noreferrer">article</a> and <a href="https://learn.microsoft.com/en-us/azure/azure-functions/functions-kubernetes-keda#deploying-a-function-app-to-kubernetes" rel="nofollow noreferrer">Microsoft official documentation</a>.</p>
<pre><code>Function runtime: 3.0.2630
Python version: 3.7.7
azure-functions: 1.3.1
azure-functions-durable: 1.0.0b9
</code></pre>
<p>Here is my HttStart <code>function.json</code> file looks like,</p>
<pre><code>{
"scriptFile": "__init__.py",
"bindings": [
{
"authLevel": "anonymous",
"name": "req",
"type": "httpTrigger",
"direction": "in",
"route": "orchestrators/{functionName}",
"methods": [
"post",
"get"
]
},
{
"name": "$return",
"type": "http",
"direction": "out"
},
{
"name": "starter",
"type": "orchestrationClient",
"direction": "in"
}
]
}
</code></pre>
<p>Docker file:</p>
<pre><code>FROM mcr.microsoft.com/azure-functions/python:3.0-python3.7
ENV AzureWebJobsScriptRoot=/home/site/wwwroot \
AzureFunctionsJobHost__Logging__Console__IsEnabled=true
COPY requirements.txt /
RUN pip install -r /requirements.txt
COPY . /home/site/wwwroot
</code></pre>
<p>This application works perfectly in my local environment. After deploying to AKS cluster, when I call URL, it throws the following expection</p>
<pre><code>fail: Function.HelloWorldHttpStart[3]
Executed 'Functions.HelloWorldHttpStart' (Failed, Id=e7dd35a1-2001-4f11-396f-d251cbd87a0d, Duration=82ms)
Microsoft.Azure.WebJobs.Host.FunctionInvocationException: Exception while executing function: Functions.HelloWorldHttpStart
---> System.InvalidOperationException: Webhooks are not configured
at Microsoft.Azure.WebJobs.Extensions.DurableTask.HttpApiHandler.ThrowIfWebhooksNotConfigured() in d:\a\r1\a\azure-functions-durable-extension\src\WebJobs.Extensions.DurableTask\HttpApiHandler.cs:line 737
</code></pre>
<p>Is there any configuration I missed out? Any suggestions would be appreciated.</p>
<p>Thank you.</p>
| <p>Try adding a <code>WEBSITE_HOSTNAME</code> environment variable with <code><ip-address>:<port></code> as the value, where <code><ip-address>:<port></code> refers to the address that can be used to reach your function app from outside.</p>
<p>This error happens when you use an API that depends on this environment variable. When running using the local core tools, this value is set to <code>localhost:7071</code> automatically. When running in the Azure Functions hosted service, this environment variable is also pre-configured to be the DNS name of the function app (e.g. <code>myfunctionapp.azurewebsites.net</code>. For other environments, like AKS, you'll need to add this environment variable explicitly and set it to the correct value for your deployment.</p>
|
<p>Stateless is the way to go for services running in pods however i have been trying to move a stateful app which needs to perform session persistence if one pod goes does for resiliency reasons.</p>
<p>In websphere world IHS can be used to keep track of the session and if a node goes down it can be recreated on the live clone. </p>
<p>Is there an industry standard way to handle this issue without having to refactor the applications code by persisting the session using some sidecar pod ?</p>
| <p>Yes. Store the session somewhere. Spring boot supports out of the box MongoDB, Redis, Hazelcast or any JDBC database.</p>
<blockquote>
<p>Spring Boot provides Spring Session auto-configuration for a wide
range of data stores. When building a Servlet web application, the
following stores can be auto-configured:</p>
<p>JDBC Redis Hazelcast MongoDB When building a reactive web application,
the following stores can be auto-configured:</p>
<p>Redis MongoDB If a single Spring Session module is present on the
classpath, Spring Boot uses that store implementation automatically.
If you have more than one implementation, you must choose the
StoreType that you wish to use to store the sessions. For instance, to
use JDBC as the back-end store, you can configure your application as
follows:</p>
<p>spring.session.store-type=jdbc </p>
<p>[Tip] You can disable Spring Session by
setting the store-type to none. Each store has specific additional
settings. For instance, it is possible to customize the name of the
table for the JDBC store, as shown in the following example:</p>
<p>spring.session.jdbc.table-name=SESSIONS </p>
<p>For setting the timeout of the
session you can use the spring.session.timeout property. If that
property is not set, the auto-configuration falls back to the value of
server.servlet.session.timeout.</p>
</blockquote>
|
<p>I'm trying to create a simple nginx service on GKE, but I'm running into strange problems. </p>
<p>Nginx runs on port 80 inside the Pod. The service is accessible on port 8080. (This works, I can do <code>curl myservice:8080</code> inside of the pod and see the nginx home screen)</p>
<p>But when I try to make it publicly accessible using an ingress, I'm running into trouble. Here are my deployment, service and ingress files.</p>
<pre><code>apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx-deployment
labels:
app: nginx
spec:
replicas: 3
selector:
matchLabels:
app: nginx
template:
metadata:
labels:
app: nginx
spec:
containers:
- name: nginx
image: nginx:1.7.9
ports:
- containerPort: 80
kind: Service
apiVersion: v1
metadata:
name: my-service
spec:
selector:
app: nginx
ports:
- protocol: TCP
port: 8080
nodePort: 32111
targetPort: 80
type: NodePort
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: test-ingress
spec:
rules:
- http:
paths:
# The * is needed so that all traffic gets redirected to nginx
- path: /*
backend:
serviceName: my-service
servicePort: 80
</code></pre>
<p>After a while, this is what my ingress status looks like:</p>
<pre><code>$ k describe ingress test-ingress
Name: test-ingress
Namespace: default
Address: 35.186.255.184
Default backend: default-http-backend:80 (10.44.1.3:8080)
Rules:
Host Path Backends
---- ---- --------
*
/* my-service:32111 (<none>)
Annotations:
backends: {"k8s-be-30030--ecc76c47732c7f90":"HEALTHY"}
forwarding-rule: k8s-fw-default-test-ingress--ecc76c47732c7f90
target-proxy: k8s-tp-default-test-ingress--ecc76c47732c7f90
url-map: k8s-um-default-test-ingress--ecc76c47732c7f90
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Normal ADD 18m loadbalancer-controller default/test-ingress
Normal CREATE 17m loadbalancer-controller ip: 35.186.255.184
Warning Service 1m (x5 over 17m) loadbalancer-controller Could not find nodeport for backend {ServiceName:my-service ServicePort:{Type:0 IntVal:32111 StrVal:}}: could not find matching nodeport from service
Normal Service 1m (x5 over 17m) loadbalancer-controller no user specified default backend, using system default
</code></pre>
<p>I don't understand why it's saying that it can't find nodeport - the service has nodePort defined and it is of type NodePort as well. Going to the actual IP results in <code>default backend - 404</code>. </p>
<p>Any ideas why?</p>
| <p>The configuration is missing a health check endpoint, for the GKE loadbalancer to know whether the backend is healthy. The <code>containers</code> section for the <code>nginx</code> should also specify:</p>
<pre><code> livenessProbe:
httpGet:
path: /
port: 80
</code></pre>
<p>The <code>GET /</code> on port 80 is the default configuration, and can be changed.</p>
|
<p>I would like to expose my Kubernetes Managed Digital Ocean (single node) cluster's service on port 80 without the use of Digital Ocean's load balancer. Is this possible? How would I do this? </p>
<p>This is essentially a hobby project (I am beginning with Kubernetes) and just want to keep the cost very low. </p>
| <p>You can deploy an Ingress configured to use the host network and port 80/443.</p>
<ol>
<li><p>DO's firewall for your cluster doesn't have 80/443 inbound open by default.</p>
<p>If you edit the auto-created firewall the rules <a href="https://www.digitalocean.com/community/questions/how-to-customize-firewall-rules-for-managed-kubernetes-service" rel="noreferrer">will eventually reset themselves</a>. The solution is to create a separate firewall also pointing at the same Kubernetes worker nodes:</p>
</li>
</ol>
<pre><code>$ doctl compute firewall create \
--inbound-rules="protocol:tcp,ports:80,address:0.0.0.0/0,address:::/0 protocol:tcp,ports:443,address:0.0.0.0/0,address:::/0" \
--tag-names=k8s:CLUSTER_UUID \
--name=k8s-extra-mycluster
</code></pre>
<p>(Get the <code>CLUSTER_UUID</code> value from the dashboard or the ID column from <code>doctl kubernetes cluster list</code>)</p>
<ol start="2">
<li>Create the <a href="https://kubernetes.github.io/ingress-nginx/" rel="noreferrer">nginx ingress</a> using the host network. I've included the <a href="https://github.com/helm/charts/tree/master/stable/nginx-ingress" rel="noreferrer">helm chart</a> config below, but you could do it via the direct install process too.</li>
</ol>
<p>EDIT: The Helm chart in the above link has been DEPRECATED, Therefore the correct way of installing the chart would be(<a href="https://github.com/kubernetes/ingress-nginx/tree/master/charts/ingress-nginx" rel="noreferrer">as per the new docs</a>) is :</p>
<pre><code>helm repo add ingress-nginx https://kubernetes.github.io/ingress-nginx
helm repo update
</code></pre>
<p>After this repo is added & updated</p>
<pre><code># For Helm 2
$ helm install stable/nginx-ingress --name=myingress -f myingress.values.yml
# For Helm 3
$ helm install myingress stable/nginx-ingress -f myingress.values.yml
#EDIT: The New way to install in helm 3
helm install myingress ingress-nginx/ingress-nginx -f myingress.values.yaml
</code></pre>
<p><code>myingress.values.yml</code> for the chart:</p>
<pre class="lang-yaml prettyprint-override"><code>---
controller:
kind: DaemonSet
hostNetwork: true
dnsPolicy: ClusterFirstWithHostNet
daemonset:
useHostPort: true
service:
type: ClusterIP
rbac:
create: true
</code></pre>
<ol start="3">
<li><p>you should be able to access the cluster on :80 and :443 via any worker node IP and it'll route traffic to your ingress.</p>
</li>
<li><p>since node IPs can & do change, look at deploying <a href="https://github.com/kubernetes-incubator/external-dns" rel="noreferrer">external-dns</a> to manage DNS entries to point to your worker nodes. Again, using the helm chart and assuming your DNS domain is hosted by DigitalOcean (though any supported DNS provider will work):</p>
</li>
</ol>
<pre><code># For Helm 2
$ helm install --name=mydns -f mydns.values.yml stable/external-dns
# For Helm 3
$ helm install mydns stable/external-dns -f mydns.values.yml
</code></pre>
<p><code>mydns.values.yml</code> for the chart:</p>
<pre class="lang-yaml prettyprint-override"><code>---
provider: digitalocean
digitalocean:
# create the API token at https://cloud.digitalocean.com/account/api/tokens
# needs read + write
apiToken: "DIGITALOCEAN_API_TOKEN"
domainFilters:
# domains you want external-dns to be able to edit
- example.com
rbac:
create: true
</code></pre>
<ol start="5">
<li>create a Kubernetes <a href="https://kubernetes.github.io/ingress-nginx/user-guide/basic-usage/" rel="noreferrer">Ingress resource</a> to route requests to an existing Kubernetes service:</li>
</ol>
<pre class="lang-yaml prettyprint-override"><code>---
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: testing123-ingress
annotations:
kubernetes.io/ingress.class: nginx
spec:
rules:
- host: testing123.example.com # the domain you want associated
http:
paths:
- path: /
backend:
serviceName: testing123-service # existing service
servicePort: 8000 # existing service port
</code></pre>
<ol start="6">
<li>after a minute or so you should see the DNS records appear and be resolvable:</li>
</ol>
<pre><code>$ dig testing123.example.com # should return worker IP address
$ curl -v http://testing123.example.com # should send the request through the Ingress to your backend service
</code></pre>
<p>(Edit: editing the automatically created firewall rules eventually breaks, add a separate firewall instead).</p>
|
<p>The data needs to be loaded periodically (like once in a day), and it should be stored in SQL format so that the API can run SQL queries.
We are thinking of loading it from HDFS. Currently we are thinking of using Apache Nifi using PutIgniteCache. </p>
<p>I was thinking probably I can launch a remote Ignite client node and then use IgniteDataStreamer to stream the data, but I was not able to find proper documentation for that. Are there any better ways to do this?</p>
| <p>The documentation for Nifi says that <a href="https://nifi.apache.org/docs/nifi-docs/components/org.apache.nifi/nifi-ignite-nar/1.9.0/org.apache.nifi.processors.ignite.cache.PutIgniteCache/index.html" rel="nofollow noreferrer">it uses the data streamer API</a>, so unless you need more control it doesn’t seem like a bad option (with the caveat that I’d never heard of Nifi before much less used it!).</p>
|
<p>Trying Ignite with Kubertenes deployment options. </p>
<ol>
<li>Is it zone-aware? Cannot find any docs & configuration about this.</li>
<li>Can I connect the Kubernetes cluster via an external client? I'd like to connect via <a href="https://apacheignite-net.readme.io" rel="nofollow noreferrer">C# client</a>.</li>
</ol>
<p>Thank you!</p>
| <ol>
<li>Broadly speaking, Ignite assumes all your nodes are close to one another. You could make it aware of multiple zones by using custom affinity functions, but it's not straight-forward. There are also third-party solutions (I work for GridGain who provide one) that support data centre replication, etc. that would work in this situation</li>
<li>Yes. I would suggest that thick clients should be part of your Kubernetes infrastructure (since they become part of the Ignite cluster topology), but you can connect a thin client just by opening the right ports. You can use Kubernetes load balancing / round robin to connect to any node</li>
</ol>
|
<p>I am trying to extract podname using the below jq query.</p>
<pre class="lang-sh prettyprint-override"><code>❯ kubectl get pods -l app=mssql-primary --output jsonpath='{.items[0].metadata.name}'
mssqlag-primary-deployment-77b8974bb9-dbltl%
❯ kubectl get pods -l app=mssql-primary -o json | jq -r '.items[0].metadata.name'
mssqlag-primary-deployment-77b8974bb9-dbltl
</code></pre>
<p>While they both provide the same out put the first one has a % character at the end of the pod name. Any reason why ? Is there something wrong with the jsonpath representation in the first command ?</p>
| <p>I'm guessing <code>zsh</code> is your shell. The <code>%</code> is an indicator output by your shell to say that the last line output by <code>kubectl</code> had no newline character at the end. So it's not <em>extra</em> output, it's actually an indicator that the raw <code>kubectl</code> command outputs <em>less</em> than <code>jq</code>.</p>
<p>You could explicitly add a newline to the jsonpath output if you want it:</p>
<pre><code>kubectl get pods -l app=mssql-primary --output jsonpath='{.items[0].metadata.name}{"\n"}'
</code></pre>
<p>Or in the other direction you could tell <code>jq</code> not to add newlines at all by specifying <code>-j</code> instead of <code>-r</code>:</p>
<pre><code>kubectl get pods -l app=mssql-primary -o json | jq -j '.items[0].metadata.name'
</code></pre>
|
<p>We are trying to use control.sh to activate out Ignite cluster which is running in Kubernetes and has native persistence as described <a href="https://ignite.apache.org/docs/latest/tools/control-script" rel="nofollow noreferrer">here</a>, however we are getting to error below.</p>
<p>We have also tried activating the cluster via the post install of the auto deployment but are getting the same error.</p>
<pre><code>lifecycle:
postStart:
exec:
command:
- >-
/opt/ignite/apache-ignite/bin/control.sh --set-state ACTIVE
--yes
</code></pre>
<p>Error:</p>
<pre><code>/opt/ignite/apache-ignite/bin/control.sh --set-state ACTIVE
failed - error: command '/bin/sh -c /opt/ignite/apache-ignite/bin/control.sh --set-state ACTIVE' exited with 2: , message: "JVM_OPTS environment variable is set, but will not be used. To pass JVM options use CONTROL_JVM_OPTS
JVM_OPTS=-DIGNITE_WAL_MMAP=false -DIGNITE_UPDATE_NOTIFIER=false -XX:+UseG1GC -Xmx4g -XX:+DisableExplicitGC -server -Xms4g -XX:+AlwaysPreTouch -XX:+ScavengeBeforeFullGC
Control utility [ver. 2.11.1#20211220-sha1:eae1147d]2021 Copyright(C) Apache Software Foundation
User: root
Time: 2022-05-31T18:56:38.690
Connection to cluster failed. Latest topology update failed.
Command [SET-STATE] finished with code: 2
Control utility has completed execution at: 2022-05-31T18:56:41.859
Execution time: 3169 ms
</code></pre>
| <p>Activating the cluster relates to the lifecycle of the <em>cluster</em> rather than an individual pod, do you don't want to add it to the pod.</p>
<p>Instead, it's a "manual" process once all your nodes/pods are up. <a href="https://medium.com/@sdarlington/activating-an-apache-ignite-cluster-on-kubernetes-afbed40c7e53" rel="nofollow noreferrer">I wrote about it here</a>.</p>
<p>In short, either run exec:</p>
<pre><code>kubectl exec -it ignite-0 --namespace=ignite -- /opt/ignite/apache-ignite-fabric/bin/control.sh --activate
</code></pre>
<p>Or create a Kubernetes job.</p>
|
<p>Are there any know issues with running the org.apache.ignite.spi.discovery.tcp.ipfinder.kubernetes.TcpDiscoveryKubernetesIpFinder a purely IPv6 environment? I looked <a href="https://ignite.apache.org/docs/latest/clustering/network-configuration" rel="nofollow noreferrer">here</a> and it mentions there may be issues with clusters becoming detached but does not offer any specifics. Any information would be appreciated, thanks.</p>
| <p>I'm not aware of any IPv6 problems <em>per se</em>, so if your network is configured correctly I would expect it to work.</p>
<p>The problem we typically see when IPv6 is enabled is that it's possible to route to the IPv4 address but <em>not</em> the IPv6 address -- which is why setting preferIPv4Stack works.</p>
|
<p>We have observed following issue when we deploy Ignite Cluster on Open Shift</p>
<p>We have created respective PV and PVC YAML files.</p>
<p>One more important point is always it points to /ignite/work irrespective of Mount Path.</p>
<p>Error details at POD:
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See <a href="http://www.slf4j.org/codes.html#StaticLoggerBinder" rel="nofollow noreferrer">http://www.slf4j.org/codes.html#StaticLoggerBinder</a> for further details.
class org.apache.ignite.IgniteException: Work directory does not exist and cannot be created: /ignite/work
at org.apache.ignite.internal.util.IgniteUtils.convertException(IgniteUtils.java:1135)
at org.apache.ignite.Ignition.start(Ignition.java:356)
at org.apache.ignite.startup.cmdline.CommandLineStartup.main(CommandLineStartup.java:365)
Caused by: class org.apache.ignite.IgniteCheckedException: Work directory does not exist and cannot be created: /ignite/work
at org.apache.ignite.internal.util.IgniteUtils.workDirectory(IgniteUtils.java:9900)
at org.apache.ignite.internal.IgnitionEx$IgniteNamedInstance.initializeConfiguration(IgnitionEx.java:1891)
at org.apache.ignite.internal.IgnitionEx$IgniteNamedInstance.start(IgnitionEx.java:1715)
at org.apache.ignite.internal.IgnitionEx.start0(IgnitionEx.java:1160)
at org.apache.ignite.internal.IgnitionEx.startConfigurations(IgnitionEx.java:1054)
at org.apache.ignite.internal.IgnitionEx.start(IgnitionEx.java:940)
at org.apache.ignite.internal.IgnitionEx.start(IgnitionEx.java:839)
at org.apache.ignite.internal.IgnitionEx.start(IgnitionEx.java:709)
at org.apache.ignite.internal.IgnitionEx.start(IgnitionEx.java:678)
at org.apache.ignite.Ignition.start(Ignition.java:353)
... 1 more
Failed to start grid: Work directory does not exist and cannot be created: /ignite/work</p>
<hr />
<p>YAML Content</p>
<hr />
<p>apiVersion: v1
kind: PersistentVolume
metadata:
annotations:
field.cattle.io/creatorId: user-zqf4l
creationTimestamp: "2021-01-12T06:48:02Z"
finalizers:</p>
<ul>
<li>kubernetes.io/pv-protection
labels:
cattle.io/creator: norman
name: ignite-storage-work-vol
resourceVersion: "18595579"
selfLink: /api/v1/persistentvolumes/newsto
uid: ee81855d-6497-4465-abdd-8244883e383b
spec:
accessModes:</li>
<li>ReadWriteOnce
capacity:
storage: 1Gi
hostPath:
##when you create folder ensure you give proper permission to folder Assing Owner
##chown rootadmin:rootadmin grafana
##give full writes chmod 777 grafana/
path: /opt/work ## Change the location before deploying
type: ""
persistentVolumeReclaimPolicy: Retain
volumeMode: Filesystem</li>
</ul>
<p>.....
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: ignite-storage-work-vol-claim
spec:
volumeName: ignite-storage-work-vol
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 1Gi</p>
<p>......</p>
<h1>An example of a Kubernetes configuration for pod deployment.</h1>
<p>apiVersion: apps/v1
kind: StatefulSet
metadata:</p>
<h1>Cluster name.</h1>
<p>name: ignite-cluster
namespace: or
spec:</p>
<h1>The initial number of Ignite pods.</h1>
<p>replicas: 2
serviceName: ignite-service
selector:
matchLabels:
app: ignite
template:
metadata:
labels:
app: ignite
spec:
serviceAccountName: ignite
# terminationGracePeriodSeconds: 60000 (use in production for graceful restarts and shutdowns)
containers:
# Custom pod name.
- name: ignite-node
image: apacheignite/ignite:2.13.0
imagePullPolicy: IfNotPresent
env:
- name: OPTION_LIBS
value: ignite-kubernetes,ignite-rest-http
- name: CONFIG_URI
value: file:///ignite/config/ignite-node-cfg.xml
- name: JVM_OPTS
value: "-DIGNITE_WAL_MMAP=false"
# consider this property for production -DIGNITE_WAIT_FOR_BACKUPS_ON_SHUTDOWN=true</p>
<pre><code> ports:
# Ports you might need to open.
- containerPort: 47100 # communication SPI port
- containerPort: 47500 # discovery SPI port
- containerPort: 49112 # JMX port
- containerPort: 10800 # thin clients/JDBC driver port
- containerPort: 8080 # REST API
volumeMounts:
- mountPath: /ignite/config
name: config-vol
- name: work-vol
mountPath: /tmp/work
readOnly: false
- name: storage-vol
mountPath: /tmp/storage
readOnly: false
- name: wal-vol
mountPath: /tmp/wal
readOnly: false
- name: walarchive-vol
mountPath: /tmp/walarchive
readOnly: false
volumes:
- name: config-vol
configMap:
name: ignite-cfg-persistent
- name: work-vol
persistentVolumeClaim:
claimName: ignite-storage-work-vol-claim
- name: storage-vol
persistentVolumeClaim:
claimName: ignite-storage-storage-vol-claim
- name: wal-vol
persistentVolumeClaim:
claimName: ignite-storage-wal-vol-claim
- name: walarchive-vol
persistentVolumeClaim:
claimName: ignite-storage-walarchive-vol-claim
</code></pre>
| <p>It's expecting to be able to write to <code>/ignite/work</code> but there's no persistent volume there. You appear to be mounting them in <code>/tmp</code>. Suggest changing:</p>
<pre><code>- name: work-vol
mountPath: /tmp/work
readOnly: false
</code></pre>
<p>To:</p>
<pre><code>- name: work-vol
mountPath: /ignite/work
readOnly: false
</code></pre>
<p>And the same for the other PVs.</p>
|
<p>I am trying to run an ASP.Net docker container on Kubernetes as a non-root user. I have this dockerfile:</p>
<pre><code>FROM mcr.microsoft.com/dotnet/core/aspnet:3.1-buster-slim AS base
WORKDIR /app
EXPOSE 8443
FROM mcr.microsoft.com/dotnet/core/sdk:3.1-buster AS build
WORKDIR /src
COPY ["MyProgram.API/MyProgram.API.csproj", "MyProgram.API/"]
COPY ["MyProgram.Services/MyProgram.Services.csproj", "MyProgram.Services/"]
COPY ["MyProgram.Core/MyProgram.Core.csproj", "MyProgram.Core/"]
COPY ["MyProgram.Data/MyProgram.Data.csproj", "MyProgram.Data/"]
RUN dotnet restore "MyProgram.API/MyProgram.API.csproj"
COPY . .
WORKDIR "/src/MyProgram.API"
RUN dotnet build "MyProgram.API.csproj" -c Release -o /app/build
FROM build AS publish
RUN dotnet publish "MyProgram.API.csproj" -c Release -o /app/publish
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "MyProgram.API.dll"]
</code></pre>
<p>When I run it locally, I can go to https://localhost:8443 and use my app succesfully. When I deploy it to Kubernetes using this file:</p>
<pre><code>apiVersion: apps/v1
kind: Deployment
# snip
spec:
securityContext:
fsGroup: 2000
runAsNonRoot: true
runAsUser: 1000
containers:
- name: myprogram
image: mycompany/myprogram:develop
imagePullPolicy: "Always"
env:
- name: "ASPNETCORE_ENVIRONMENT"
value: "Kubernetes"
ports:
- containerPort: 8443
name: "myprogram"
securityContext:
allowPrivilegeEscalation: false
imagePullSecrets:
- name: privatereposecret
---
apiVersion: v1
kind: Service
#snip
spec:
type: NodePort
ports:
- protocol: TCP
port: 8081
targetPort: 8443
nodePort: 31999
selector:
app: myprogram
</code></pre>
<p>My container won't start and gives these gives these log files:</p>
<pre><code>[13:13:30 FTL] Unable to start Kestrel.
System.Net.Sockets.SocketException (13): Permission denied
at System.Net.Sockets.Socket.UpdateStatusAfterSocketErrorAndThrowException(SocketError error, String callerName)
at System.Net.Sockets.Socket.DoBind(EndPoint endPointSnapshot, SocketAddress socketAddress)
at System.Net.Sockets.Socket.Bind(EndPoint localEP)
at Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets.SocketConnectionListener.Bind()
at Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets.SocketTransportFactory.BindAsync(EndPoint endpoint, CancellationToken cancellationToken)
at Microsoft.AspNetCore.Server.Kestrel.Core.KestrelServer.<>c__DisplayClass21_0`1.<<StartAsync>g__OnBind|0>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.AddressBinder.BindEndpointAsync(ListenOptions endpoint, AddressBindContext context)
at Microsoft.AspNetCore.Server.Kestrel.Core.ListenOptions.BindAsync(AddressBindContext context)
at Microsoft.AspNetCore.Server.Kestrel.Core.AnyIPListenOptions.BindAsync(AddressBindContext context)
at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.AddressBinder.AddressesStrategy.BindAsync(AddressBindContext context)
at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.AddressBinder.BindAsync(IServerAddressesFeature addresses, KestrelServerOptions serverOptions, ILogger logger, Func`2 createBinding)
at Microsoft.AspNetCore.Server.Kestrel.Core.KestrelServer.StartAsync[TContext](IHttpApplication`1 application, CancellationToken cancellationToken)
[13:13:30 FTL] Application start-up failed
System.Net.Sockets.SocketException (13): Permission denied
at System.Net.Sockets.Socket.UpdateStatusAfterSocketErrorAndThrowException(SocketError error, String callerName)
at System.Net.Sockets.Socket.DoBind(EndPoint endPointSnapshot, SocketAddress socketAddress)
at System.Net.Sockets.Socket.Bind(EndPoint localEP)
at Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets.SocketConnectionListener.Bind()
at Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets.SocketTransportFactory.BindAsync(EndPoint endpoint, CancellationToken cancellationToken)
at Microsoft.AspNetCore.Server.Kestrel.Core.KestrelServer.<>c__DisplayClass21_0`1.<<StartAsync>g__OnBind|0>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.AddressBinder.BindEndpointAsync(ListenOptions endpoint, AddressBindContext context)
at Microsoft.AspNetCore.Server.Kestrel.Core.ListenOptions.BindAsync(AddressBindContext context)
at Microsoft.AspNetCore.Server.Kestrel.Core.AnyIPListenOptions.BindAsync(AddressBindContext context)
at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.AddressBinder.AddressesStrategy.BindAsync(AddressBindContext context)
at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.AddressBinder.BindAsync(IServerAddressesFeature addresses, KestrelServerOptions serverOptions, ILogger logger, Func`2 createBinding)
at Microsoft.AspNetCore.Server.Kestrel.Core.KestrelServer.StartAsync[TContext](IHttpApplication`1 application, CancellationToken cancellationToken)
at Microsoft.AspNetCore.Hosting.GenericWebHostService.StartAsync(CancellationToken cancellationToken)
at Microsoft.Extensions.Hosting.Internal.Host.StartAsync(CancellationToken cancellationToken)
at Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.RunAsync(IHost host, CancellationToken token)
at Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.RunAsync(IHost host, CancellationToken token)
at Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.Run(IHost host)
at MyProgram.API.Program.Main(String[] args) in /src/MyProgram.API/Program.cs:line 30
</code></pre>
<p>If I try the exact same deployment without a SecurityContext the container works perfectly. What's going wrong?</p>
| <p>Kestrel is trying to bind to port 80 and/or port 443 because that's its default unless you tell it otherwise, and you can't do that unless priviledged.</p>
<p>You need to specify the ports, usually via environment variables, and expose them, e.g.</p>
<pre><code># Declare ports above 1024, as an unprivileged non-root user cannot bind to ports <= 1024
ENV ASPNETCORE_URLS http://+:8000;https://+:8443
EXPOSE 8000
EXPOSE 8443
</code></pre>
|
<p>I have a Kubernetes setup of 7 Apache Ignite servers and over 100 clients.</p>
<p>With my current Apache Ignite configuration, I am seeing the following line of log for the servers:</p>
<pre><code>java.lang.OutOfMemoryError: Java heap space
</code></pre>
<p>Below is the memory configuration Apache Ignite server:</p>
<ul>
<li>Pod memory limit: 2Gb</li>
<li>Xmx: 768m</li>
</ul>
<p>I would like to know what should be the optimum Memory configuration for the Apache Ignite cluster</p>
| <p>It depends on what you're trying to do -- persistence and SQL tend to use more heap space for example -- but both 2Gb and 768Mb are <em>much</em> smaller than I'd expect for an in-memory database.</p>
<p>The <a href="https://www.gridgain.com/docs/latest/perf-troubleshooting-guide/memory-tuning" rel="nofollow noreferrer">tuning guide</a> suggests 10Gb as a starting point:</p>
<pre><code>-server
-Xms10g
-Xmx10g
-XX:+AlwaysPreTouch
-XX:+UseG1GC
-XX:+ScavengeBeforeFullGC
-XX:+DisableExplicitGC
</code></pre>
|
<p>I am trying to install Operator Lifecycle Manager (OLM) — a tool to help manage the Operators running on your cluster — from the <a href="https://operatorhub.io/operator/gitlab-runner-operator" rel="nofollow noreferrer">official documentation</a>, but I keep getting the error below. What could possibly be wrong?</p>
<p>This is the result from the command:</p>
<pre class="lang-bash prettyprint-override"><code>curl -sL https://github.com/operator-framework/operator-lifecycle-manager/releases/download/v0.22.0/install.sh | bash -s v0.22.0
</code></pre>
<pre class="lang-bash prettyprint-override"><code>/bin/bash: line 2: $'\r': command not found
/bin/bash: line 3: $'\r': command not found
/bin/bash: line 5: $'\r': command not found
: invalid option6: set: -
set: usage: set [-abefhkmnptuvxBCEHPT] [-o option-name] [--] [-] [arg ...]
/bin/bash: line 7: $'\r': command not found
/bin/bash: line 9: $'\r': command not found
/bin/bash: line 60: syntax error: unexpected end of file
</code></pre>
<p>I've tried removing the existing curl and downloaded and installed another version but the issue has still persisted. Most solutions online are for Linux users and they all lead to Windows path settings and files issues.</p>
<p>I haven't found one tackling installing a file using <code>curl</code>.</p>
<p>I'll gladly accept any help.</p>
| <p>To start off, I need to be clear about a few things:</p>
<ol>
<li>Based on the tags to the question, I see we are in PowerShell rather than a linux/unix or even Windows cmd shell</li>
<li>In spite of this, we are using Unix <code>curl</code> (probably <code>curl.exe</code>), and not the PowerShell alias for <code>Invoke-WebRequest</code>. We know this because of the <code>-sL</code> argument. If Powershell was using the alias, we'd see a completely different error.</li>
</ol>
<p>Next, I need to talk briefly about line endings. Instead of just a single LF (<code>\n</code>) character as seen in Unix/linux and expected by bash, Windows by default uses the two-character LF/CR pair (<code>\n\r</code>) for line endings.</p>
<hr />
<p>With all that background out of the way, I can now explain what's causing the problem. It's this single pipe character:</p>
<pre><code>|
</code></pre>
<p>This a PowerShell pipe, not a Unix pipe, so the operation puts the output of the <code>curl</code> program in the PowerShell pipeline in order to send it to the <code>bash</code> interpreter. Each line is an individual item on the pipeline, and as such no longer includes any original line breaks. PowerShell pipeline will "correct" this before calling bash using the default line ending for the system, which in this case is the LF/CR pair used by Windows. Now when bash tries to interpret the input, it sees an extra <code>\r</code> character after every line and doesn't know what to do with it.</p>
<p>The trick is most of what we might do in Powershell to strip out those extra characters is still gonna get sent through another pipe after we're done. I guess we <em>could</em> tell curl to write the file to disk without ever using a pipe, and then tell bash to run the saved file, but that's awkward, extra work, and much slower.</p>
<hr />
<p>But we can do a little better. PowerShell by default treats each line returned by curl as a separate item on the pipeline. We can "trick" it to instead putting one big item on the pipeline using the <code>-join</code> operation. That will give us one big string that can go on the pipeline as a single element. It will still end up with an extra <code>\r</code> character, but by the time bash sees it the script will have done it's work.</p>
<p>Code to make this work is found in the other answer, and they deserve all the credit for the solution. The purpose of my post is to do a little better job explaining what's going on: why we have a problem, and why the solution works, since I had to read through that answer a couple times to really get it.</p>
|
<p>I deployed apache ignite cluster in google cloud referring [1], but it given class not found error as follows.</p>
<p>[1]. <a href="https://apacheignite.readme.io/docs/google-cloud-deployment" rel="nofollow noreferrer">https://apacheignite.readme.io/docs/google-cloud-deployment</a></p>
<p>Error message :</p>
<pre><code>2018 Copyright(C) Apache Software Foundation
class org.apache.ignite.IgniteException: Failed to instantiate Spring XML application context (make sure all classes used in Spring configuration are present at CLASSPATH) [springUrl=https://raw.githubusercontent.com/apache/ignite/master/modules/kubernetes/config/example-kube-persistence-and-wal.xml]
at org.apache.ignite.internal.util.IgniteUtils.convertException(IgniteUtils.java:990)
at org.apache.ignite.Ignition.start(Ignition.java:355)
at org.apache.ignite.startup.cmdline.CommandLineStartup.main(CommandLineStartup.java:301)
Caused by: class org.apache.ignite.IgniteCheckedException: Failed to instantiate Spring XML application context (make sure all classes used in Spring configuration are present at CLASSPATH) [springUrl=https://raw.githubusercontent.com/apache/ignite/master/modules/kubernetes/config/example-kube-persistence-and-wal.xml]
at org.apache.ignite.internal.util.spring.IgniteSpringHelperImpl.applicationContext(IgniteSpringHelperImpl.java:387)
at org.apache.ignite.internal.util.spring.IgniteSpringHelperImpl.loadConfigurations(IgniteSpringHelperImpl.java:104)
at org.apache.ignite.internal.util.spring.IgniteSpringHelperImpl.loadConfigurations(IgniteSpringHelperImpl.java:98)
at org.apache.ignite.internal.IgnitionEx.loadConfigurations(IgnitionEx.java:744)
at org.apache.ignite.internal.IgnitionEx.start(IgnitionEx.java:945)
at org.apache.ignite.internal.IgnitionEx.start(IgnitionEx.java:854)
at org.apache.ignite.internal.IgnitionEx.start(IgnitionEx.java:724)
at org.apache.ignite.internal.IgnitionEx.start(IgnitionEx.java:693)
at org.apache.ignite.Ignition.start(Ignition.java:352)
... 1 more
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.apache.ignite.configuration.IgniteConfiguration#0' defined in URL [https://raw.githubusercontent.com/apache/ignite/master/modules/kubernetes/config/example-kube-persistence-and-wal.xml]: Cannot create inner bean 'org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi#1efee8e7' of type [org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi] while setting bean property 'discoverySpi'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi#1efee8e7' defined in URL [https://raw.githubusercontent.com/apache/ignite/master/modules/kubernetes/config/example-kube-persistence-and-wal.xml]: Cannot create inner bean 'org.apache.ignite.spi.discovery.tcp.ipfinder.kube
rnetes.TcpDiscoveryKubernetesIpFinder#1442d7b5' of type [org.apache.ignite.spi.discovery.tcp.ipfinder.kubernetes.TcpDiscoveryKubernetesIpFinder] while setting bean property
'ipFinder'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.apache.ignite.spi.discovery.tcp.ipfinder.kubernet
es.TcpDiscoveryKubernetesIpFinder#1442d7b5' defined in URL [https://raw.githubusercontent.com/apache/ignite/master/modules/kubernetes/config/example-kube-persistence-and-wal
.xml]: Cannot create inner bean 'org.apache.ignite.kubernetes.configuration.KubernetesConnectionConfiguration#6e2c9341' of type [org.apache.ignite.kubernetes.configuration.K
ubernetesConnectionConfiguration] while setting constructor argument; nested exception is org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [org.apache.ignite.kubernetes.configuration.KubernetesConnectionConfiguration] for bean with name 'org.apache.ignite.kubernetes.configuration.KubernetesConnectionConfiguratio
n#6e2c9341' defined in URL [https://raw.githubusercontent.com/apache/ignite/master/modules/kubernetes/config/example-kube-persistence-and-wal.xml]; nested exception is java.
lang.ClassNotFoundException: org.apache.ignite.kubernetes.configuration.KubernetesConnectionConfiguration
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveInnerBean(BeanDefinitionValueResolver.java:313)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:122)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1533)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1280)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:553)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:312)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:308)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:761)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:867)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:543)
at org.apache.ignite.internal.util.spring.IgniteSpringHelperImpl.applicationContext(IgniteSpringHelperImpl.java:381)
... 9 more
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi#1efee8e7' defined in U
RL [https://raw.githubusercontent.com/apache/ignite/master/modules/kubernetes/config/example-kube-persistence-and-wal.xml]: Cannot create inner bean 'org.apache.ignite.spi.d
iscovery.tcp.ipfinder.kubernetes.TcpDiscoveryKubernetesIpFinder#1442d7b5' of type [org.apache.ignite.spi.discovery.tcp.ipfinder.kubernetes.TcpDiscoveryKubernetesIpFinder] wh
ile setting bean property 'ipFinder'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.apache.ignite.spi.disco
very.tcp.ipfinder.kubernetes.TcpDiscoveryKubernetesIpFinder#1442d7b5' defined in URL [https://raw.githubusercontent.com/apache/ignite/master/modules/kubernetes/config/exampl
e-kube-persistence-and-wal.xml]: Cannot create inner bean 'org.apache.ignite.kubernetes.configuration.KubernetesConnectionConfiguration#6e2c9341' of type [org.apache.ignite.
kubernetes.configuration.KubernetesConnectionConfiguration] while setting constructor argument; nested exception is org.springframework.beans.factory.CannotLoadBeanClassExce
ption: Cannot find class [org.apache.ignite.kubernetes.configuration.KubernetesConnectionConfiguration] for bean with name 'org.apache.ignite.kubernetes.configuration.Kubern
etesConnectionConfiguration#6e2c9341' defined in URL [https://raw.githubusercontent.com/apache/ignite/master/modules/kubernetes/config/example-kube-persistence-and-wal.xml];
nested exception is java.lang.ClassNotFoundException: org.apache.ignite.kubernetes.configuration.KubernetesConnectionConfiguration
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveInnerBean(BeanDefinitionValueResolver.java:313)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:122)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1533)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1280)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:553)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveInnerBean(BeanDefinitionValueResolver.java:299)
... 22 more
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.apache.ignite.spi.discovery.tcp.ipfinder.kubernetes.TcpDiscoveryKubern
etesIpFinder#1442d7b5' defined in URL [https://raw.githubusercontent.com/apache/ignite/master/modules/kubernetes/config/example-kube-persistence-and-wal.xml]: Cannot create
inner bean 'org.apache.ignite.kubernetes.configuration.KubernetesConnectionConfiguration#6e2c9341' of type [org.apache.ignite.kubernetes.configuration.KubernetesConnectionCo
nfiguration] while setting constructor argument; nested exception is org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [org.apache.ignite.kub
ernetes.configuration.KubernetesConnectionConfiguration] for bean with name 'org.apache.ignite.kubernetes.configuration.KubernetesConnectionConfiguration#6e2c9341' defined i
n URL [https://raw.githubusercontent.com/apache/ignite/master/modules/kubernetes/config/example-kube-persistence-and-wal.xml]; nested exception is java.lang.ClassNotFoundExc
eption: org.apache.ignite.kubernetes.configuration.KubernetesConnectionConfiguration
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveInnerBean(BeanDefinitionValueResolver.java:313)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:122)
at org.springframework.beans.factory.support.ConstructorResolver.resolveConstructorArguments(ConstructorResolver.java:648)
at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:145)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1197)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1099)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:513)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveInnerBean(BeanDefinitionValueResolver.java:299)
... 28 more
Caused by: org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [org.apache.ignite.kubernetes.configuration.KubernetesConnectionConfiguration] f
or bean with name 'org.apache.ignite.kubernetes.configuration.KubernetesConnectionConfiguration#6e2c9341' defined in URL [https://raw.githubusercontent.com/apache/ignite/mas
ter/modules/kubernetes/config/example-kube-persistence-and-wal.xml]; nested exception is java.lang.ClassNotFoundException: org.apache.ignite.kubernetes.configuration.Kuberne
tesConnectionConfiguration
at org.springframework.beans.factory.support.AbstractBeanFactory.resolveBeanClass(AbstractBeanFactory.java:1391)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveInnerBean(BeanDefinitionValueResolver.java:299)
... 36 more
Caused by: java.lang.ClassNotFoundException: org.apache.ignite.kubernetes.configuration.KubernetesConnectionConfiguration
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at org.springframework.util.ClassUtils.forName(ClassUtils.java:251)
at org.springframework.beans.factory.support.AbstractBeanDefinition.resolveBeanClass(AbstractBeanDefinition.java:401)
at org.springframework.beans.factory.support.AbstractBeanFactory.doResolveBeanClass(AbstractBeanFactory.java:1438)
at org.springframework.beans.factory.support.AbstractBeanFactory.resolveBeanClass(AbstractBeanFactory.java:1383)
... 38 more
Failed to start grid: Failed to instantiate Spring XML application context (make sure all classes used in Spring configuration are present at CLASSPATH) [springUrl=https://r
aw.githubusercontent.com/apache/ignite/master/modules/kubernetes/config/example-kube-persistence-and-wal.xml]
Note! You may use 'USER_LIBS' environment variable to specify your classpath.
</code></pre>
<p>As the error message says no libraries in class path. Is there any issue in docker image or have any issue in deployment?</p>
<p>Thanks in advance.</p>
| <p>That's the old documentation. The new, updated ones are better: <a href="https://ignite.apache.org/docs/latest/installation/kubernetes/gke-deployment" rel="nofollow noreferrer">https://ignite.apache.org/docs/latest/installation/kubernetes/gke-deployment</a></p>
<p>But, in short, you're missing the <code>ignite-kubernetes</code> module. In your deployment/stateful-set YAML file you need something like this:</p>
<pre><code> containers:
# Custom pod name.
- name: ignite-node
image: apacheignite/ignite:2.10.0
env:
- name: OPTION_LIBS
value: ignite-kubernetes,ignite-rest-http
- name: CONFIG_URI
value: file:///ignite/config/node-configuration.xml
</code></pre>
|
<p>I need to create backups and restore for volumes in aws kubernetes cluster. I was reading about CSI driver in kubernetes docs. Though link below has mentioned the steps but I have few questions</p>
<p><a href="https://kubernetes-csi.github.io/docs/snapshot-restore-feature.html" rel="nofollow noreferrer">https://kubernetes-csi.github.io/docs/snapshot-restore-feature.html</a>
<a href="https://ignite.apache.org/docs/latest/installation/kubernetes/amazon-eks-deployment" rel="nofollow noreferrer">https://ignite.apache.org/docs/latest/installation/kubernetes/amazon-eks-deployment</a></p>
<ol>
<li>Where does it take backups. No s3 location mentioned anywhere</li>
<li>Persistent volume claims, storage classes and persistent volumes are referenced in statefulset.yaml. To enable snapshots and restore from snapshot incase needed. So it create volumes when pod is created.</li>
</ol>
<p>I am unable to understand how can we plugin snapshot.yaml and restore.yaml to create backups and to restore from backup.</p>
<p>Can anyone advise on this please or share link to appropriate documents.</p>
| <p>Don't use the infrastructure to perform a backup. Ignite is a distributed system and its data needs to be consistent across all its nodes. Getting a snapshot of a single volume or even all the volumes connected to a pod is not sufficient.</p>
<p>Instead, try to use the built-in tools. Ignite recently got the <a href="https://ignite.apache.org/docs/latest/snapshots/snapshots" rel="nofollow noreferrer">ability to perform snapshots</a> and GridGain (which is built on Ignite) has <a href="https://www.gridgain.com/docs/8.8.13/administrators-guide/snapshots/snapshots-and-recovery" rel="nofollow noreferrer">had the ability for some time</a>.</p>
|
<p>Copied from here: <a href="https://github.com/kubeflow/pipelines/issues/7608" rel="nofollow noreferrer">https://github.com/kubeflow/pipelines/issues/7608</a></p>
<p>I have a generated code file that runs against Kubeflow. It ran fine on Kubeflow v1, and now I'm moving it to Kubeflow v2. When I do this, I get the following error:
<code>json.decoder.JSONDecodeError: Expecting property name enclosed in double quotes: line 1 column 2 (char 1)</code></p>
<p>I honestly don't even know where to go next. It feels like something is fundamentally broken for something to fail in the first character, but I can't see it (it's inside the kubeflow execution).</p>
<p>Thanks!</p>
<hr />
<h3>Environment</h3>
<ul>
<li><p>How did you deploy Kubeflow Pipelines (KFP)?
Standard deployment to AWS</p>
</li>
<li><p>KFP version:
1.8.1</p>
</li>
<li><p>KFP SDK version:
1.8.12</p>
</li>
</ul>
<p>Here's the logs:</p>
<pre><code>time="2022-04-26T17:38:09.547Z" level=info msg="capturing logs" argo=true
WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead:
https://pip.pypa.io/warnings/venv
[KFP Executor 2022-04-26 17:38:24,691 INFO]: Looking for component `run_info_fn` in --component_module_path `/tmp/tmp.NJW6PWXpIt/ephemeral_component.py`
[KFP Executor 2022-04-26 17:38:24,691 INFO]: Loading KFP component "run_info_fn" from /tmp/tmp.NJW6PWXpIt/ephemeral_component.py (directory "/tmp/tmp.NJW6PWXpIt" and module name "ephemeral_component")
Traceback (most recent call last):
File "/usr/local/lib/python3.7/runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "/usr/local/lib/python3.7/runpy.py", line 85, in _run_code
exec(code, run_globals)
File "/usr/local/lib/python3.7/site-packages/kfp/v2/components/executor_main.py", line 104, in <module>
executor_main()
File "/usr/local/lib/python3.7/site-packages/kfp/v2/components/executor_main.py", line 94, in executor_main
executor_input = json.loads(args.executor_input)
File "/usr/local/lib/python3.7/json/__init__.py", line 348, in loads
return _default_decoder.decode(s)
File "/usr/local/lib/python3.7/json/decoder.py", line 337, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/usr/local/lib/python3.7/json/decoder.py", line 353, in raw_decode
obj, end = self.scan_once(s, idx)
json.decoder.JSONDecodeError: Expecting property name enclosed in double quotes: line 1 column 2 (char 1)
time="2022-04-26T17:38:24.803Z" level=error msg="cannot save artifact /tmp/outputs/run_info/data" argo=true error="stat /tmp/outputs/run_info/data: no such file or directory"
Error: exit status 1
</code></pre>
<p>Here's the files to repro:
root_pipeline_04d99580c84b47c28405a2c8bcae8703.py</p>
<pre><code>import kfp.v2.components
from kfp.v2.dsl import InputPath
from kubernetes.client.models import V1EnvVar
from kubernetes import client, config
from typing import NamedTuple
from base64 import b64encode
import kfp.v2.dsl as dsl
import kubernetes
import json
import kfp
from run_info import run_info_fn
from same_step_000_ce6494722c474dd3b8bef482bb976557 import same_step_000_ce6494722c474dd3b8bef482bb976557_fn
run_info_comp = kfp.v2.dsl.component(
func=run_info_fn,
packages_to_install=[
"kfp",
"dill",
],
)
same_step_000_ce6494722c474dd3b8bef482bb976557_comp = kfp.v2.dsl.component(
func=same_step_000_ce6494722c474dd3b8bef482bb976557_fn,
base_image="public.ecr.aws/j1r0q0g6/notebooks/notebook-servers/codeserver-python:v1.5.0",
packages_to_install=[
"dill",
"requests",
# TODO: make this a loop
],
)
@kfp.dsl.pipeline(name="root_pipeline_compilation",)
def root(
context: str='', metadata_url: str='',
):
# Generate secrets (if not already created)
secrets_by_env = {}
env_vars = {
}
run_info = run_info_comp(run_id=kfp.dsl.RUN_ID_PLACEHOLDER)
same_step_000_ce6494722c474dd3b8bef482bb976557 = same_step_000_ce6494722c474dd3b8bef482bb976557_comp(
input_context_path="",
run_info=run_info.outputs["run_info"],
metadata_url=metadata_url
)
same_step_000_ce6494722c474dd3b8bef482bb976557.execution_options.caching_strategy.max_cache_staleness = "P0D"
for k in env_vars:
same_step_000_ce6494722c474dd3b8bef482bb976557.add_env_variable(V1EnvVar(name=k, value=env_vars[k]))
</code></pre>
<p>run_info.py</p>
<pre><code>"""
The run_info component fetches metadata about the current pipeline execution
from kubeflow and passes it on to the user code step components.
"""
from typing import NamedTuple
def run_info_fn(
run_id: str,
) -> NamedTuple("RunInfoOutput", [("run_info", str),]):
from base64 import urlsafe_b64encode
from collections import namedtuple
import datetime
import base64
import dill
import kfp
client = kfp.Client(host="http://ml-pipeline:8888")
run_info = client.get_run(run_id=run_id)
run_info_dict = {
"run_id": run_info.run.id,
"name": run_info.run.name,
"created_at": run_info.run.created_at.isoformat(),
"pipeline_id": run_info.run.pipeline_spec.pipeline_id,
}
# Track kubernetes resources associated wth the run.
for r in run_info.run.resource_references:
run_info_dict[f"{r.key.type.lower()}_id"] = r.key.id
# Base64-encoded as value is visible in kubeflow ui.
output = urlsafe_b64encode(dill.dumps(run_info_dict))
return namedtuple("RunInfoOutput", ["run_info"])(
str(output, encoding="ascii")
)
</code></pre>
<p>same_step_000_ce6494722c474dd3b8bef482bb976557.py</p>
<pre><code>import kfp
from kfp.v2.dsl import component, Artifact, Input, InputPath, Output, OutputPath, Dataset, Model
from typing import NamedTuple
def same_step_000_ce6494722c474dd3b8bef482bb976557_fn(
input_context_path: InputPath(str),
output_context_path: OutputPath(str),
run_info: str = "gAR9lC4=",
metadata_url: str = "",
):
from base64 import urlsafe_b64encode, urlsafe_b64decode
from pathlib import Path
import datetime
import requests
import tempfile
import dill
import os
input_context = None
with Path(input_context_path).open("rb") as reader:
input_context = reader.read()
# Helper function for posting metadata to mlflow.
def post_metadata(json):
if metadata_url == "":
return
try:
req = requests.post(metadata_url, json=json)
req.raise_for_status()
except requests.exceptions.HTTPError as err:
print(f"Error posting metadata: {err}")
# Move to writable directory as user might want to do file IO.
# TODO: won't persist across steps, might need support in SDK?
os.chdir(tempfile.mkdtemp())
# Load information about the current experiment run:
run_info = dill.loads(urlsafe_b64decode(run_info))
# Post session context to mlflow.
if len(input_context) > 0:
input_context_str = urlsafe_b64encode(input_context)
post_metadata(
{
"experiment_id": run_info["experiment_id"],
"run_id": run_info["run_id"],
"step_id": "same_step_000",
"metadata_type": "input",
"metadata_value": input_context_str,
"metadata_time": datetime.datetime.now().isoformat(),
}
)
# User code for step, which we run in its own execution frame.
user_code = f"""
import dill
# Load session context into global namespace:
if { len(input_context) } > 0:
dill.load_session("{ input_context_path }")
{dill.loads(urlsafe_b64decode("gASVGAAAAAAAAACMFHByaW50KCJIZWxsbyB3b3JsZCIplC4="))}
# Remove anything from the global namespace that cannot be serialised.
# TODO: this will include things like pandas dataframes, needs sdk support?
_bad_keys = []
_all_keys = list(globals().keys())
for k in _all_keys:
try:
dill.dumps(globals()[k])
except TypeError:
_bad_keys.append(k)
for k in _bad_keys:
del globals()[k]
# Save new session context to disk for the next component:
dill.dump_session("{output_context_path}")
"""
# Runs the user code in a new execution frame. Context from the previous
# component in the run is loaded into the session dynamically, and we run
# with a single globals() namespace to simulate top-level execution.
exec(user_code, globals(), globals())
# Post new session context to mlflow:
with Path(output_context_path).open("rb") as reader:
context = urlsafe_b64encode(reader.read())
post_metadata(
{
"experiment_id": run_info["experiment_id"],
"run_id": run_info["run_id"],
"step_id": "same_step_000",
"metadata_type": "output",
"metadata_value": context,
"metadata_time": datetime.datetime.now().isoformat(),
}
)
</code></pre>
<p>Python file to execute to run:</p>
<pre><code>from sameproject.ops import helpers
from pathlib import Path
import importlib
import kfp
def deploy(compiled_path: Path, root_module_name: str):
with helpers.add_path(str(compiled_path)):
kfp_client = kfp.Client() # only supporting 'kubeflow' namespace
root_module = importlib.import_module(root_module_name)
return kfp_client.create_run_from_pipeline_func(
root_module.root,
arguments={},
)
</code></pre>
| <p>Turns out it has to do with not compiling with the right execution mode on.</p>
<p>If you're getting this, your code should look like this.</p>
<pre><code>Compiler(mode=kfp.dsl.PipelineExecutionMode.V2_COMPATIBLE).compile(pipeline_func=root_module.root, package_path=str(package_yaml_path))
</code></pre>
|
<p>Is it possible to programatically set the sourcetype to be the namespace from where the logs were generated? I am using the fluentd plugin to send data to the Splunk http event collector. Elsewhere, it was recommended to use ${record['kubernetes']['namespace_name'] to set the index name to be the namespace name. When I do this for sourcetype, that actual text just shows up in Splunk rather than translating to the specific namespace names.</p>
<pre><code>@include systemd.conf
@include kubernetes.conf
<match kubernetes.var.log.containers.fluentd**>
type null
</match>
<match **>
type splunk-http-eventcollector
all_items true
server host:port
token ****
index kubernetes
protocol https
verify false
sourcetype ${record['kubernetes']['namespace_name']
source kubernetes
buffer_type memory
buffer_queue_limit 16
chunk_limit_size 8m
buffer_chunk_limit 150k
flush_interval 5s
</match>
</code></pre>
| <p>If you have not defined a <code>sourcetype</code> in an appropriate <code>props.conf</code> (and associated <code>transforms.conf</code>), Splunk will try to determine the sourcetype based on heuristics</p>
<p>Those heuristics are not generally very accurate on custom data sources</p>
<p>Instead of trying to "programatically set the sourcetype to be the namespace from where the logs were generated", add a field whose contents indicate the namespace from which the logs are generated (eg "namespace")</p>
<p>It's much simpler, extends your logging more efficiently, and doesn't require the definition of scores or hundreds or thousands of individual sourcetypes</p>
|
<p>Is there a way to connect C# Thick Client running in the Windows Machine outside of the Kubernetes with Apache Ignite Cluster nodes are present in the Kubernetes.</p>
<p>Below specified article says it is not possible but this article was written in 2020. We are looking for Scenario-3 from below article
<a href="https://dzone.com/articles/apache-ignite-on-kubernetes-things-to-know-about" rel="nofollow noreferrer">https://dzone.com/articles/apache-ignite-on-kubernetes-things-to-know-about</a>
I hope there might some enhancements for Scenario-3.</p>
<p>We dont want convert our C# Thick client to Thin Client as we are using Data Streamer to insert data in bulk and same functionality is not available with Thin Client.</p>
| <p>The recommendation here would be to use the thin-client. The .net thin-client does have the data streamer API.</p>
<p>There is no straight-forward way to connect a thick-client node from outside Kubernetes to a cluster inside it.</p>
|
<p>I'm working locally (within Docker for Mac) on a Kubernetes cluster that will eventually be deployed to the cloud. We plan to use a database service in that environment. To simulate that, I'd like to have the services in the cluster connect to a database running outside the cluster on my laptop.</p>
<p>Can I do that? Here's what I thought I'd try.</p>
<ul>
<li>Define a <code>Service</code> with <code>type: ExternalName</code> and <code>externalName: somedb.local</code></li>
<li>Add <code>127.0.0.1 somedb.local</code> to <code>/etc/hosts</code> on the laptop</li>
</ul>
<p>Is that correct? Is there a better way?</p>
| <p>After talking with some colleagues, I found a solution.</p>
<p>In Docker for Mac, <code>host.docker.internal</code> points to the host machine, and that lets me connect to the db running there, even from containers running in the K8s cluster.</p>
|
<p><strong>Background</strong></p>
<p>On the Google Kubernetes Engine we've been using Cloud Endpoints, and the Extensible Service Proxy (v2) for service-to-service authentication.</p>
<p>The services authenticate themselves by including the bearer JWT token in the <code>Authorization</code> header of the HTTP requests.</p>
<p>The identity of the services has been maintained with GCP Service Accounts, and during deployment, the Json Service Account key is mounted to the container at a predefined location, and that location is set as the value of the <code>GOOGLE_APPLICATION_CREDENTIALS</code> env var.</p>
<p>The services are implemented in C# with ASP.NET Core, and to generate the actual JWT token, we use the Google Cloud SDK (<a href="https://github.com/googleapis/google-cloud-dotnet" rel="nofollow noreferrer">https://github.com/googleapis/google-cloud-dotnet</a>, and <a href="https://github.com/googleapis/google-api-dotnet-client" rel="nofollow noreferrer">https://github.com/googleapis/google-api-dotnet-client</a>), where we call the following method:</p>
<pre class="lang-cs prettyprint-override"><code>var credentials = GoogleCredential.GetApplicationDefault();
</code></pre>
<p>If the <code>GOOGLE_APPLICATION_CREDENTIALS</code> is correctly set to the path of the Service Account key, then this returns a <code>ServiceAccountCredential</code> object, on which we can call the <code>GetAccessTokenForRequestAsync()</code> method, which returns the actual JWT token.</p>
<pre class="lang-cs prettyprint-override"><code>var jwtToken = await credentials.GetAccessTokenForRequestAsync("https://other-service.example.com/");
var authHeader = $"Bearer {jwtToken}";
</code></pre>
<p>This process has been working correctly without any issues.</p>
<p>The situation is that we are in the process of migrating from using the manually maintained Service Account keys to using <a href="https://cloud.google.com/kubernetes-engine/docs/how-to/workload-identity" rel="nofollow noreferrer">Workload Identity</a> instead, and I cannot figure out how to correctly use the Google Cloud SDK to generate the necessary JWT tokens in this case.</p>
<p><strong>The problem</strong></p>
<p>When we enable Workload Identity in the container, and don't mount the Service Account key file, nor set the <code>GOOGLE_APPLICATION_CREDENTIALS</code> env var, then the <code>GoogleCredential.GetApplicationDefault()</code> call returns a <code>ComputeCredential</code> instead of a <code>ServiceAccountCredential</code>.<br />
And if we call the <code>GetAccessTokenForRequestAsync()</code> method, that returns a token which is not in the JWT format.</p>
<p>I checked the implementation, and the token seems to be retrieved from the Metadata server, of which the expected response format seems to be the standard OAuth 2.0 model (represented in <a href="https://github.com/googleapis/google-api-dotnet-client/blob/master/Src/Support/Google.Apis.Auth/OAuth2/Responses/TokenResponse.cs" rel="nofollow noreferrer">this model class</a>):</p>
<pre><code>{
"access_token": "foo",
"id_token": "bar",
"token_type": "Bearer",
...
}
</code></pre>
<p>And the <code>GetAccessTokenForRequestAsync()</code> method returns the value of <code>access_token</code>. But as far as I understand, that's not a JWT token, and indeed when I tried using it to authenticate against ESP, it responded with</p>
<pre><code>{
"code": 16,
"message": "JWT validation failed: Bad JWT format: Invalid JSON in header",
..
}
</code></pre>
<p>As far as I understand, normally the <code>id_token</code> contains the JWT token, which should be accessible via the <code>IdToken</code> property of the <code>TokenResponse</code> object, which is also accessible via the SDK, I tried accessing it like this:</p>
<pre><code>var jwtToken = ((ComputeCredential)creds.UnderlyingCredential).Token.IdToken;
</code></pre>
<p>But this returns <code>null</code>, so apparently the metadata server does not return anything in the <code>id_token</code> field.</p>
<p><strong>Question</strong></p>
<p>What would be the correct way to get the JWT token with the .NET Google Cloud SDK for accessing ESP, when using Workload Identity in GKE?</p>
| <p>To get an IdToken for the attached service account, you can use <code>GoogleCredential.GetApplicationDefault().GetOidcTokenAsync(...)</code>.</p>
|
<p>In Kubernetes, when a Pod repeatedly crashes and is in <code>CrashLoopBackOff</code> status, it is not possible to shell into the container and poke around to find the problem, due to the fact that containers (unlike VMs) live only as long as the primary process. If I shell into a container and the Pod is restarted, I'm kicked out of the shell.</p>
<p>How can I keep a Pod from crashing so that I can investigate if my primary process is failing to boot properly?</p>
| <h2>Redefine the <code>command</code></h2>
<p>In <strong>development only</strong>, a temporary hack to keep a Kubernetes pod from crashing is to redefine it and <a href="https://kubernetes.io/docs/tasks/inject-data-application/define-command-argument-container/" rel="noreferrer">specify the container's <code>command</code></a> (corresponding to a Docker <code>ENTRYPOINT</code>) and <code>args</code> to be a command that will not crash. For instance:</p>
<pre><code> containers:
- name: something
image: some-image
# `shell -c` evaluates a string as shell input
command: [ "sh", "-c"]
# loop forever, outputting "yo" every 5 seconds
args: ["while true; do echo 'yo' && sleep 5; done;"]
</code></pre>
<p>This allows the container to run and gives you a chance to shell into it, like <code>kubectl exec -it pod/some-pod -- sh</code>, and investigate what may be wrong.</p>
<p>This needs to be undone after debugging so that the container will run the command it's actually meant to run.</p>
<p>Adapted from <a href="https://beanexpert.co.in/troubleshoot-pod-crashloopbackoff-error-kubernetes/" rel="noreferrer">this blog post</a>.</p>
|
<p>I have a hard requirement to use a single ELB Classic (CLB) load balancer. Can a single ELB Classic (CLB) distribute traffic between two different Auto Scaling Groups, both running the same application code with no special path based routing needed from an ALB (Application Load Balancer).</p>
<p>For example, in a high availability (HA) cluster set-up with KOPS, how does KOPS make it possible to use a single ELB Classic load balancer (as an entry point to the API server) to serve traffic to two different Auto Scaling Groups in different Availability Zones (AZs) each with their own master instances?</p>
<p>Thanks in advance.</p>
| <p>A single classis ELB cannot have multiple ASGs associated with it, but the newer Application Load Balancer can do this.</p>
|
<p>I'm following <a href="https://cloud.google.com/python/django/kubernetes-engine" rel="nofollow noreferrer">the tutorial on how to deploy a Django application to the Kubernetes Engine</a> in the Google Cloud Platform and on step 9 it does this:</p>
<blockquote>
<ol start="9">
<li><p>Retrieve the public Docker image for the Cloud SQL proxy.</p>
<pre><code>docker pull b.gcr.io/cloudsql-docker/gce-proxy:1.05
</code></pre></li>
</ol>
</blockquote>
<p>What is this Cloud SQL proxy image? Am I understand it correctly that the application, the web workers, are deployed to images built on top of the Cloud SQL proxy image? Is this so that they can access the database?</p>
<p>Looking at <a href="https://github.com/GoogleCloudPlatform/python-docs-samples/blob/master/container_engine/django_tutorial/polls.yaml" rel="nofollow noreferrer">the yaml file</a> for the application, it looks like the image generated out of the Cloud SQL proxy will be running the application bu then there's another container that is just the cloudsql-docker image. Why is this second container needed?</p>
| <p>I'm sure some other people that actually understand Kubernetes, Docker and GCP will chip in with better answers, but I wanted to drop in what I've learned so far in case others arrived here with the same question.</p>
<blockquote>
<p>What is this Cloud SQL proxy image?</p>
</blockquote>
<p>That is a Docker image that runs the Cloud SQL proxy which is explained here: <a href="https://cloud.google.com/sql/docs/postgres/sql-proxy" rel="nofollow noreferrer">https://cloud.google.com/sql/docs/postgres/sql-proxy</a></p>
<p>I'm still not 100% sure why this SQL Proxy is used though.</p>
<blockquote>
<p>Am I understand it correctly that the application, the web workers, are deployed to images built on top of the Cloud SQL proxy image?</p>
</blockquote>
<p>That was wrong. This command:</p>
<pre><code>docker build -t gcr.io/<your-project-id>/polls .
</code></pre>
<p>uses the <a href="https://github.com/GoogleCloudPlatform/python-docs-samples/blob/master/container_engine/django_tutorial/Dockerfile" rel="nofollow noreferrer">Dockerfile from the git repo</a> which states <code>gcr.io/google_appengine/python</code> as the base image for the app image.</p>
|
<p>I was trying to reduce the production of logs in splunk. when i tried to reduce the logs by using below query i was getting a large number of log entries</p>
<pre><code>Spunk query: (source!="/var/log/kubernetes/audit/kube-apiserver-audit.log" cluster_name::dkp-test index="tst-dkp") null sourcetype="fluentd:monitor-agent"
</code></pre>
<p>I was tried to reduce the log production by using <code>emit_interval 300</code> and <code>cache_ttl 3600</code> but it is not worked.</p>
<p>Can anyone please suggest how should i reduce the production of logs in splunk connector. Thanks.</p>
<p>I found that the logs were producing from the node:</p>
<pre><code>[ec2-user@ip-11-21-111-11 ~]$ sudo su
[root@ip-11-21-111-11 ec2-user]# ps -ef | grep flu
root 2536779 2536761 0 Jan31 ? 00:00:16 /usr/bin/fluentd -c /fluentd/etc/fluent.conf
root 2536965 2536779 0 Jan31 ? 00:07:34 /usr/bin/ruby -r/usr/local/share/gems/gems/bundler-2.2.33/lib/bundler/setup -Eascii-8bit:ascii-8bit /usr/bin/fluentd -c /fluentd/etc/fluent.conf --under-supervisor
root 2536978 2536965 0 Jan31 ? 00:00:00 sh -c jq --unbuffered -c '.record.source = "namespace:platform/pod:splunk-connect-splunk-kubernetes-logging-vmkjx" | .record.sourcetype = "fluentd:monitor-agent" | .record.cluster_name = "platform-dkp-test" | .record.splunk_index = "ss-tst-dkp" | .record' 2>&1
root 2536980 2536978 0 Jan31 ? 00:00:02 jq --unbuffered -c .record.source = "namespace:platform/pod:splunk-connect-splunk-kubernetes-logging-vmkjx" | .record.sourcetype = "fluentd:monitor-agent" | .record.cluster_name = "platform-dkp-test" | .record.splunk_index = "ss-tst-dkp" | .record
root 3730152 3730072 0 13:21 pts/0 00:00:00 grep --color=auto flu
</code></pre>
<p>The logs are generating from the splunk are :</p>
<pre><code>{ [-]
emit_records: 0
emit_size: 0
output_plugin: false
plugin_category: filter
plugin_id: object:c11c
retry_count: null
type: jq_transformer
}
Show as raw text
host = ip-11-21-111-11.ec2.internalsource = namespace:platform/pod:splunk-connect-splunk-kubernetes-logging-jxsourcetype = fluentd:monitor-agent
</code></pre>
<p>in this i wanted reduce the logs for <code>Reduce logging for retry_count: null</code></p>
| <p>The only way to "reduce the production of logs" going into Splunk is to not log as much that the Universal Forwarder picks up, or that is sent via the HTTP Event Collector</p>
<p>If you want to <em>filter</em> events based on criteria in your SPL, then you need to look at the field(s) in question, and only select what you're looking for</p>
|
<p><a href="https://i.stack.imgur.com/szaBC.png" rel="nofollow noreferrer">enter image description here</a></p>
<p><code>Operation failed. Check pod logs for install-runner for more details.</code></p>
<p>I am getting this error while trying to install GitLab runner.
What I have done so far</p>
<ul>
<li>successfully installed Kubernetes cluster</li>
<li>created a demo project in Gitlab</li>
<li>provided details to GitLab for Kubernetes cluster</li>
</ul>
<p><strong>Then while trying to installing runner it shows failure.</strong>
What am I missing here? [please check the attached image]</p>
| <p>Warning, with GitLab 13.11 (April 2021):</p>
<blockquote>
<h2><a href="https://about.gitlab.com/releases/2021/04/22/gitlab-13-11-released/#one-click-gitlab-managed-apps-will-be-removed-in-gitlab-14.0" rel="nofollow noreferrer">One-click GitLab Managed Apps will be removed in GitLab 14.0</a></h2>
<p>We are deprecating one-click install of GitLab Managed Apps.</p>
<p>Although they made it very easy to get started with deploying to Kubernetes from GitLab, the overarching community feedback was that they were not flexible or customizable enough for real-world Kubernetes applications.</p>
<p>Instead, our future direction will focus on <a href="https://docs.gitlab.com/ee/user/clusters/applications.html#install-using-gitlab-cicd-alpha" rel="nofollow noreferrer">installing apps on Kubernetes via GitLab CI/CD</a> in order to provide a better balance between ease-of-use and expansive customization.</p>
<p>We plan to remove one-click Managed Apps completely in GitLab version 14.0.<br />
This will not affect how existing managed applications run inside your cluster, however, you’ll no longer have the ability to modify those applications via the GitLab UI.</p>
<p>We recommend cluster administrators plan to migrate any existing managed applications by reinstalling them either manually or via CI/CD. Migration instructions will be available in our documentation later.</p>
<p>For users of alerts on managed Prometheus, in GitLab version 14.0, we will also remove the ability to setup/modify alerts from the GitLab UI. This change is necessary because the existing solution will no longer function once managed Prometheus is removed.</p>
</blockquote>
<p>Deprecation date: May 22, 2021</p>
|
<p>I am currently using Kubernetes Python SDK to fetch relevant information from my k8s cluster. I am running this from outside the cluster.</p>
<p>I have a requirement of fetching the images of all the POD's running within a namespace. I did look at Docker python SDK but that requires me to be running the script on the cluster itself which i want to avoid.</p>
<p>Is there a way to get this done ?</p>
<p>TIA</p>
| <blockquote>
<p>that requires me to be running the script on the cluster itself</p>
</blockquote>
<p>No, it should not: the <a href="https://github.com/kubernetes-client/python" rel="nofollow noreferrer">kubernetes-client python</a> performs operations similar to <strong><a href="https://kubernetes.io/docs/reference/kubectl/overview/" rel="nofollow noreferrer"><code>kubectl</code></a></strong> calls (as <a href="https://github.com/kubernetes-client/python/blob/e057f273069de445a2d5a250ac5fe37d79671f3b/examples/notebooks/intro_notebook.ipynb" rel="nofollow noreferrer">detailed here</a>).<br>
And <code>kubectl</code> calls can be done from any client with a properly set <code>.kube/config</code> file.</p>
<p>Once you get the image name from a <code>kubectl describe po/mypod</code>, you might need to docker pull that image locally if you want more (like a docker history).</p>
<p>The <a href="https://stackoverflow.com/users/3219658/raks">OP Raks</a> adds <a href="https://stackoverflow.com/questions/52685119/fetching-docker-image-information-using-python-sdk/52686099?noredirect=1#comment92326426_52686099">in the comments</a>:</p>
<blockquote>
<p>I wanted to know if there is a python client API that actually gives me an option to do docker pull/save/load of an image as such</p>
</blockquote>
<p>The <a href="https://docker-py.readthedocs.io/en/stable/images.html" rel="nofollow noreferrer"><strong>docker-py</strong></a> library can pull/load/save images.</p>
|
<p>I have a Kubernetes v1.10.2 cluster and a cronjob on it.
The job config is set to:</p>
<pre><code> failedJobsHistoryLimit: 1
successfulJobsHistoryLimit: 3
</code></pre>
<p>But it has created more than ten jobs, which are all successful and not removed automatically.
Now I am trying to delete them manually, with <code>kubectl delete job XXX</code>, but the command timeout as:</p>
<pre><code>$ kubectl delete job XXX
error: timed out waiting for "XXX" to be synced
</code></pre>
<p>I want to know how can I check in such a situation. Is there a log file for the command execution?</p>
<p>I only know the <code>kubectl logs</code> command, but it is not for such a situation.</p>
<p>"kubectl get" shows the job has already finished:</p>
<pre><code>status:
active: 1
completionTime: 2018-08-27T21:20:21Z
conditions:
- lastProbeTime: 2018-08-27T21:20:21Z
lastTransitionTime: 2018-08-27T21:20:21Z
status: "True"
type: Complete
failed: 3
startTime: 2018-08-27T01:00:00Z
succeeded: 1
</code></pre>
<p>and "kubectl describe" output as:</p>
<pre><code>$ kubectl describe job test-elk-xxx-1535331600 -ntest
Name: test-elk-xxx-1535331600
Namespace: test
Selector: controller-uid=863a14e3-a994-11e8-8bd7-fa163e23632f
Labels: controller-uid=863a14e3-a994-11e8-8bd7-fa163e23632f
job-name=test-elk-xxx-1535331600
Annotations: <none>
Controlled By: CronJob/test-elk-xxx
Parallelism: 0
Completions: 1
Start Time: Mon, 27 Aug 2018 01:00:00 +0000
Pods Statuses: 1 Running / 1 Succeeded / 3 Failed
Pod Template:
Labels: controller-uid=863a14e3-a994-11e8-8bd7-fa163e23632f
job-name=test-elk-xxx-1535331600
Containers:
xxx:
Image: test-elk-xxx:18.03-3
Port: <none>
Host Port: <none>
Args:
--config
/etc/elasticsearch-xxx/xxx.yml
/etc/elasticsearch-xxx/actions.yml
Limits:
cpu: 100m
memory: 100Mi
Requests:
cpu: 100m
memory: 100Mi
Environment: <none>
Mounts:
/etc/elasticsearch-xxx from xxx-configs (ro)
Volumes:
xxx-configs:
Type: ConfigMap (a volume populated by a ConfigMap)
Name: test-elk-xxx
Optional: false
Events: <none>
</code></pre>
<p>It indicates still one pod running, but I don't know how to figure out the pod name.</p>
| <p>Check if <code>kubectl describe pod <pod name></code> (associated pod of the job) still returns something, which would:</p>
<ul>
<li>mean the node is still there</li>
<li>include the <a href="https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle/#pod-conditions" rel="nofollow noreferrer">pod condition</a></li>
</ul>
<p>In that state, you can then consider <a href="https://kubernetes.io/docs/tasks/run-application/force-delete-stateful-set-pod/#delete-pods" rel="nofollow noreferrer">a force deletion</a>.</p>
|
<p>I have an application that gets deployed from a docker image to a Kubernetes pod. Inside of my docker image I run the following command</p>
<pre><code>FROM openjdk:17.0.1-slim
USER root
WORKDIR /opt/app
ARG JAR_FILE
ARG INFO_APP_BUILD
RUN apt-get update
RUN apt-get install -y sshpass
RUN apt-get install -y openssh-service
COPY /build/libs/*SNAPSHOT.jar /opt/app/app.jar
ENV INFO_APP_BUILD=${INFO_APP_BUILD}
EXPOSE 8080
CMD java -jar /opt/app/app.jar
</code></pre>
<p>When the application gets deployed, out of my control, the user gets set to a non root user.</p>
<p>Now the important part is that when i try to launch an ssh command i get an error message <code>no user exists for uid [random id here]</code></p>
<p>My goal is to configure the docker image to create a user and grant it permission to use the SSH command.</p>
| <blockquote>
<p>When the application gets deployed, out of my control, the user gets set to a non root user.</p>
</blockquote>
<p>Inside the container, the user running <code>java -jar /opt/app/app.jar</code> is root, because of <code>USER root</code>.</p>
<p>Outside the container, on the host, a deployed application is usually (almost exclusively) never executed/accessed as <code>root</code>.</p>
<p>But it should still make ssh request from within the container to a server:</p>
<ul>
<li>the <a href="https://ubuntu.com/server/docs/service-openssh" rel="nofollow noreferrer">openssh service</a> is started</li>
<li>the container /root/.ssh has the right public/private key</li>
<li>the <code>~user/.ssh</code> folder, on the target server where the Docker application is running, has the authorized_keys with the public one in it.</li>
</ul>
<p>But if the user does not exist inside the container, you need to create it on <code>docker run</code>, as <a href="https://unix.stackexchange.com/a/613055/7490">in here</a>:</p>
<pre class="lang-sh prettyprint-override"><code>docker run -it --rm --entrypoint sh "$@" \
-c "[ -x /usr/sbin/useradd ] && useradd -m -u $(id -u) u1 -s /bin/sh || adduser -D -u $(id -u) u1 -s /bin/sh;
exec su - u1"
</code></pre>
|
<p>I have a simple website running in my Kubernetes cluster and exposed to the Internet using Traefik. My Ingress object looks like this (the only things I've changed here are the name and domain names):</p>
<pre class="lang-yaml prettyprint-override"><code>apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
annotations:
cert-manager.io/cluster-issuer: letsencrypt-staging
kubernetes.io/ingress.class: traefik
name: my-cool-website
namespace: default
spec:
rules:
- host: my-cool-website.com
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: my-cool-website
port:
number: 80
- host: www.my-cool-website.com
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: my-cool-website
port:
number: 80
tls:
- hosts:
- my-cool-website.com
- www.my-cool-website.com
secretName: my-cool-website-tls
</code></pre>
<p>This <strong>works</strong>. It allows me to access the site either from <code>my-cool-website.com</code> or from <code>www.my-cool-website.com</code>. But what I'd like to have happen is that if someone visits the former, that Traefik automatically redirects them to the latter. I found a couple of guides online that recommended creating a Traefik middleware, so I did just that, but unfortunately it doesn't work as intended. Here is my middleware definition:</p>
<pre class="lang-yaml prettyprint-override"><code>apiVersion: traefik.containo.us/v1alpha1
kind: Middleware
metadata:
name: my-cool-website-force-www
spec:
redirectRegex:
regex: ^https?://my-cool-website.com/(.*)
replacement: https://www.my-cool-website.com/${1}
</code></pre>
<p>And then I add the following annotation back to the ingress object:</p>
<pre class="lang-yaml prettyprint-override"><code>traefik.ingress.kubernetes.io/router.middlewares: my-cool-website-force-www
</code></pre>
<p>But as soon as I do that, it breaks my web app. By that I mean, when that annotation is applied, instead of serving my website, I start seeing a generic nginx page that looks like this when I try to access the domain (and also it does not do the redirect):</p>
<p><a href="https://i.stack.imgur.com/fuiJY.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/fuiJY.png" alt="Hello World generic Traefik response" /></a></p>
<p>I have to assume this Hello World page is being served by Traefik as some sort of generic default page, as it definitely does not originate from my pod. So that tells me something about this middleware (or perhaps how I'm calling it with the annotation) isn't working. What am I missing?</p>
| <p>I figured it out, by port-forwarding to the Traefik Dashboard and looking at the service there. It was showing an error for the middleware not found. I then clicked over to the middlewares and realized that they end up with a longer canonical name. So in my annotation I had to change the reference from <code>my-cool-website-force-www</code> to <code>default-my-cool-website-force-www@kubernetescrd</code> and then everything worked.</p>
|
<p>I am using Clair for Vulnerability checks in my harbor.</p>
<p>Services like Clair that have thousands of hosts continually hitting the hosting git server(<a href="https://git.launchpad.net/ubuntu-cve-tracker/" rel="nofollow noreferrer">https://git.launchpad.net/ubuntu-cve-tracker/</a>) saturate the server, and so there are scaling measures in place that causes it to return a 503 error when too many clients are concurrently hitting it.</p>
<p>These are my errors in my Clair pod:</p>
<pre><code>{"Event":"could not pull ubuntu-cve-tracker repository","Level":"error","Location":"ubuntu.go:174",
"Time":"2021-06-25 06:38:32.859806","error":"exit status 128",
"output":"Cloning into '.'...
fatal: unable to access '[https://git.launchpad.net/ubuntu-cve-tracker/':|https://git.launchpad.net/ubuntu-cve-tracker/%27:]
The requested URL returned error: 503\n"}
{"Event":"an error occured when fetching update","Level":"error","Location":"updater.go:246",
"Time":"2021-06-25 06:38:32.859934","error":"could not download requested resource","updater name":"ubuntu"}
</code></pre>
<pre><code>panic: runtime error: slice bounds out of range goroutine 549 [running]: github.com/coreos/clair/ext/vulnsrc/rhel.toFeatureVersions(0xc000208390, 0x2, 0xc000246070, 0x1, 0x1, 0xc0001bc200, 0x1, 0x1, 0x0, 0x908f38, ...) /go/src/github.com/coreos/clair/ext/vulnsrc/rhel/rhel.go:292 +0xc3b github.com/coreos/clair/ext/vulnsrc/rhel.parseRHSA(0x7fcc0f4a24b0, 0xc00038c0f0, 0xc00038c0f0, 0x7fcc0f4a24b0, 0xc00038c0f0, 0x8e2708, 0x4) /go/src/github.com/coreos/clair/ext/vulnsrc/rhel/rhel.go:182 +0x1c8
</code></pre>
<p>As per <a href="https://bugs.launchpad.net/ubuntu-cve-tracker/+bug/1925337" rel="nofollow noreferrer">https://bugs.launchpad.net/ubuntu-cve-tracker/+bug/1925337</a> this is a bug from the git server, and in that post, they are suggesting to get Clair to pull data from other sources instead which means an offline approach. So apart from the offline approach, is there any other way to decrease the number of hits to the git server for Vulnerability checks?</p>
<p>I have tried to control the number of hits to the git server, but nowhere have I found the configuration in Clair.</p>
<p>Does anyone have any idea how we can control the hits for Vulnerability checks or avoid restarts of my pod?</p>
<p>Also, I found schedule a scan(hourly, daily, or weekly) on my harbor UI, But how does scheduling the scan to say daily help?<br />
Is it only at that point it will try to do the git clone to get the latest CVEs?</p>
| <p>Check first if this is linked to <a href="https://github.com/goharbor/harbor/issues/14720" rel="nofollow noreferrer"><code>goharbor/harbor</code> issue 14720</a>: "clair restarts repeatedly when there is some issue with vulnerability repos", with logs like</p>
<pre class="lang-golang prettyprint-override"><code>{"Event":"Start fetching vulnerabilities","Level":"info","Location":"ubuntu.go:85","Time":"2021-04-21 19:18:24.446743","package":"Ubuntu"}
...
{"Event":"could not pull ubuntu-cve-tracker repository","Level":"error","Location":"ubuntu.go:174","Time":"2021-04-21 19:18:25.147515","error":"exit status 128","output":"Cloning into '.'...\nfatal: unable to access 'https://git.launchpad.net/ubuntu-cve-tracker/': The requested URL returned error: 503\n"}
{"Event":"an error occured when fetching update","Level":"error","Location":"updater.go:246","Time":"2021-04-21 19:18:25.147607","error":"could not download requested resource","updater name":"ubuntu"}
...
panic: runtime error: slice bounds out of range [25:24]
goroutine 327 [running]:
github.com/quay/clair/v2/ext/vulnsrc/rhel.toFeatureVersions(0xc0065215a8, 0x2, 0xc0000b4f08, 0x1, 0x1, 0xc006ef7aa0, 0x1, 0x1, 0x2, 0xc0000b4ef0, ...)
/go/src/github.com/quay/clair/ext/vulnsrc/rhel/rhel.go:276 +0xbf8
</code></pre>
<p>It refers to <a href="https://github.com/quay/clair/issues/1249#L278" rel="nofollow noreferrer"><code>quay/clair</code> issue 1249</a>, but the harbor case is closed with <a href="https://github.com/goharbor/harbor/pull/15032" rel="nofollow noreferrer">PR 15032</a>, using <code>CLAIRVERSION=v2.1.7</code></p>
|
<p>I am using docker to run my java war application and when I run the container I got this exception <strong>java.net.BindException: Address already in use</strong> .</p>
<p>The container expose port 8085 (8080->8085/tcp)
I executed this command to run the docker container :</p>
<blockquote>
<p>docker run -p 8080:8085/tcp -d --name=be-app java-app-image:latest</p>
</blockquote>
<p>this is screenshot of the error
<a href="https://i.stack.imgur.com/Hjoc0.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Hjoc0.png" alt="enter image description here" /></a></p>
<p>I checked the opened ports inside the container
<a href="https://i.stack.imgur.com/6YIvP.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/6YIvP.png" alt="enter image description here" /></a></p>
<p>I cannot restart the tomcat inside the container because it will stop , I thought about changing the 8085 port in the server.xml file , but I think that I should change the exposed port also.
Is there any solution to avoid this exception ? ( java.net.BindException: Address already in use)</p>
<p>this is also what I am getting when I run command ps aux
<a href="https://i.stack.imgur.com/xItSj.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/xItSj.png" alt="enter image description here" /></a></p>
| <p>The <code>ps</code> shows <em>two</em> java processes, possibly running Tomcat.</p>
<p>Since they would be running with the same parameters, including ports, it seems expected the second process fails with</p>
<pre><code>java.net.BindException: Address already in use
</code></pre>
<p>Make sure to <code>docker stop</code> everything first, and check the status of <code>docker ps --all</code></p>
|
<p>I have an app running in a kubernetes managed docker container, using Azure Kubernetes Service (AKS). I can output logs to a text file for the app deployment using:</p>
<pre><code>kubectl logs deployment/my-deployment > out.txt
</code></pre>
<p>This gives me a file of around max 28Mb. When I get the docker logs for the same container on the physical VM using <code>docker logs ...</code>, the log file is much bigger (up to 120Mb+).</p>
<p>How can I increase the size of the available <code>kubectl logs</code> for the deployment? If this option is available, then it would likely be an option that increases the size of the available <code>kubectl logs</code> for the <em>pod</em> that holds the container, as the pod and deployment logs are identical.</p>
<p>It's not the docker configuration in <code>/etc/docker/daemon.json</code> that's limiting the <code>kubectl</code> logs, as that's set to 50Mb. I've read that it's the underlying docker configuration that kubernetes uses, but that doesn't seem to be the case, as my<code>kubectl</code> logs are being truncated to around 28Mb.</p>
| <p><a href="https://kubernetes.io/docs/reference/generated/kubectl/kubectl-commands#logs" rel="nofollow noreferrer"><code>Kubectl logs</code></a> might read logs with a default log rotation, meaning the <a href="https://stackoverflow.com/a/39398892/6309">logrotate service is active</a>.</p>
<p>Check the content of cat /etc/logrotate.d/docker-containers, as in <a href="https://github.com/kubernetes/kubernetes/issues/11046" rel="nofollow noreferrer">this issue</a>, for confirmation.</p>
<p>As explained in <a href="https://unofficial-kubernetes.readthedocs.io/en/latest/concepts/cluster-administration/logging/#:%7E:text=Kubernetes%20uses%20the%20logrotate%20tool,for%20the%20container%20are%20lost." rel="nofollow noreferrer"><code>unofficial-kubernetes</code></a>:</p>
<blockquote>
<p>An important consideration in node-level logging is implementing log rotation, so that logs don't consume all available storage on the node. Kubernetes uses the <code>logrotate</code> tool to implement log rotation.</p>
<p>Kubernetes performs log rotation daily, or if the log file grows beyond 10MB in size.<br />
Each rotation belongs to a single container; if the container repeatedly fails or the pod is evicted, all previous rotations for the container are lost.<br />
<strong>By default, Kubernetes keeps up to five logging rotations per container</strong>.</p>
</blockquote>
|
<p>I've placed a docker compose file <strong>project.yaml</strong> at the location /etc/project/project.yaml</p>
<p>the file and well as the project directory have the same file permission, i.e. -rxwrxxrwx
but when I run docker-compose</p>
<pre><code>sudo docker-compose -f ./project.yaml up -d
</code></pre>
<p>if errors out with the following
Cannot find the file ./project.yaml</p>
<p>I have checked various times and it seems there is no permission issue. Can anyone tell why we have this problem and what would be the solution</p>
| <p>Beside using the full path, as <a href="https://stackoverflow.com/questions/73500671/docker-compose-cannot-find-the-yaml-file#comment129801726_73500671">commented</a> by <a href="https://stackoverflow.com/users/14312225/quoc9x">quoc9x</a>, double-check your current working directory when you call a command with a relative path <code>./project.yaml</code></p>
<p>If you are not in the right folder, that would explain the error message.</p>
|
<p>When deploying the app, certain environment-specific settings need to be applied to the server.xml, which cannot be applied when the container is built. Has anyone tried using a volume_mounted config file, and where would I tell tomcat the location of this custom config?</p>
| <p>To illustrate <a href="https://stackoverflow.com/users/19246531/nataraj-medayhal">Nataraj Medayhal</a>, you can find an example based on configMap on <a href="https://github.com/devlinx9/k8s_tomcat_custer" rel="nofollow noreferrer"><code>devlinx9/k8s_tomcat_custer</code></a></p>
<blockquote>
<p>The configMap is used to control the configuration of tomcat, in this we added the cluster configuration, save the following text in a file <code>configmap-tomcat.yaml</code></p>
<pre class="lang-yaml prettyprint-override"><code>apiVersion: v1
kind: ConfigMap
metadata:
name: testconfig
data:
server.xml: |
<?xml version="1.0" encoding="UTF-8"?>
<Server port="8005" shutdown="SHUTDOWN">
<Listener className="org.apache.catalina.startup.VersionLoggerListener" />
<Listener className="org.apache.catalina.core.AprLifecycleListener" SSLEngine="on" />
...
</Server>
</code></pre>
<p>Create the configMap:</p>
<pre><code>kubectl apply -f configmap-tomcat.yaml -n {namespace}
</code></pre>
</blockquote>
|
<p>I have started to learn GitOps ArgoCD. I have one basic doubt. I am unable to test ArgoCD because I do not have any Cluster. It will be so kind of you if you can clear my doubts.</p>
<ol>
<li>As an example currently I am running my deployment using <code>test:1</code> docker image. Then using Jenkins I upload <code>test:2</code> and then put <code>test:2</code> in place of <code>test:1</code> then ArgoCD detects the change and applies the new image in a cluster.
But if before I used <code>test:latest</code> then using Jenkins I uploads a new image with same name <code>test:latest</code>. What will happen now? Will ArgoCD deploy the image ( name and tag of the new and previous image are the same )</li>
</ol>
| <p>If you need automation, you can consider <a href="https://argocd-image-updater.readthedocs.io/en/latest/" rel="nofollow noreferrer"><strong>Argo CD Image Updater</strong></a>, which does include in its <a href="https://argocd-image-updater.readthedocs.io/en/latest/basics/update-strategies/" rel="nofollow noreferrer">update strategies</a>:</p>
<p><code>latest/newest-build</code> - Update to the most recently built image found in a registry</p>
<blockquote>
<p>It is important to understand, that this strategy will consider the build date of the image, and not the date of when the image was tagged or pushed to the registry.</p>
<p>If you are tagging the same image with multiple tags, these tags will have the same build date.<br />
In this case, Argo CD Image Updater will sort the tag names lexically descending and pick the last tag name of that list.</p>
<p>For example, consider an image that was tagged with the <code>f33bacd</code>, <code>dev</code> and <code>latest</code> tags.<br />
You might want to have the <code>f33bacd</code> tag set for your application, but Image Updater will pick the <code>latest</code> tag name.</p>
</blockquote>
<pre class="lang-yaml prettyprint-override"><code>argocd-image-updater.argoproj.io/image-list: myimage=some/image
argocd-image-updater.argoproj.io/myimage.update-strategy: latest
</code></pre>
|
<p>I have a spring-boot application running over Kubernetes, Now I am trying to set up a horizontal pod auto scaler.</p>
<p>I have one doubt, without modifying any autoscalar thresholds, does auto scaler check pods only when they are ready(after the readiness probe succeeds) or even when readiness is not complete.</p>
<p>Example</p>
<ul>
<li>A Java app takes 5 mins to start(i.e to complete the readiness probe)</li>
<li>During this 5 mins, CPU for this app with 100% of the CPU requests assigned</li>
<li>HPA is configured to scale if targetCPUUtilization reaches 50%</li>
<li>Now what would happen in this case when the HPA condition is satisfied but the pod is not ready yet? Will it add one more pod right away or it will first wait for pods to be ready and then starts the timer for -<strong>horizontal-pod-autoscaler-initial-readiness-delay ?</strong></li>
</ul>
<p>I am assuming answer lies in this, but not clear to me</p>
<blockquote>
<p>Due to technical constraints, the HorizontalPodAutoscaler controller
cannot exactly determine the first time a pod becomes ready when
determining whether to set aside certain CPU metrics. Instead, it
considers a Pod "not yet ready" if it's unready and transitioned to
unready within a short, configurable window of time since it started.
This value is configured with the
--horizontal-pod-autoscaler-initial-readiness-delay flag, and its default is 30 seconds. Once a pod has become ready, it considers any
transition to ready to be the first if it occurred within a longer,
configurable time since it started. This value is configured with the
--horizontal-pod-autoscaler-cpu-initialization-period flag, and its default is 5 minutes</p>
</blockquote>
<p>Also, can anyone <strong>explain horizontal-pod-autoscaler-cpu-initialization-period</strong> & <strong>horizontal-pod-autoscaler-initial-readiness-delay</strong> ? Documentation is confusing</p>
| <p>A <a href="https://github.com/jthomperoo/predictive-horizontal-pod-autoscaler" rel="nofollow noreferrer">Digital OCean Predictive Horizontal Pod Autoscaler</a> has the same kind of parameter: <a href="https://predictive-horizontal-pod-autoscaler.readthedocs.io/en/latest/reference/configuration/#cpuinitializationperiod" rel="nofollow noreferrer"><code>cpuInitializationPeriod</code></a>.</p>
<p>It rephrases what <code>--horizontal-pod-autoscaler-cpu-initialization-period</code> as:</p>
<blockquote>
<p>the period after pod start when CPU samples might be skipped.</p>
</blockquote>
<p>And for <code>horizontal-pod-autoscaler-initial-readiness-delay</code></p>
<blockquote>
<p>the period after pod start during which readiness changes will be treated as initial readiness.</p>
</blockquote>
<p>The idea is to:</p>
<ul>
<li>not trigger any scaling based on CPU change alone (because the initial <code>cpu-initialization-period</code> means the pod is still being ready, with potential CPU spike)</li>
<li>not trigger any scaling based on readiness state changes (because the initial <code>readiness-delay</code> means, even if the pod reports it is ready, that can change during that delay)</li>
</ul>
<p><a href="https://github.com/kubernetes/website/issues/12657" rel="nofollow noreferrer"><code>kubernetes/website</code> issue 12657</a> has more (mainly to confirm the original documentation is confusing).</p>
|
<p>I am not able to attach to a container in a pod. Receiving below message
Error from server (Forbidden): pods "sleep-76df4f989c-mqvnb" is forbidden: cannot exec into or attach to a privileged container</p>
<p>Could someone please let me what i am missing?</p>
| <p>This seems to be a permission (possibly <a href="https://kubernetes.io/docs/reference/access-authn-authz/rbac/" rel="nofollow noreferrer">RBAC</a>) issue.<br>
See <a href="https://kubernetes.io/docs/concepts/policy/pod-security-policy/" rel="nofollow noreferrer">Kubernetes pod security-policy</a>.</p>
<p>For instance <a href="https://github.com/gluster/gluster-kubernetes/issues/432" rel="nofollow noreferrer"><code>gluster/gluster-kubernetes</code> issue 432</a> points to <a href="https://github.com/Azure/acs-engine/pull/1961" rel="nofollow noreferrer">Azure PR 1961</a>, which disable the <code>cluster-admin</code> rights (although you can <a href="https://github.com/Azure/acs-engine/issues/2200#issuecomment-363070771" rel="nofollow noreferrer">customize/override the admission-controller flags passed to the API server</a>).</p>
<p>So it depends on the nature of your Kubernetes environment.</p>
|
<p>So I am running Django App in kubernetes pod at when trying to save an image file:</p>
<pre><code>img_obj.image.save(img_file, File(img_file_org))
</code></pre>
<p>I am getting no space left error:</p>
<pre><code> File "/code/ocr_client/management/commands/pdf_to_image.py", line 126, in handle
img_obj.image.save(img_file, File(img_file_org))
File "/opt/conda/lib/python3.7/site-packages/django/db/models/fields/files.py", line 88, in save
self.name = self.storage.save(name, content, max_length=self.field.max_length)
File "/opt/conda/lib/python3.7/site-packages/django/core/files/storage.py", line 54, in save
return self._save(name, content)
File "/opt/conda/lib/python3.7/site-packages/django/core/files/storage.py", line 274, in _save
fd = os.open(full_path, self.OS_OPEN_FLAGS, 0o666)
OSError: [Errno 28] No space left on device: '/code/pca_back_data/media/file1.png'
</code></pre>
<p>I already ran</p>
<pre><code>kubectl exec <my-pod> -- df -ah
</code></pre>
<p>And there is still 20% of the space left (100GB)</p>
<p>I also ran as suggested in other thread:</p>
<pre><code>kubectl exec <my-pod> -- df -hi
</code></pre>
<p>and the usage of inodes was only 5%</p>
<p>I am not sure what else might be the issue here?
Is there some config in Kubernetes that restricts usage of storage for a pod/process?</p>
| <p>If you are getting the "<code>No space left on device</code>" error even when the disk usage and inode usage are low, it might be that the disk resources for your specific pod are limited. The Kubernetes system can set limits on resources like CPU, memory, and disk storage.</p>
<p>So start with checking the Kubernetes resource limits and requests for your pod: run <code>kubectl describe pod <my-pod></code> to check if there are resource limits or requests set. Look for something like:</p>
<pre class="lang-yaml prettyprint-override"><code>Resources:
Limits:
ephemeral-storage: 1Gi
Requests:
ephemeral-storage: 500Mi
</code></pre>
<p>The <a href="https://docs.openshift.com/container-platform/4.13/storage/understanding-ephemeral-storage.html" rel="nofollow noreferrer"><code>ephemeral-storage</code></a> represents the storage available for your pod to use. If it is set too low, you might need to adjust it.</p>
<p>Try also to set said resource requests and limits yourself: You can specify the resources available for your pod by adding the following in your pod or deployment configuration with:</p>
<pre class="lang-yaml prettyprint-override"><code>resources:
requests:
ephemeral-storage: "1Gi"
limits:
ephemeral-storage: "2Gi"
</code></pre>
<p>That allows your pod to request 1 GiB of ephemeral storage and limit it to using 2 GiB. Adjust these values as needed based on the size of the images you are dealing with.</p>
<hr />
<p>But another approach would be to consider using Persistent Volumes (PV): If your application needs to store a lot of data (like many large image files), consider using a <a href="https://kubernetes.io/docs/concepts/storage/persistent-volumes/" rel="nofollow noreferrer">Persistent Volume (PV) and Persistent Volume Claim (PVC)</a>. PVs represent physical storage in a cluster and can be used to provision durable storage resources. You would need to change your application's code or configuration to write to this PV.</p>
<p>Define a PV and PVC:</p>
<pre class="lang-yaml prettyprint-override"><code>apiVersion: v1
kind: PersistentVolume
metadata:
name: my-pv
spec:
capacity:
storage: 10Gi
accessModes:
- ReadWriteOnce
hostPath:
path: "/mnt/data"
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: my-pvc
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 10Gi
</code></pre>
<p>And in your pod spec, you would add:</p>
<pre class="lang-yaml prettyprint-override"><code>volumes:
- name: my-storage
persistentVolumeClaim:
claimName: my-pvc
</code></pre>
<p>And mount it into your pod:</p>
<pre class="lang-yaml prettyprint-override"><code>volumeMounts:
- mountPath: "/code/pca_back_data/media"
name: my-storage
</code></pre>
<p>When you create the Persistent Volume (PV) and mount it into your pod at the same location (<code>/code/pca_back_data/media</code>), your application will continue to write to the same directory without needing to change the Django settings.</p>
<p>The only difference is that the storage will now be backed by a Persistent Volume which is designed to handle larger amounts of data and will not be subject to the same restrictions as the pod's ephemeral storage.</p>
<p>In that case, no changes would be required in your Django settings. The application would continue to write to the same path but the underlying storage mechanism would have changed.</p>
<p>However, do note that <code>hostPath</code> should be used only for development or testing. For production, consider using a networked storage like an NFS server, or a cloud provider's storage service.</p>
<hr />
<blockquote>
<p>I am already using PVC that is attached to this pod. And it has more than enough storage. What is stranger is that not all files are failing this… –</p>
</blockquote>
<p>As I commented, it could be a concurrency issue: If multiple processes or threads are trying to write to the same file or location simultaneously, that might cause some operations to fail with "<code>No space left on device</code>" errors.<br />
Also, Although the PVC has enough available space, individual filesystems on the PVC might have quotas that limit how much space they can use. Check if there are any such quotas set on your filesystem.</p>
<p>The OP confirms:</p>
<blockquote>
<p>There is something like this happening - multiple processes are using the same PVC directory, maybe not exactly same file but same parent directory can be accessed by those processes.</p>
</blockquote>
<p>Multiple processes using the same PVC directory or parent directory should generally not be a problem, as long as they are not trying to write to the same file at the same time. But if these processes are creating a large number of files or very large files, and if your PVC or underlying filesystem has a limit on the number of files (inodes) or the total size of files it can handle, that could potentially lead to the "No space left on device" error.</p>
<p>You can check for filesystem quotas on a PVC:</p>
<ul>
<li><p>Connect to your pod: <code>kubectl exec -it <your-pod> -- /bin/bash</code></p>
</li>
<li><p>Install the <code>quota</code> package: This can usually be done with <a href="https://doc.ubuntu-fr.org/quota" rel="nofollow noreferrer"><code>apt-get install quota</code></a> on Debian/Ubuntu systems or <code>yum install quota</code> on CentOS/RHEL systems. If these commands do not work, you may need to look up how to install <code>quota</code> for your specific container's operating system.</p>
</li>
<li><p>Check quotas: Run <code>quota -v</code> to view quota information. If quotas are enabled and you are nearing or at the limit, you will see that here.</p>
</li>
</ul>
<p>If your filesystem does not support quotas or they are not enabled, you will not get useful output from <code>quota -v</code>. In that case, or if you are unable to install the <code>quota</code> package, you might need to check for quotas from outside the pod, which would depend on your Kubernetes setup and cloud provider.</p>
<p>If you are still having trouble, another possible culprit could be a Linux kernel parameter called <a href="https://unix.stackexchange.com/q/444998/7490"><code>fs.inotify.max_user_watches</code></a>, which can limit the number of files the system can monitor for changes. If you are opening and not properly closing a large number of files, you could be hitting this limit. You can check its value with <code>cat /proc/sys/fs/inotify/max_user_watches</code> and increase it if necessary.</p>
<hr />
<p>The OP adds:</p>
<blockquote>
<p>I think the issue in my case is that <code>/tmp</code> folder inside the pod is running out of space (in Django <code>/tmp</code> is used for the files when saving to database if I understand correctly), not sure how to expand size of it?</p>
</blockquote>
<p>Yes, you're correct. Django, like many other systems, uses the <code>/tmp</code> directory to handle temporary files, which includes processing file uploads. If the <code>/tmp</code> directory is running out of space, you can consider the following options:</p>
<ul>
<li>Increase the Pod ephemeral storage limit: as mentioned above, you can adjust the ephemeral storage requests and limits in your pod or deployment configuration, like so:</li>
</ul>
<pre class="lang-yaml prettyprint-override"><code>resources:
requests:
ephemeral-storage: "2Gi" # Request 2Gi of ephemeral storage
limits:
ephemeral-storage: "4Gi" # Limit ephemeral storage usage to 4Gi
</code></pre>
<p>Remember to adjust these values according to your needs.</p>
<ul>
<li>Or use an <code>emptyDir</code> Volume for <code>/tmp</code>: meaning use a Kubernetes <code>emptyDir</code> volume for your <code>/tmp</code> directory. When a Pod is assigned to a Node, Kubernetes will create an <code>emptyDir</code> volume for that Pod, and it will exist as long as that Pod is running on that node. The <code>emptyDir</code> volume can use the node's storage space, and you can specify a size limit.</li>
</ul>
<p>Here is how you might define an <code>emptyDir</code> volume for <code>/tmp</code>:</p>
<pre class="lang-yaml prettyprint-override"><code>apiVersion: v1
kind: Pod
metadata:
name: my-pod
spec:
containers:
- name: my-container
image: my-image
volumeMounts:
- name: tmp-storage
mountPath: /tmp
volumes:
- name: tmp-storage
emptyDir:
medium: "Memory"
sizeLimit: "2Gi" # Set a size limit for the volume
</code></pre>
<p>The <code>medium: "Memory"</code> means that the <code>emptyDir</code> volume is backed by memory (tmpfs) instead of disk storage. If you remove this line, the <code>emptyDir</code> volume will use disk storage. The <code>sizeLimit</code> is optional.</p>
<ul>
<li>You can also consider using a dedicated PVC for <code>/tmp</code>: If the above options are not feasible or if you need more control over the storage for <code>/tmp</code>, you can also use a dedicated PVC for it, similar to the one you're using for <code>/code/pca_back_data/media</code>.</li>
</ul>
<p>Remember that changes to your pod or deployment configuration need to be applied with <code>kubectl apply -f <configuration-file></code>, and you may need to recreate your pod or deployment for the changes to take effect.</p>
<hr />
<p>The OP concludes in <a href="https://stackoverflow.com/questions/76570871/django-on-kubernetes-pod-no-space-left-on-device/76636516?noredirect=1#comment135345270_76636516">the comments</a>:</p>
<blockquote>
<p>I managed to solve this issue: looks like the GCP storage disc was somehow corrupted and we changed to another and it seems to be fine now.</p>
</blockquote>
|
<p>I have node.js application that I need to deploy to exising kubernetes cluster.</p>
<p>The cluster is setup using <code>kops</code> on AWS.</p>
<p>I have created <code>.gitlab-ci.yml</code> file for building docker images.</p>
<p>So, whenever a change is pushed to either <code>master</code> or <code>develop</code> branch. It will build the docker image.</p>
<p>I have already followed steps defined <a href="https://docs.gitlab.com/ee/user/project/clusters/add_remove_clusters.html#existing-kubernetes-cluster" rel="nofollow noreferrer">here</a> to add an existing cluster.</p>
<p>Now, I have to roll update to exisitng kubernetes cluster..</p>
<pre><code># This file is a template, and might need editing before it works on your project.
docker-build-master:
# Official docker image.
image: docker:latest
stage: build
services:
- docker:dind
before_script:
- docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY
script:
- docker build --pull -t "$CI_REGISTRY_IMAGE:prod" .
- docker push "$CI_REGISTRY_IMAGE:prod"
only:
- master
docker-build-dev:
# Official docker image.
image: docker:latest
stage: build
services:
- docker:dind
before_script:
- docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY
script:
- docker build --pull -t "$CI_REGISTRY_IMAGE:dev" .
- docker push "$CI_REGISTRY_IMAGE:dev"
only:
- develop
</code></pre>
<p>For now, I am using shared runner.</p>
<p><em>How can I integrate kubernetes deployment after image is built with gitlab ci/cd to deploy on aws (cluster is created with kops)?</em></p>
<p><em>For registry I am using gitlab's container registry not docker hub.</em></p>
<p><strong>Update</strong></p>
<p>I changed configuration and doing below,</p>
<pre><code>stages:
- docker-build
- deploy
docker-build-master:
image: docker:latest
stage: docker-build
services:
- docker:dind
before_script:
- docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY
script:
- docker build --pull -t "$CI_REGISTRY_IMAGE:prod" .
- docker push "$CI_REGISTRY_IMAGE:prod"
only:
- master
deploy-prod:
stage: deploy
image: roffe/kubectl
script:
- kubectl apply -f scheduler-deployment.yaml
only:
- master
docker-build-dev:
image: docker:latest
stage: docker-build
services:
- docker:dind
before_script:
- docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY
script:
- docker build --pull -t "$CI_REGISTRY_IMAGE:dev" .
- docker push "$CI_REGISTRY_IMAGE:dev"
only:
- develop
</code></pre>
<p>But now I am getting below error.</p>
<pre><code>roffe/kubectl with digest roffe/kubectl@sha256:ba13f8ffc55c83a7ca98a6e1337689fad8a5df418cb160fa1a741c80f42979bf ...
$ kubectl apply -f scheduler-deployment.yaml
error: the path "scheduler-deployment.yaml" does not exist
Cleaning up file based variables
00:01
ERROR: Job failed: exit code 1
</code></pre>
<p>File <code>scheduler-deployment.yaml</code> does exist in the root directory.</p>
| <blockquote>
<p>I suggest using Flux for deploying rather than invoking kubectl as part of the pipeline,</p>
</blockquote>
<p>That would be true because:</p>
<ul>
<li><p>the traditional <a href="https://docs.gitlab.com/ee/user/clusters/agent/gitops/agent.html" rel="nofollow noreferrer">GitOps with the agent for Kubernetes</a> has been deprecated with GitLab 16.2 (July 2023), and <a href="https://docs.gitlab.com/ee/user/clusters/agent/gitops.html" rel="nofollow noreferrer">replaced with Flux</a>, as shown <a href="https://docs.gitlab.com/ee/user/clusters/agent/gitops/flux_tutorial.html" rel="nofollow noreferrer">in this tutorial</a>.</p>
</li>
<li><p><a href="https://about.gitlab.com/releases/2023/08/22/gitlab-16-3-released/#flux-sync-status-visualization" rel="nofollow noreferrer">GitLab 16.3</a> (August 2023) adds:</p>
<blockquote>
<h2>Flux sync status visualization</h2>
<p>In previous releases, you probably used <code>kubectl</code> or another third-party tool to check the status of your Flux deployments. From GitLab 16.3, you can check your deployments with the environments UI.</p>
<p>Deployments rely on Flux <code>Kustomization</code> and <code>HelmRelease</code> resources to gather the status of a given environment, which requires a namespace to be configured for the environment. By default, GitLab searches the <code>Kustomization</code> and <code>HelmRelease</code> resources for the name of the project slug. You can customize the name GitLab looks for in the environment settings.</p>
<p><a href="https://i.stack.imgur.com/9hhlp.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/9hhlp.png" alt="https://about.gitlab.com/images/16_3/flux-badges.png -- Flux sync status visualization" /></a></p>
<p>See <a href="https://docs.gitlab.com/ee/ci/environments/kubernetes_dashboard.html#flux-sync-status" rel="nofollow noreferrer">Documentation</a> and <a href="https://gitlab.com/gitlab-org/gitlab/-/issues/391581" rel="nofollow noreferrer">Issue</a>.</p>
</blockquote>
</li>
</ul>
|
<p>I have a couple of client applications. For each one I have a build pipeline that gets latest code, compiles it and plots the result to a <code>dist</code> folder (containing only html and js files).</p>
<p>These <code>dist</code> folders are synced, using docker volume, to a web server (<code>nginx</code>) container which actually hosts the client application.</p>
<p>The result is that my client is always "up" and I only need to update the <code>dist</code> folder of any client to deploy it, and never need to mess with the web server container.</p>
<p>However, I want to move my deployment to a different approach, of only building the docker images on pipelines (code change) and using them on demand whenever deploying an environment.</p>
<p>The problem would be how to build the web server container while I don't want to rebuild all clients on any change, nor do I want to store the built output in source control. What would be the best approach?</p>
| <p>You could consider a <a href="https://docs.docker.com/develop/develop-images/multistage-build/" rel="nofollow noreferrer">multi-stage build</a> with:</p>
<ul>
<li>the first stage being the build of your web server (which never change, so it is cached)</li>
<li>the second stage being the build of your dist folder, to which image you add the web server of the first stage.</li>
</ul>
<p>The end result is an image with both the web server and the static files to serve (instead of those files being in a volume), with only the static files being rebuilt.</p>
|
<p>Currently, I have two microservices. I want to send message to KubeMQ Queue from first microservice and want it to be received by Second microservice. I am able to send message to a KubeMQ Queue using below code:</p>
<pre><code>Queue queue = new Queue("QueueName", "ClientID", "localhost:50000");
SendMessageResult resSend = queue.SendQueueMessage(new Message()
.setBody(Converter.ToByteArray("some-simple_queue-queue-message"))
.setMetadata("someMeta"));
if (resSend.getIsError()) {
System.out.printf("Message enqueue error, error: %s", resSend.getError());
}
</code></pre>
<p>I need Listener in the second microservice in order to receive the message from Queue.
Below is code provided by KubeMQ to receive the message:</p>
<pre><code> Queue queue = new Queue("QueueName", "ClientID", "localhost:50000");
ReceiveMessagesResponse resRec = queue.ReceiveQueueMessages(10, 1);
if (resRec.getIsError()) {
System.out.printf("Message dequeue error, error: %s", resRec.getError());
return;
}
System.out.printf("Received Messages %s:", resRec.getMessagesReceived());
for (Message msg : resRec.getMessages()) {
System.out.printf("MessageID: %s, Body:%s", msg.getMessageID(), Converter.FromByteArray(msg.getBody()));
}
</code></pre>
<p>How to configure it in the second microservice to receive message instantly as they are added into the queue?</p>
<p>Please help.</p>
| <blockquote>
<p>I need a Listener in the second microservice in order to receive the message from Queue.</p>
</blockquote>
<p>Why polling, when you can be notified through the <a href="https://docs.kubemq.io/learn/message-patterns/pubsub" rel="nofollow noreferrer">KubeMQ Pub/Sub pattern</a>?</p>
<p><a href="https://i.stack.imgur.com/0Y2hd.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/0Y2hd.png" alt="https://3720647888-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M2b9dwAGbMPWty0fPGr%2F-M2cg-nL53EVg5rPnOZB%2F-M2chJWo9-utUu1Q8v2C%2Fpubsub.png?alt=media&token=e003b332-df67-4ffb-be81-6b9218cefc4e" /></a></p>
<p>In the context of message queues, "polling" refers to a process where your application continually checks the queue to see if a new message has arrived. This can be inefficient, as it requires your application to make many requests when there may not be any new messages to process.</p>
<p>On the other hand, a "listener" (also known as a subscriber or a callback) is a function that is automatically called when a new message arrives. This is more efficient because your application does not need to continually check the queue; instead, it can wait and react when a message arrives.</p>
<hr />
<p>The Publish-Subscribe pattern (or pub/sub) is a messaging pattern supported by KubeMQ, and it differs slightly from the queue-based pattern you are currently using.<br />
In the pub/sub pattern, senders of messages (publishers) do not program the messages to be sent directly to specific receivers (subscribers). Instead, the programmer “publishes” messages (events), without any knowledge of any subscribers there may be. Similarly, subscribers express interest in one or more events and only receive messages that are of interest, without any knowledge of any publishers.</p>
<p>In this pattern, KubeMQ provides two types of event handling, <code>Events</code> and <code>Events Store</code>.</p>
<ul>
<li><p>The <code>Events</code> type is an asynchronous real-time Pub/Sub pattern, meaning that messages are sent and received in real-time but only if the receiver is currently connected to KubeMQ. There is no message persistence available in this pattern.</p>
</li>
<li><p>The <code>Events Store</code> type, however, is an asynchronous Pub/Sub pattern with persistence. This means that messages are stored and can be replayed by any receiver, even if they were not connected at the time the message was sent.<br />
The system also supports replaying all events from the first stored event, replaying only the last event, or only sending new events.</p>
</li>
</ul>
<p>However, it is important to note that the uniqueness of a client ID is essential when using Events Store.<br />
At any given time, only one receiver can connect with a unique Client ID.<br />
If two receivers try to connect to KubeMQ with the same Client ID, one of them will be rejected. Messages can only be replayed once per Client ID and Subscription type. If a receiver disconnects and reconnects with any subscription type, only new events will be delivered for this specific receiver with that Client ID. To replay messages, a receiver needs to connect with a different Client ID.</p>
<p>Given these features, if you switch your architecture to a pub/sub pattern using the Events Store type, your second microservice could instantly receive messages as they are added into the channel, and even replay old messages if needed. You would need to ensure each microservice has a unique Client ID and manages its subscriptions appropriately.</p>
<p>However, the pub/sub pattern may require changes in the architecture and coding of your microservices, so you would need to evaluate whether this change is suitable for your use case. It is also important to note that the pub/sub pattern, especially with message persistence, may have different performance characteristics and resource requirements compared to the queue pattern.</p>
<hr />
<p>Here is a high-level overview of the classes that are present and their usage:</p>
<ol>
<li><p><code>Channel.java</code>: This class appears to represent a channel for sending events in a publish-subscribe model.</p>
</li>
<li><p><code>ChannelParameters.java</code>: This class defines the parameters for creating a Channel instance.</p>
</li>
<li><p><code>Event.java</code>: This class represents an event that can be sent via a Channel.</p>
</li>
<li><p><code>EventReceive.java</code>: This class is used to process received events.</p>
</li>
<li><p><code>Result.java</code>: This class contains the result of a sent event.</p>
</li>
<li><p><code>Subscriber.java</code>: This class allows you to subscribe to a channel and handle incoming events.</p>
</li>
</ol>
<p>So here is an example of how you might use the existing classes to publish and subscribe to messages.</p>
<pre class="lang-java prettyprint-override"><code>import io.kubemq.sdk.Channel;
import io.kubemq.sdk.ChannelParameters;
import io.kubemq.sdk.Result;
import io.kubemq.sdk.event.Event;
import io.kubemq.sdk.event.Subscriber;
public class KubeMQExample {
public static void main(String[] args) {
try {
// Initialize ChannelParameters
ChannelParameters params = new ChannelParameters();
params.setChannel("your_channel");
params.setClient("your_client_id");
// Initialize a new Channel
Channel channel = new Channel(params);
// Create a new Event
Event event = new Event();
event.setBody("Your message here".getBytes());
// Send the Event
Result sendResult = channel.SendEvent(event);
System.out.println("Event sent, Result: " + sendResult.getIsError());
// Initialize a new Subscriber
Subscriber subscriber = new Subscriber("localhost:5000");
// Subscribe to the Channel
subscriber.SubscribeToEvents(params, (eventReceive) -> {
System.out.println("Received Event: " + new String(eventReceive.getBody()));
});
} catch (Exception e) {
e.printStackTrace();
}
}
}
</code></pre>
<p>Do note that this code is based on the existing SDK and may not reflect the functionality of the original code. You will need to replace "<code>your_channel</code>" and "<code>your_client_id</code>" with your actual channel name and client ID. The event body can also be replaced with the actual message you want to send.</p>
<p>The <code>Subscriber</code> class is used here to listen for and process incoming events. The <code>SubscribeToEvents</code> method takes a <code>ChannelParameters</code> object and a lambda function that processes received events.</p>
<p>Do also note that the <code>Queue</code> and <code>EventsStore</code> classes seem to have been removed from the SDK. The SDK now seems to primarily use the publish-subscribe model, which differs from queue-based communication in that messages are not stored if no consumer is available to consume them.<br />
Events Store was a hybrid model that allowed for persistence in the pub/sub model, storing events that could be replayed by receivers connecting at a later time.</p>
<p>For your original functionality of reading queue messages and peeking at messages in a queue, unfortunately, it does not seem like the current state of the Kubemq Java SDK on the provided GitHub repository supports these actions.</p>
|
<p>Hi I am at a loss when it comes to configuring OIDC (Keycloak) with MinIO (both are deployed on same AKS cluster). I have configured an Ingress for both, both use the same wildcard cert that I got from DigiCert. However, whenever I got to configure OIDC (either via Helm values or manually in the console) I get the following error:</p>
<pre><code>Get "https://<FQDN_KEYCLOAK>/realms/master/.well-known/openid-configuration": tls: failed to verify certificate: x509: certificate signed by unknown authority
</code></pre>
<p>I tried to manually mount the tls secret into <code>/etc/minio/certs</code> on the MinIO pod but same error. Any suggestions? Thanks</p>
<p><strong>UPDATE</strong>: I get the same exception when integrating Keycloak (OIDC) with ArgoCD.</p>
| <p>Since you have an error "<code>TLS: failed to verify certificate: x509: certificate signed by unknown authority</code>", that should mean that the certificate used by the Keycloak server is not trusted by the system where MinIO and ArgoCD are running.</p>
<p>You should make sure the certificate authority (CA) that signed your certificate is trusted by the MinIO and ArgoCD systems. Since you mentioned that you are using a certificate from DigiCert, it is strange that it is not recognized, as DigiCert is a well-known CA.</p>
<p>First, check that the certificate is correctly installed on the Keycloak server. You can verify the certificate installation using tools like <a href="https://www.openssl.org/" rel="nofollow noreferrer">OpenSSL</a> or <a href="https://www.digicert.com/help/" rel="nofollow noreferrer">online SSL checkers</a>.</p>
<pre class="lang-bash prettyprint-override"><code>openssl s_client -connect <FQDN_KEYCLOAK>:443 -showcerts
</code></pre>
<p>When you run this command, look for the "Certificate chain" section in the output. If you see one, then make sure the certificates for all levels in the chain are present and correctly <a href="https://www.keycloak.org/server/enabletls" rel="nofollow noreferrer">configured in your server configuration, which, in this case, is Keycloak</a>.<br />
The certificates must be concatenated in a single file (<code>https-certificate-file</code>), with the server's certificate first, then the intermediate certificate(s), and finally the root certificate, to form a complete chain.</p>
<p>Update the certificate trust store on the <a href="https://min.io/docs/minio/linux/operations/network-encryption.html" rel="nofollow noreferrer">MinIO</a> and <a href="https://argo-cd.readthedocs.io/en/stable/operator-manual/tls/" rel="nofollow noreferrer">ArgoCD</a> systems to include the CA certificate that signed your Keycloak certificate.</p>
<ul>
<li><p>For MinIO, you need to correctly configure it to trust your CA certificate. You may add your certificate to the system trust store, or configure MinIO to use a custom CA certificate:</p>
<pre><code>mkdir -p /root/.minio/certs/CAs/
cp your-root-ca.crt /root/.minio/certs/CAs/
</code></pre>
<p>Restart the MinIO server after adding the certificates.</p>
</li>
<li><p>Similar to MinIO, for ArgoCD, update the trust store to include your CA certificate.</p>
</li>
</ul>
<p>All this assumes that the FQDN specified in the error message resolves correctly to your Keycloak server and that there are no network issues preventing connectivity.</p>
<p>You can use <code>curl</code> to test the certificate validation manually:</p>
<pre><code>curl -v https://<FQDN_KEYCLOAK>/realms/master/.well-known/openid-configuration --cacert /path/to/your/ca/cert.pem
</code></pre>
<p>If curl command succeeds without certificate errors, it indicates the certificate is correctly installed and trusted.</p>
<hr />
<blockquote>
<p>This is a very strange error, as I have configured both of these services with Keycloak in other K8s environments, it appears to just be this one (running on AKS).</p>
<p>The certs are definitely installed in Keycloak using the Bitnami chart, and that curl command did not return a cert error (both using the above with Keycloak and using the FQDN of argo).</p>
</blockquote>
<p>Since you have successfully configured these services in other Kubernetes environments and are experiencing issues only in this specific AKS cluster, the issue should be specific to this particular AKS environment or the certificates involved. The successful <code>curl</code> command test is a strong indicator that the certificates on the Keycloak server are correctly installed and accessible from within the cluster.</p>
<p>So check aks-specific configurations: AKS might have some specific security policies or networking configurations that affect TLS verification. Confirm that there are no such configurations that may be interfering with the connection to Keycloak.</p>
<p>And review mounted certificates in pods: Inspect MinIO and ArgoCD pods to see whether the CA certificates are correctly mounted and accessible.</p>
<pre class="lang-bash prettyprint-override"><code>kubectl exec -it <pod_name> -n <namespace> -- /bin/sh
ls /etc/minio/certs/CAs/ # or corresponding path
</code></pre>
<p>Make sure that there are no Kubernetes network policies or Azure-specific firewall rules that may be interfering with the certificate verification process.<br />
For instance, use <code>curl</code> from inside other pods in the cluster to rule out any network issues specific to MinIO or ArgoCD.</p>
<pre class="lang-bash prettyprint-override"><code>kubectl run --rm -i --tty --image=busybox testpod -- sh
wget --ca-cert=/path/to/ca.crt https://<FQDN_KEYCLOAK>/realms/master/.well-known/openid-configuration
</code></pre>
<hr />
<p>The <a href="https://stackoverflow.com/users/1314147/user1314147">OP</a> adds in <a href="https://stackoverflow.com/questions/77092098/minio-openid-keycloak-on-aks-failed-to-verify-tls/77141650#comment136118029_77141650">the comments</a>:</p>
<blockquote>
<p>I ended up figuring it out, it was due to 2 issues:</p>
<ul>
<li>I was trying to use one wildcar cert for <code>auth.<BASE_URL></code> and <code>argo.<BASE_URL></code>, switched to using letsencrypt and</li>
<li>I needed to concert the certs to PEM format and mount to <code>/opt/bitnami/keycloak/certs</code></li>
</ul>
</blockquote>
<p>True:</p>
<h2>Use of a single wildcard certificate:</h2>
<ul>
<li><p><a href="https://en.wikipedia.org/wiki/Wildcard_certificate" rel="nofollow noreferrer">Wildcard certificates</a> can be convenient for securing multiple subdomains under a single base domain.<br />
However, depending on the issuing Certificate Authority (CA) and the applications involved, wildcard certificates may not always work seamlessly. And using a single certificate for multiple services can sometimes introduce complexities or limitations.</p>
</li>
<li><p>By opting for Let's Encrypt, you could easily issue separate certificates for each subdomain (<code>auth.<BASE_URL></code> and <code>argo.<BASE_URL></code>), isolating each service's SSL configuration.<br />
That is generally easier to manage and troubleshoot. Let's Encrypt's automation features can also streamline the renewal process, further reducing maintenance overhead.</p>
</li>
</ul>
<h2>Conversion to PEM format:</h2>
<p>Certificates can come in <a href="https://en.wikipedia.org/wiki/X.509#Certificate_filename_extensions" rel="nofollow noreferrer">various formats</a> like DER, PEM, PFX, etc. The applications involved (in this case, Bitnami's Keycloak chart) might expect the certificates to be in a particular format.</p>
<ul>
<li><p>PEM (Privacy-Enhanced Mail) is one of the most commonly used certificate formats, recognizable by the <code>-----BEGIN CERTIFICATE-----</code> and <code>-----END CERTIFICATE-----</code> delimiters. Not all software can read all formats, so converting to PEM is often necessary for compatibility.</p>
</li>
<li><p>Mounting to <code>/opt/bitnami/keycloak/certs</code>: That is specific to the <a href="https://github.com/bitnami/charts/tree/main/bitnami/keycloak" rel="nofollow noreferrer">Bitnami Keycloak Helm chart</a>. Helm charts usually define specific paths where they expect to find configurations or certificates. You needed to make sure the PEM-formatted certificates were placed in this specific directory for Keycloak to use them properly.</p>
</li>
</ul>
|
<p>I tried following the instructions from the official documentation page of "<strong>Operator SDK</strong>". The device I'm trying to install it on is running on Windows 10, AMD64. I installed GNU Make via Chocolatey.</p>
<pre><code> make --version
GNU Make 4.4.1
Built for Windows32
Copyright (C) 1988-2023 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
</code></pre>
<p>As per the "<a href="https://sdk.operatorframework.io/docs/installation/#compile-and-install-from-master" rel="nofollow noreferrer">Command and install from master</a>" section of the official documentation:</p>
<pre><code>git clone https://github.com/operator-framework/operator-sdk
cd operator-sdk
git checkout master
make install
</code></pre>
<p>The last line "make install" fails:</p>
<pre><code>make install
go install -gcflags "all=-trimpath=C:/Users/erjan/Downloads/operator_k8s_sdk" -asmflags "all=-trimpath=C:/Users/erjan/Downloads/operator_k8s_sdk" -ldflags " -X 'github.com/operator-framework/operator-sdk/internal/version.Version=v1.31.0+git' -X 'github.com/operator-framework/operator-sdk/internal/version.GitVersion=v1.31.0-3-gd21ed649' -X 'github.com/operator-framework/operator-sdk/internal/version.GitCommit=d21ed6499ebfc8ecdb4508e1c2a2a0cfd2a151f3' -X 'github.com/operator-framework/operator-sdk/internal/version.KubernetesVersion=v1.26.0' -X 'github.com/operator-framework/operator-sdk/internal/version.ImageVersion=v1.31.0' " ./cmd/# github.com/containerd/containerd/archive
..\..\..\go\pkg\mod\github.com\containerd\[email protected]\archive\tar_windows.go:234:19: cannot use syscall.NsecToFiletime(hdr.AccessTime.UnixNano()) (value of type syscall.Filetime) as "golang.org/x/sys/windows".Filetime value in struct literal
..\..\..\go\pkg\mod\github.com\containerd\[email protected]\archive\tar_windows.go:235:19: cannot use syscall.NsecToFiletime(hdr.ModTime.UnixNano()) (value of type syscall.Filetime) as "golang.org/x/sys/windows".Filetime value in struct literal
..\..\..\go\pkg\mod\github.com\containerd\[email protected]\archive\tar_windows.go:236:19: cannot use syscall.NsecToFiletime(hdr.ChangeTime.UnixNano()) (value of type syscall.Filetime) as "golang.org/x/sys/windows".Filetime value in struct literal
..\..\..\go\pkg\mod\github.com\containerd\[email protected]\archive\tar_windows.go:239:17: cannot use syscall.NsecToFiletime(hdr.ModTime.UnixNano()) (value of type syscall.Filetime) as "golang.org/x/sys/windows".Filetime value in struct literal
..\..\..\go\pkg\mod\github.com\containerd\[email protected]\archive\tar_windows.go:257:27: cannot use syscall.NsecToFiletime(createTime.UnixNano()) (value of type syscall.Filetime) as "golang.org/x/sys/windows".Filetime value in assignment
make: *** [Makefile:75: install] Error 1
</code></pre>
<p>What could be the reason for this error?</p>
| <p>I see there are several lines where Go is complaining about a type mismatch. Specifically, it is mentioning that <code>syscall.Filetime</code> cannot be used as <code>"golang.org/x/sys/windows".Filetime</code>.</p>
<pre><code>..\..\..\go\pkg\mod\github.com\containerd\[email protected]\archive\tar_windows.go:234:19: cannot use syscall.NsecToFiletime(hdr.AccessTime.UnixNano()) (value of type syscall.Filetime) as "golang.org/x/sys/windows".Filetime value in struct literal
</code></pre>
<p>A value of type <code>syscall.Filetime</code> is being used where a value of type <code>"golang.org/x/sys/windows".Filetime</code> is expected. This is a type mismatch issue. The file <code>tar_windows.go</code> within the <code>github.com/containerd/containerd</code> package seems to be the source of these errors, and it appears to be related to how file timestamps are being handled on Windows.</p>
<p><a href="https://github.com/containerd/containerd/releases/tag/v1.4.11" rel="nofollow noreferrer"><code>containerd/containerd</code> v1.4.11</a> seems quite old, considering the <a href="https://github.com/operator-framework/operator-sdk/blob/d21ed6499ebfc8ecdb4508e1c2a2a0cfd2a151f3/go.mod#L72" rel="nofollow noreferrer">operator-framework/operator-sdk</a> project itself needs <a href="https://github.com/containerd/containerd/releases/tag/v1.7.0" rel="nofollow noreferrer"><code>containerd</code> v1.7.0</a></p>
<p>Since I got the same error through <code>make install</code>, I tried first <code>go build -a -v ...</code>, which does not trigger errors.
The Makefile fails on <code>go install ./cmd/{operator-sdk,helm-operator}</code></p>
<ul>
<li><code>go install ./cmd/helm-operator</code> works.</li>
<li><code>go install ./cmd/operator-sdk</code> has the error</li>
</ul>
<p>That bug is confirmed with your issue <a href="https://github.com/operator-framework/operator-sdk/issues/6585" rel="nofollow noreferrer"><code>operator-framework/operator-sdk</code> issue 6585</a></p>
<blockquote>
<p>We do not officially support or build binaries for windows. But we are open to receiving any help with contributions.<br />
Duplicate of <a href="https://github.com/operator-framework/operator-sdk/issues/6586" rel="nofollow noreferrer">#6586</a></p>
<p>Operator SDK <a href="https://sdk.operatorframework.io/docs/overview/#platform-support" rel="nofollow noreferrer">doesn't officially support or build binaries for Windows</a>.</p>
<p>However, there have been instances where users could still build SDK binary from master on their windows machines. This error seems to be coming from <code>github.com\containerd\[email protected]</code>.<br />
Looks like it may have an issue. Also, we have explicitly pinned <code>containerd</code> to 1.4.11:</p>
<p><a href="https://github.com/operator-framework/operator-sdk/blob/d21ed6499ebfc8ecdb4508e1c2a2a0cfd2a151f3/go.mod#L243" rel="nofollow noreferrer">operator-sdk/go.mod</a>:</p>
<pre><code>github.com/containerd/containerd => github.com/containerd/containerd v1.4.11
</code></pre>
<p>because a bump in it breaks github.com/deislabs/oras.</p>
<p>I would suggest to start by checking if a bump in dependencies fixes these issues without breaking anything else in SDK. If so, we can merge that in master to fix it. Unfortunately, supporting windows builds has not been in our roadmap, but if you would like to try it out, we would appreciate any contributions.</p>
</blockquote>
|
<p>i am trying to create a Kubernetes cluster with the intention of hosting a docker registry, but after installing kubectl (via homebrew on Mac) along with minikube i am getting <code>The connection to the server localhost:8080 was refused - did you specify the right host or port?</code> when i run <code>kubectl version</code> or any other commands. I have previously used the docker desktop app with Kubernetes so don't know if there is any config i need to replace?</p>
<p>I have discovered there is no context set in the kubectl config but if i run <code>kubectl config get-contexts</code> there is nothing there.</p>
| <p><a href="https://discuss.kubernetes.io/t/the-connection-to-the-server-localhost-8080-was-refused-did-you-specify-the-right-host-or-port/1464/9" rel="nofollow noreferrer">This thread</a> mentions:</p>
<blockquote>
<p>That error should only come up if you have no contexts configured in your client.<br />
If you run <code>kubectl config view</code> and you get something like this:</p>
<pre><code>$ kubectl config view
apiVersion: v1
clusters: []
contexts: []
current-context: ""
kind: Config
preferences: {}
users: []
</code></pre>
<p>Then no contexts are configured.</p>
</blockquote>
<p>And:</p>
<blockquote>
<p>Getting <code>kubectl</code> to run really depends on how you installed it.<br />
Basically, if you install and have a proper config file, it should always work.</p>
<p>So, either an old file from a previous installation is there or something silly like that (although usually difficult to spot).</p>
<p>Also, make sure the commands don’t fail (some on the post pasted that the step to copy the <code>kubectl config</code> failed). That is the way to authorize to the cluster, so it won’t never work if that step doesn’t work</p>
</blockquote>
<p>Example of possible resolution:</p>
<pre class="lang-bash prettyprint-override"><code>mkdir -p $HOME/.kube
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/config
export KUBECONFIG=$HOME/.kube/config
kubectl get nodes
</code></pre>
<p>(From "<a href="https://kubernetes.io/docs/setup/production-environment/tools/kubeadm/create-cluster-kubeadm/#more-information" rel="nofollow noreferrer">Creating a cluster with <code>kubeadm</code></a>")</p>
|
<p>I'm facing an issue with <a href="https://github.com/oauth2-proxy/manifests/tree/main/helm/oauth2-proxy" rel="nofollow noreferrer">oauth2 proxy</a> and Ingress Nginx (with the latest versions) in a Kubernetes cluster where the <code>X-Auth-Request</code> headers are not being passed through to the client during the standard oauth authentication flow. I'm specifically using Azure as the auth provider.</p>
<p>Here's the relevant portion of my oauth Proxy configuration:</p>
<pre><code>pass_access_token = true
pass_authorization_header = true
pass_user_headers = true
set_xauthrequest = true
</code></pre>
<p>When I explicitly call <code>/oauth2/auth</code>, I get the headers as expected. However, during the standard OAuth2 auth flow, none of the headers are returned with any request.</p>
<p>This situation is somewhat similar to another question here: <a href="https://stackoverflow.com/questions/64666156/oauth2-proxy-do-not-pass-x-auth-request-groups-header">Oauth2-Proxy do not pass X-Auth-Request-Groups header</a>, but in my case, I'm not receiving any of the <code>X-Auth-Request</code> headers, except when I call <code>/oauth2/auth</code> directly.</p>
<p>I've also tried adding the following snippet to my application Ingress configuration with no luck:</p>
<pre><code>nginx.ingress.kubernetes.io/configuration-snippet: |
auth_request_set $email $upstream_http_x_auth_request_email;
access_by_lua_block {
if ngx.var.email ~= "" then
ngx.req.set_header("X-Auth-Request-Email", ngx.var.email)
end
}
</code></pre>
<p>I've gone through multiple configurations, read numerous blog posts, and scoured GitHub issues, but haven't been able to resolve this issue. Does anyone have any insights into what could be causing this behavior?</p>
| <p>You do have a <a href="https://kubernetes.io/docs/concepts/services-networking/ingress/#the-ingress-resource" rel="nofollow noreferrer">Kubernetes Ingress resource</a> that manages external access to the services in your cluster. That is typically defined in a YAML file and applied to your Kubernetes cluster using <code>kubectl apply -f <filename.yaml></code>.</p>
<p>Something like (mentioned for other readers):</p>
<pre class="lang-yaml prettyprint-override"><code>apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: my-ingress
annotations:
# annotations go here
spec:
rules:
- host: myapp.mydomain.com
http:
paths:
- backend:
service:
name: my-service
port:
number: 80
</code></pre>
<p>In the <code>annotations</code> section, you can specify various settings that the Nginx Ingress Controller should apply. I would suggest, from the <a href="https://github.com/kubernetes/ingress-nginx/blob/main/docs/user-guide/nginx-configuration/annotations.md#external-authentication" rel="nofollow noreferrer">kubernetes/ingress-nginx annotations External Authentication</a>:</p>
<pre class="lang-yaml prettyprint-override"><code>apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: my-ingress
annotations:
nginx.ingress.kubernetes.io/auth-url: "https://$host/oauth2/auth"
nginx.ingress.kubernetes.io/auth-signin: "https://$host/oauth2/start?rd=$escaped_request_uri"
nginx.ingress.kubernetes.io/auth-response-headers: "x-auth-request-user, x-auth-request-groups, x-auth-request-email"
spec:
rules:
- host: myapp.mydomain.com
http:
paths:
- backend:
service:
name: my-service
port:
number: 80
</code></pre>
<p>(And <code>kubectl apply -f <your-ingress-config>.yaml</code>)</p>
<p>That would explicitly tell the Ingress to pick these headers from the authentication response and pass them to the upstream application.</p>
<p>Doing this updates the Ingress resource in your Kubernetes cluster and subsequently should update the Nginx Ingress Controller's configuration. After applying, give it some time to propagate, and then you can check if the <code>X-Auth-Request</code> headers are being passed as you expect.</p>
<p>If not, and if nothing is obvious in <code>kubectl logs <nginx-ingress-pod></code> output, check the OAuth2 Proxy logs (<code>kubectl logs <oauth2-proxy-pod></code>) to see if the headers are generated as expected (because if there are not... no amount of Lua script would change the end result).</p>
|
<p>I was trying to create a namespace using <code>kubectl</code>, but I got this error:</p>
<blockquote>
<p>Error from server (Forbidden): error when creating "namespacefoo": namespaces is forbidden: User "[email protected]" cannot create namespaces at the cluster scope</p>
</blockquote>
<p>Is there a concept of "scope" in Kubernetes? I couldn't find any information about different types of scope. If I cannot create namespace at the cluster scope, where can I create the namespace? How can I check which "scopes" do I have access to?</p>
| <p>That depends on your Kubernetes environment.</p>
<p>This <a href="https://stackoverflow.com/a/49094802/6309">answer suggest</a> (in a <a href="https://cloud.google.com/" rel="nofollow noreferrer">Google Cloud environment</a>):</p>
<blockquote>
<p>That suggests that <code>gcloud config set container/use_client_certificate</code> is set to <code>true</code> i.e. that <code>gcloud</code> is expecting a client cluster certificate to authenticate to the cluster (this is what the 'client' in the error message refers to).</p>
<p>Unsetting <code>container/use_client_certificate</code> by issuing the following command in the <code>glcoud config</code> ends the need for a legacy certificate or credentials and prevents the error message:</p>
<pre><code>gcloud config unset container/use_client_certificate
</code></pre>
<p>Issues such as this may be more likely if you are using an older version of <code>gcloud</code> on your home workstation or elsewhere.</p>
</blockquote>
<p>Still, <a href="https://github.com/kubernetes/kubernetes/issues/62361#issuecomment-397215728" rel="nofollow noreferrer">kubernetes/kubernetes issue 62361</a> mentions the same error message.</p>
|
<p>i am trying deploy a simple python flask application in digital ocean Kubernetes cluster using below deployment and service configuration. flask app is using 8080 port while running the code and same is used to expose through load balancer.</p>
<p>flask app</p>
<pre><code> if __name__ == '__main__':
app.run(debug=True, host='0.0.0.0', port=8080)
</code></pre>
<p>deployment</p>
<pre><code> ubuntu@ubuntu-22lts:~$ cat deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: unit7-app-deploy
spec:
replicas: 2
selector:
matchLabels:
app: unit-app
template:
metadata:
labels:
app: unit-app
spec:
containers:
- name: unit-app
image: <username>/flask-app:latest
imagePullPolicy: IfNotPresent
resources:
limits:
memory: "128Mi"
cpu: "500m"
ports:
- containerPort: 8080
</code></pre>
<p>and service for load balance creation</p>
<pre><code> apiVersion: v1
kind: Service
metadata:
name: unit7-app-service
spec:
selector:
app: unit7-app-deploy
ports:
- port: 8080
targetPort: 8080
protocol: TCP
type: LoadBalancer
</code></pre>
<p>Now I am trying to access my app through Kubernetes external IP and 8080 port which is not working. pods logs are showing that my flaks is running.</p>
<pre><code> ubuntu@ubuntu-22lts:~$ kubectl --kubeconfig=k8s-1-27-2-do-0-blr1-cluster1-kubeconfig.yaml logs -f unit7-app-deploy-6568dss8-ddsds
* Serving Flask app 'run'
* Debug mode: on
WARNING: This is a development server. Do not use it in a production deployment. Use a production WSGI server instead.
* Running on all addresses (0.0.0.0)
* Running on http://127.0.0.1:8080
* Running on http://10.244.0.214:8080
</code></pre>
<p>where am I wrong. Kindly help me.</p>
| <p>Just in case this is part of your issue, your Service's selector does not match your Deployment's label.<br />
The selector in your service should match the labels in your deployment to establish the correct connection.</p>
<p>In your Deployment:</p>
<pre class="lang-yaml prettyprint-override"><code>apiVersion: apps/v1
kind: Deployment
metadata:
name: unit7-app-deploy
spec:
replicas: 2
selector:
matchLabels:
app: unit-app
</code></pre>
<p>The label for the pods being deployed is <code>app: unit-app</code>.</p>
<p>But in your Service:</p>
<pre class="lang-yaml prettyprint-override"><code>apiVersion: v1
kind: Service
metadata:
name: unit7-app-service
spec:
selector:
app: unit7-app-deploy
</code></pre>
<p>Here, the service selector is looking for pods with label <code>app: unit7-app-deploy</code>.</p>
<p>The selector in the service configuration should match the label you defined in your Deployment configuration for the pods, which is <code>app: unit-app</code>.<br />
For instance, service configuration should look like:</p>
<pre class="lang-yaml prettyprint-override"><code>apiVersion: v1
kind: Service
metadata:
name: unit7-app-service
spec:
selector:
app: unit-app # Change from 'unit7-app-deploy' to 'unit-app'
ports:
- port: 8080
targetPort: 8080
protocol: TCP
type: LoadBalancer
</code></pre>
<p>That mismatch is likely the reason your load balancer is not working correctly, as it is not able to find the correct pods to send traffic to.</p>
|
<p>I have setup a kubernetes cluster with 2 <code>master</code> nodes and 4 <code>worker nodes</code>, I am trying to do an etcd backup
as described in the documentation inside my etcd container.</p>
<pre><code>ETCDCTL_API=3 etcdctl --endpoints=https://127.0.0.1:2379 \
--cacert=<trusted-ca-file> --cert=<cert-file> --key=<key-file> \
snapshot save <backup-file-location>
</code></pre>
<p>but I get the following error:</p>
<pre><code>Error: unknown command "save" for "etcdctl"
</code></pre>
<p>Are there something to concider upfront?</p>
| <p>Check first if this is similar to <a href="https://stackoverflow.com/q/70906419/6309">this question</a></p>
<blockquote>
<p>I forgot to set <code>$ENDPOINT</code>.</p>
</blockquote>
<p>That can happen if the <code>--endpoints</code> flag is not correctly followed by an actual endpoint.<br />
In your case, because of the lack of a specified endpoint after the <code>--endpoints</code> flag, <code>etcdctl</code> is interpreting "<code>snapshot</code>" as the endpoint, and "<code>save</code>" as the command - which could result in the error you are seeing.</p>
<p>A better formed command would be:</p>
<pre class="lang-bash prettyprint-override"><code>ETCDCTL_API=3 etcdctl --endpoints=https://127.0.0.1:2379 \
--cacert=<trusted-ca-file> --cert=<cert-file> --key=<key-file> \
snapshot save <backup-file-location>
</code></pre>
<p>Do replace <code><trusted-ca-file></code>, <code><cert-file></code>, <code><key-file></code>, and <code><backup-file-location></code> with your actual file paths.</p>
<p>The <code>--endpoints</code> flag specifies the endpoint to connect to your etcd server. In a Kubernetes cluster, you typically connect to the etcd server through localhost (127.0.0.1) on port 2379, which is the default etcd client port.</p>
<hr />
<p>Also, just in case, in some shells, using the <code>\</code> character for line continuation might cause issues, try running the command all on one line:</p>
<p><code>ETCDCTL_API=3 etcdctl --endpoints=https://127.0.0.1:2379 --cacert=<trusted-ca-file> --cert=<cert-file> --key=<key-file> snapshot save <backup-file-location></code></p>
<p>Another issue might be that the <code><backup-file-location></code> you are specifying does not exist or the <code>etcdctl</code> does not have permission to write to it. Make sure the directory you are trying to save the snapshot to exists and that the user running the <code>etcdctl</code> command has permission to write to it.</p>
|
<p><a href="https://i.stack.imgur.com/IOowW.png" rel="nofollow noreferrer">looks like this</a>
using windows version 10,
docker for windows(docker verion) : 18.09.2</p>
<p>how to resolve this issue ?</p>
| <p>Kubernetes should be running.</p>
<p>But check your cluster-info:</p>
<pre><code>> kubectl cluster-info
Kubernetes master is running at http://localhost:8080
To further debug and diagnose cluster problems, use 'kubectl cluster-info dump'.
Unable to connect to the server: dial tcp [::1]:8080: connectex: No connection could be made because the target machine actively refused it.
</code></pre>
<p>That is reported both in <a href="https://github.com/docker/machine/issues/1094#issuecomment-460817882" rel="nofollow noreferrer">docker/machine</a> and <a href="https://github.com/docker/for-win/issues/2099" rel="nofollow noreferrer">docker/for-win</a> or <a href="https://github.com/kubernetes/minikube/issues/3562#issuecomment-457142656" rel="nofollow noreferrer">kubernetes/minikube</a>.</p>
<p>While the issue is pending, and if no firewall/proxy is involved, I have seen the error caused because <a href="https://stackoverflow.com/a/52313787/6309">the port is already taken</a>.</p>
<p>See also <a href="https://www.ntweekly.com/2018/05/08/kubernetes-windows-error-unable-connect-server-dial-tcp-16445-connectex-no-connection-made-target-machine-actively-refused/" rel="nofollow noreferrer">this article</a>:</p>
<blockquote>
<h2>Issue</h2>
<p>The reason you are getting the error message is that Kuberentes is not looking into the correct configuration folder because the configuration path is not configured on the Windows 10 machine.</p>
<h2>Solution</h2>
<p>To fix the problem, I will run the command below that will tell Kubernetes where to find the configuration file on the machine.</p>
<pre><code>Powershell
[Environment]::SetEnvironmentVariable("KUBECONFIG", $HOME + "\.kube\config", [EnvironmentVariableTarget]::Machine)
</code></pre>
</blockquote>
|
End of preview. Expand
in Dataset Viewer.
No dataset card yet
- Downloads last month
- 9