prompt stringlengths 65 38.7k | response stringlengths 41 29.1k |
|---|---|
<p>I'm trying to use CircleCI + ArgoCD for CD/CI on a digitalocean kubernetes cluster, is there a way to connect ArgoCD to a github account that have 2FA enabled? Because every time I go in the connect repo section it gives me "Unable to connect repository: authentication required" but the credentials are the correct one</p>
| <p>Try to use a access token, check this bloc <a href="https://help.github.com/en/articles/creating-a-personal-access-token-for-the-command-line" rel="nofollow noreferrer">https://help.github.com/en/articles/creating-a-personal-access-token-for-the-command-line</a></p>
|
<p>I want to access my backend pods using an internal Kubernetes dns name. Instead of using <a href="http://somepodip:8080/get" rel="nofollow noreferrer">http://somepodip:8080/get</a> I want to use <a href="http://backend:8080/get" rel="nofollow noreferrer">http://backend:8080/get</a> to use my backend.</p>
<p>I am currently running my backend pods and have hooked them up to a service.</p>
<pre><code>kind: Service
apiVersion: v1
metadata:
name: backend
spec:
selector:
app: myapp-backend
ports:
- name: http
protocol: TCP
port: 8080
targetPort: 8080
</code></pre>
<p>This does assign my pods to the backend service. But when I try to use a frontend pod with <a href="http://backend/get" rel="nofollow noreferrer">http://backend/get</a> , it does not find the resource. </p>
<p>Am I incorrectly configuring the service?</p>
| <p>Your service seems to be ok, the issue could be possibly because your frontend is not server rendered, which means that your browser is trying to lookup for a name <code>backend</code>, in that case you cannot rely on kubernetes service name as your browser does not recognize it as a valid hostname.</p>
<p>If you want to access externally by instead of ip, you want to use names, check how to setup a ingress entry <a href="https://kubernetes.io/docs/concepts/services-networking/ingress/#what-is-ingress" rel="nofollow noreferrer">https://kubernetes.io/docs/concepts/services-networking/ingress/#what-is-ingress</a></p>
|
<p>I am trying to deploy MongoDB on my Kubernetes cluster.</p>
<p>I am deploying it in a few different steps where the first one will include the config-svr replicated , the second will include the shards replicated and he third will inc;ude replicated router pods.</p>
<p>I was able to create a kubernetes statefulset of 3 config pods but now I have to initialize the replica set.</p>
<p>I understood that I need to use rs.initiate() method in order to initialize the replicaset but I can't do it from remote.</p>
<p>my installation is all automatic and in which I can oinly run kubernetes job for the deployment and i cannot run exec command in any script.</p>
<p>I tried using a remote mongo pod job with the --host flg but I get an error message indicating admin is not authorized:</p>
<pre><code>{
"ok" : 0,
"errmsg" : "not authorized on admin to execute command { replSetInitiate: { _id: \"crs\", configsvr: true, members: [ { _id: 0.0, host: \"mongo-config-0.mongo-config-svc.default.svc.cluster.local:27017\" }, { _id: 1.0, host: \"mongo-config-1.mongo-config-svc.default.svc.cluster.local:27017\" }, { _id: 2.0, host: \"mongo-config-2.mongo-config-svc.default.svc.cluster.local:27017\" } ] } }",
"code" : 13,
"codeName" : "Unauthorized"
}
</code></pre>
<p>I read that I need to give my admin user read/write permissions but that will require again doing 'exec' commands inside the pods manually ( or via external script ) and I can't do that.</p>
<p>I also tried using the kubernetes api with ServiceAccount token permissions inside a pod job but I found that it is not possible to use curl with exec api since it requires a web session unlike other kubernetes api commands.</p>
<p>was any one able to initialize mongoDB replica either but using some Mongo workaround or Kubernetes workaround?</p>
<p>thanks</p>
| <p>This works for me from outside of pod:</p>
<pre><code>kubectl exec PODNAME-mongo-0 -- bash -c 'mongo localhost:27017 --eval "rs.initiate({_id:\"YOURREPLICASETNAME\",members:[{\"_id\":1,\"host\":\"YOUR-NODE-1-NAME:27017\",\"priority\":10}, {\"_id\":2,\"host\":\"YOUR-NODE-2-NAME:27017\",\"priority\":5}]})"'
</code></pre>
|
<p>I need to lock down access to service running in Google Cloud Kubernetes. What I can do is use "loadBalancerSourceRanges" in service deployment with TCP load balancer to restrict networks that can access service say on port 443.</p>
<p>What I don't seem to be able to do is lock down ICMP traffic from internet hitting load balancer. This is security compliance requirement I have.</p>
<p>Google documentation and bug tracker seem to indicate that this is not possible. Am I correct and what is best alternative?</p>
| <p>If you go to VPC Network -> Firewall Rules -> Create firewall rule and select the targets as "All instances in the network" and block all ICMP requests you may be able to accomplish this (not tested).</p>
|
<p>I need to get a list of all namespaces in a specifc Kubernetes cluster, using the Kubernetes API. Because I need to loop through multiple clusters in my Python program, I need to specify the cluster every time I call the API.</p>
<p>One option is to use list_namespace(), as described in <a href="https://github.com/kubernetes-client/python/blob/master/kubernetes/docs/CoreV1Api.md" rel="noreferrer">https://github.com/kubernetes-client/python/blob/master/kubernetes/docs/CoreV1Api.md</a></p>
<p>However, this API doesn't allow me to specify the cluster. It picks up the cluster from the current-context in my .kube config file. If I remove or rename the config file, the API call fails completely.</p>
<p>I also found an extensions API at <a href="https://github.com/kubernetes-client/python/blob/master/kubernetes/docs/ExtensionsV1beta1Api.md" rel="noreferrer">https://github.com/kubernetes-client/python/blob/master/kubernetes/docs/ExtensionsV1beta1Api.md</a></p>
<p>Unfortunately, there is no API there to retrieve a list of namespaces. Is there some other API that I am unaware of?</p>
| <p>If you see the <a href="https://github.com/kubernetes-client/python-base/blob/master/config/kube_config.py" rel="noreferrer">source code</a> of the <em>kube_config</em> module you can use different arguments with the method <em>load_kube_config</em> to select your cluster:</p>
<blockquote>
<pre><code>def load_kube_config(config_file=None, context=None,
client_configuration=None,
persist_config=True):
"""Loads authentication and cluster information from kube-config file
and stores them in kubernetes.client.configuration.
:param config_file: Name of the kube-config file.
:param context: set the active context. If is set to None, current_context
from config file will be used.
:param client_configuration: The kubernetes.client.Configuration to
set configs to.
:param persist_config: If True, config file will be updated when changed
(e.g GCP token refresh).
"""
</code></pre>
</blockquote>
<p>If I understood the code correctly, you can do somewhat like the following:</p>
<pre><code>from kubernetes import client, config
for file in files:
config.load_kube_config(config_file=file)
v1 = client.CoreV1Api()
response = v1.list_namespace()
print(response)
</code></pre>
<p>EDIT: <a href="https://github.com/kubernetes-client/python/blob/e057f273069de445a2d5a250ac5fe37d79671f3b/examples/example4.py" rel="noreferrer">This</a> is an example that uses the context argument <strong>with a single kubeconfig file</strong> to iterate over multiple clusters. In the kubernetes docs there is an entry on <a href="https://kubernetes.io/docs/concepts/configuration/organize-cluster-access-kubeconfig/#merging-kubeconfig-files" rel="noreferrer">Merging kubeconfig files</a>. Basically after having a config file with multiple contexts you can load the file with <code>config.load_kube_config(config_file=file)</code> and load contexts with <code>client.load_kube_config(context="context2')</code></p>
<p>P.S. You don't need to use <em>config.load_kube_config()</em> if you want to use a config file in the default path (<em>'~/.kube/config'</em>) or if you set a path in the KUBECONFIG environment variable.</p>
|
<p>Hi do you know why I get the following error:</p>
<pre><code> ~ minikube start --vm-driver kvm2
😄 minikube v1.0.0 on darwin (amd64)
🤹 Downloading Kubernetes v1.14.0 images in the background ...
🔥 Creating kvm2 VM (CPUs=2, Memory=2048MB, Disk=20000MB) ...
💡 unsupported driver: kvm2
</code></pre>
<p>I have installed: </p>
<pre><code>brew update && brew install kubernetes-cli && brew cask install docker docker-machine minikube virtualbox && brew install hyperkit
</code></pre>
| <p>As per <a href="https://github.com/kubernetes/minikube/blob/master/docs/drivers.md#driver-plugin-installation" rel="nofollow noreferrer">Minikube Driver Plugin Installation</a>:</p>
<blockquote>
<p>Minikube uses Docker Machine to manage the Kubernetes VM so it
benefits from the driver plugin architecture that Docker Machine uses
to provide a consistent way to manage various VM providers. Minikube
embeds VirtualBox and VMware Fusion drivers so there are no additional
steps to use them. However, other drivers require an extra binary to
be present in the host PATH.</p>
</blockquote>
<p>The KVM2 driver is maintained by the minikube team. It is built, tested and released with minikube, however, <a href="https://github.com/kubernetes/minikube/blob/master/docs/drivers.md#kvm2-driver" rel="nofollow noreferrer">it's <strong>not supported by MacOS</strong></a>. </p>
<p><em>(I'm assuming that you are using MacOS since you are managing your packages with <code>brew</code>).</em></p>
<p>Minikube supports the <a href="https://kubernetes.io/docs/setup/minikube/#quickstart" rel="nofollow noreferrer">following drivers</a> (set with <code>--vm-driver=xxxxx</code>; default is <code>virtualbox</code>):</p>
<blockquote>
<ul>
<li>virtualbox</li>
<li>vmwarefusion</li>
<li>kvm2</li>
<li>kvm</li>
<li>hyperkit</li>
<li>xhyve (deprecated)</li>
<li>hyperv</li>
<li>none (Runs the Kubernetes components on the host and not in a VM. Using this driver requires Docker and a Linux environment</li>
</ul>
</blockquote>
<p>From this list, the best suitable drivers to use with MacOS are:</p>
<ul>
<li><a href="https://www.virtualbox.org/wiki/Downloads" rel="nofollow noreferrer">Virtual Box</a></li>
<li><a href="https://www.vmware.com/products/fusion.html" rel="nofollow noreferrer">VMware Fusion</a></li>
<li><em>and maybe the <a href="https://github.com/kubernetes/minikube/blob/master/docs/drivers.md#hyperkit-driver" rel="nofollow noreferrer">Hyperkit driver</a></em></li>
</ul>
|
<p>Microk8s is installed on default port 16443. I want to change it to 6443. I am using Ubuntu 16.04. I have installed microk8s using snapd and conjure-up.</p>
<p>None of the following options I have tried worked.</p>
<ol>
<li>Tried to edit the port in <code>/snap/microk8s/current/kubeproxy.config</code>. As the volume is read-only, I could not edit it.</li>
<li>Edited the <code>/home/user_name/.kube/config</code> and restarted the cluster.</li>
<li>Tried using the command and restarted the cluster
<code>sudo kubectl config set clusters.microk8s-cluster.server https://my_ip_address:6443</code>.</li>
<li>Tried to use <code>kubectl proxy --port=6443 --address=0.0.0.0 --accept-hosts=my_ip_address &</code>. It listens on 6443, but only HTTP, not HTTPS traffic.</li>
</ol>
| <p>That was initially resolved in <a href="https://github.com/ubuntu/microk8s/issues/43#issuecomment-434383633" rel="noreferrer">microk8s issue 43</a>, but detailed in <a href="https://github.com/ubuntu/microk8s/issues/300#issuecomment-476995716" rel="noreferrer">microk8s issue 300</a>:</p>
<blockquote>
<p>This is the right one to use for the latest microk8s:</p>
</blockquote>
<pre><code>#!/bin/bash
# define our new port number
API_PORT=8888
# update kube-apiserver args with the new port
# tell other services about the new port
sudo find /var/snap/microk8s/current/args -type f -exec sed -i "s/8080/$API_PORT/g" {} ';'
# create new, updated copies of our kubeconfig for kubelet and kubectl to use
mkdir -p ~/.kube && microk8s.config -l | sed "s/:8080/:$API_PORT/" | sudo tee /var/snap/microk8s/current/kubelet.config > ~/.kube/microk8s.config
# tell kubelet about the new kubeconfig
sudo sed -i 's#${SNAP}/configs/kubelet.config#${SNAP_DATA}/kubelet.config#' /var/snap/microk8s/current/args/kubelet
# disable and enable the microk8s snap to restart all services
sudo snap disable microk8s && sudo snap enable microk8s
</code></pre>
|
<p>I am new to <a href="https://spark.apache.org/" rel="nofollow noreferrer">spark</a>. I am trying to get <a href="https://spark.apache.org/" rel="nofollow noreferrer">spark</a> running on <a href="https://kubernetes.io/docs/concepts/overview/what-is-kubernetes/" rel="nofollow noreferrer">k8s</a> using <a href="https://github.com/helm/charts/tree/master/stable/spark" rel="nofollow noreferrer">helm chart: stable/spark</a>. I can see that it spins up the 1 <strong>master</strong> and 2 <strong>executer</strong> by default and exposes port: <strong>8080</strong> on <code>ClusterIP</code>. </p>
<p>Now what I have done is to expose the Port: <code>8080</code> via <code>elb</code> so I can see the <code>UI</code>.</p>
<p>Question is do I always have to bake the <code>jar</code> or <code>pySpark</code> code in the image I am using to spin the master or do I have other option as well ?</p>
<p>I don't want to use <code>k8s</code> as Cluster Manager for <code>spark</code>. I am trying to see if there is a way to host <code>spark</code> as an application on <code>k8s</code> and submit jobs to it as it is a standalone cluster with worker nodes.</p>
<p>so instead of using:</p>
<pre><code>spark-submit \
...
--master k8s://https://KUBECLUSTER-DNS-ADDRESS
</code></pre>
<p>I want to do:</p>
<pre><code>spark-submit \
...
--master spark://SPARK-MASTER-ELB-DNS
</code></pre>
<p>Also, I am trying to avoid baking the <code>job</code> in the <strong>spark docker image</strong></p>
| <blockquote>
<p>I don't want to use k8s as Cluster Manager for spark. I am trying to see if there is a way to host spark as an application on k8s and submit jobs to it as it is a standalone cluster with worker nodes.</p>
</blockquote>
<p>You can use <code>client</code> or <code>cluster</code> <a href="https://spark.apache.org/docs/latest/submitting-applications.html" rel="nofollow noreferrer">mode</a>. </p>
<p><strong><em>client:</em></strong></p>
<pre><code># Run on a Spark standalone cluster in client deploy mode
./bin/spark-submit \
--class org.apache.spark.examples.SparkPi \
--master spark://IP-ADDRESS-OF-MASTER:7077 \
--executor-memory 20G \
--total-executor-cores 100 \
/path/to/examples.jar \
1000
</code></pre>
<p><strong><em>cluster:</em></strong></p>
<pre><code>./bin/spark-submit \
--class org.apache.spark.examples.SparkPi \
--master spark://IP-ADDRESS-OF-MASTER:7077 \
--deploy-mode cluster \
--supervise \
--executor-memory 20G \
--total-executor-cores 100 \
/path/to/examples.jar \
1000
</code></pre>
<blockquote>
<p>Also, I am trying to avoid baking the job in the spark docker image.</p>
</blockquote>
<p>The only way is to use <code>client</code> mode. Basically, your driver will be in whatever machine where you run <code>spark-submit</code> from and that will need to have all the bits you need to execute your job. The only downside is that you might be susceptible to network latency if the client is not co-located with your Kubernetes cluster.</p>
<p>With <code>cluster</code> mode you will have bake stuff into your container image because your driver can start on any of the containers/pods that are slaves in your cluster.</p>
|
<p>I am trying to create a RollingUpdate and trying to use below code to see if pod came up or not. Should i create explicit API path like /healthz in my application so that kubernetes pings it and gets 200 status back or else its internal url for kubernetes?</p>
<pre><code>specs:
containers:
- name: liveness
readinessProbe:
httpGet:
path: /healthz
port: 80
</code></pre>
| <p>As@Thomas answered the Http probe, If application does not provide a endpoint to validate the success response. you can use <strong>TCP Probe</strong> </p>
<p>kubelet tries to establish a TCP connection on the container's port. If it can establish a connection, the container is considered healthy; if it can’t it is considered unhealthy</p>
<p>for example, in your case it would be like this</p>
<pre><code> ports:
- containerPort: 80
readinessProbe:
tcpSocket:
port: 80
initialDelaySeconds: 5
periodSeconds: 10
livenessProbe:
tcpSocket:
port: 80
initialDelaySeconds: 15
periodSeconds: 20
</code></pre>
<p>You can get further information over here <a href="https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-probes/" rel="nofollow noreferrer">configure-liveness-readiness-probes/</a></p>
|
<p>I'm trying to get a <a href="https://learn.microsoft.com/en-us/virtualization/windowscontainers/kubernetes/joining-windows-workers?tabs=ManagementIP" rel="nofollow noreferrer">windows (server 2019) based docker container running inside a kubernetes cluster</a>, using the <code>mcr.microsoft.com/windows/servercore:1809</code> image <a href="https://hub.docker.com/_/microsoft-windows-servercore" rel="nofollow noreferrer">from here</a></p>
<p>The node is recognised by the cluster and shown as ready.</p>
<p>When I try to deploy any pod to the cluster it runs without problems, but it's not possible to access the exposed ports associated with the service.</p>
<p>It appears that there's an issue with running <code>kube-proxy</code> on the windows worker node. The log for that node show:</p>
<p><code>Failed create pod sandbox: rpc error: code = Unknown desc = failed to start sandbox container for pod "kube-proxy-nwclf": Error response from daemon: network host not found</code></p>
<p>Any ideas on where I'm going wrong here?</p>
<p>UPDATE:
Just noticed that the kube-proxy pod on the windows machine has a cluster based ip address (<code>10.244.5.2</code>) rather than one from my local network (<code>192.168.1.X</code>). Is this relevant in terms of working out what the problem is?</p>
<pre><code>NAMESPACE NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES
kube-system kube-proxy-9jq8w 1/1 Running 1 15d 192.168.1.9 k8s-mr <none> <none>
kube-system kube-proxy-h5gx7 0/1 ContainerCreating 0 13s 10.244.5.2 wins2019-worker <none> <none>
</code></pre>
<p>Detail from describe pod shown below.</p>
<pre><code>user@k8s-mr:~/kube_projects/testdemo-4.1/app$ kubectl -n kube-system describe pod kube-proxy-nwclf
Name: kube-proxy-nwclf
Namespace: kube-system
Priority: 2000001000
PriorityClassName: system-node-critical
Node: wins2019-worker/192.168.1.10
Start Time: Wed, 17 Apr 2019 13:35:30 +0100
Labels: controller-revision-hash=b7775b676
k8s-app=kube-proxy
pod-template-generation=1
Annotations: <none>
Status: Pending
IP: 192.168.1.10
Controlled By: DaemonSet/kube-proxy
Containers:
kube-proxy:
Container ID:
Image: k8s.gcr.io/kube-proxy:v1.14.0
Image ID:
Port: <none>
Host Port: <none>
Command:
/usr/local/bin/kube-proxy
--config=/var/lib/kube-proxy/config.conf
--hostname-override=$(NODE_NAME)
State: Waiting
Reason: ContainerCreating
Ready: False
Restart Count: 0
Environment:
NODE_NAME: (v1:spec.nodeName)
Mounts:
/lib/modules from lib-modules (ro)
/run/xtables.lock from xtables-lock (rw)
/var/lib/kube-proxy from kube-proxy (rw)
/var/run/secrets/kubernetes.io/serviceaccount from kube-proxy-token-f4tqx (ro)
Conditions:
Type Status
Initialized True
Ready False
ContainersReady False
PodScheduled True
Volumes:
kube-proxy:
Type: ConfigMap (a volume populated by a ConfigMap)
Name: kube-proxy
Optional: false
xtables-lock:
Type: HostPath (bare host directory volume)
Path: /run/xtables.lock
HostPathType: FileOrCreate
lib-modules:
Type: HostPath (bare host directory volume)
Path: /lib/modules
HostPathType:
kube-proxy-token-f4tqx:
Type: Secret (a volume populated by a Secret)
SecretName: kube-proxy-token-f4tqx
Optional: false
QoS Class: BestEffort
Node-Selectors: <none>
Tolerations:
CriticalAddonsOnly
node.kubernetes.io/disk-pressure:NoSchedule
node.kubernetes.io/memory-pressure:NoSchedule
node.kubernetes.io/network-unavailable:NoSchedule
node.kubernetes.io/not-ready:NoExecute
node.kubernetes.io/pid-pressure:NoSchedule
node.kubernetes.io/unreachable:NoExecute
node.kubernetes.io/unschedulable:NoSchedule
Events:
Type Reason Age From Message
------
Normal Scheduled 70s default-scheduler Successfully assigned kube-system/kube-proxy-nwclf to wins2019-worker
Normal SandboxChanged 2s (x12 over 61s) kubelet, wins2019-worker Pod sandbox changed, it will be killed and re-created.
Warning FailedCreatePodSandBox 0s (x13 over 62s) kubelet, wins2019-worker Failed create pod sandbox: rpc error: code = Unknown desc = failed to start sandbox container for pod "kube-proxy-nwclf": Error response from daemon: network host not found
</code></pre>
| <p>Fixed it now, I had misunderstood that <code>kube-proxy</code> should not run at all on the windows node.</p>
<p>I had to amend the kubernetes master and apply a <code>NodeSelector</code> to ensure that the appropriate pods are setup for each node based on its OS. </p>
<pre><code>wget https://raw.githubusercontent.com/Microsoft/SDN/master/Kubernetes/flannel/l2bridge/manifests/node-selector-patch.yml
kubectl patch ds/kube-proxy --patch "$(cat node-selector-patch.yml)" -n=kube-system
</code></pre>
|
<p>I want to set higher logging verbosity in my k8s setup. While i managed to enable verbosity for API server and Kubectl by <code>--v=4</code> argument; I am having difficulties finding way to pass in this flag to Kubelet. </p>
<p>I am using <code>kubeadm init</code> method to launch small scale cluster, where master is also tainted so it can serve as minion. can you help in in enabling kubelet logging verbosity ?</p>
| <p>1) ssh to the master node</p>
<p>2) append <code>/var/lib/kubelet/kubeadm-flags.env</code> file with <code>--v=4</code>, i.e.</p>
<pre><code>KUBELET_KUBEADM_ARGS=--cgroup-driver=cgroupfs --network-plugin=cni --pod-infra-container-image=k8s.gcr.io/pause:3.1 --v=4
</code></pre>
<p>3) restart kubelet service</p>
<pre><code>sudo systemctl restart kubelet
</code></pre>
|
<p>OKD 3.11 Installation failed "Control plane pods didn't come up" </p>
<p><strong>Environment</strong></p>
<ul>
<li>CentOS Linux release 7.6.1810 (Core)</li>
<li>ansible 2.6.16</li>
<li>OKD 3.11</li>
<li>Docker version 1.13.1, build b2f74b2/1.13.1</li>
</ul>
<p><strong>Ansible inventory file</strong></p>
<pre><code> ##Open shift master nodes
# Create an OSEv3 group that contains the masters, nodes, and etcd groups
[OSEv3:children]
masters
nodes
etcd
# host group for masters
[masters]
SBSTJVMLX605 openshift_ip=192.168.62.95
# host group for etcd
[etcd]
SBSTJVMLX605 openshift_ip=192.168.62.95
# host group for nodes, includes region info
[nodes]
SBSTJVMLX605 openshift_node_group_name='node-config-master-infra' openshift_schedulable=true openshift_ip=192.168.62.95
[OSEv3:vars]
openshift_deployment_type=origin
#openshift_release="3.11"
openshift_disable_check=disk_availability,docker_storage,package_version,memory_availability
openshift_enable_docker_excluder=false
debug_level=4
</code></pre>
<p><strong>Errors from ansible</strong></p>
<pre><code>Failure summary:
1. Hosts: SBSTJVMLX605
Play: Configure masters
Task: Report control plane errors
Message: Control plane pods didn't come up
</code></pre>
<p><strong>Errors from journal ctl</strong></p>
<pre><code>31207 kubelet.go:2101] Container runtime network not ready: NetworkReady=false reason:NetworkPluginNotReady message:docker: network plugin is not ready: cni config uninitialized
</code></pre>
<p>Also </p>
<pre><code>origin-node[31207]: W0418 10:26:47.866972 31207 docker_service.go:545] Hairpin mode set to "promiscuous-bridge" but kubenet is not enabled, falling back to "hairpin-veth"
Apr 18 10:26:47 SBSTJVMLX605.SUNTECSBS.COM origin-node[31207]: I0418 10:26:47.866991 31207 docker_service.go:238] Hairpin mode set to "hairpin-veth"
Apr 18 10:26:47 SBSTJVMLX605.SUNTECSBS.COM origin-node[31207]: W0418 10:26:47.867101 31207 cni.go:172] Unable to update cni config: No networks found in /etc/cni/net.d
Apr 18 10:26:47 SBSTJVMLX605.SUNTECSBS.COM origin-node[31207]: W0418 10:26:47.870697 31207 cni.go:172] Unable to update cni config: No networks found in /etc/cni/net.d
Apr 18 10:26:47 SBSTJVMLX605.SUNTECSBS.COM origin-node[31207]: I0418 10:26:47.870720 31207 plugins.go:159] Loaded network plugin "cni"
Apr 18 10:26:47 SBSTJVMLX605.SUNTECSBS.COM origin-node[31207]: I0418 10:26:47.870745 31207 docker_service.go:253] Docker cri networking managed by cni
Apr 18 10:26:47 SBSTJVMLX605.SUNTECSBS.COM origin-node[31207]: I0418 10:26:47.883666 31207 docker_service.go:258] Docker Info: &{ID:BHX3:QGBT:WAEZ:TNJL:PCFX:4S6K:CEV6:QMMQ:NELX:RCXS:EXOE:AXYY Containers:0 ContainersRunning:0 ContainersPaused:0 ContainersStopped:0 Images:5 Driver:overlay2 DriverStatus:[[Backing Filesystem xfs] [Supports d_type true] [Native Overlay Diff true]] SystemStatus:[] Plugins:{Volume:[local] Network:[bridge host macvlan null overlay] Authorization:[] Log:[]} MemoryLimit:true SwapLimit:true KernelMemory:true CPUCfsPeriod:true CPUCfsQuota:true CPUShares:true CPUSet:true IPv4Forwarding:true BridgeNfIptables:false BridgeNfIP6tables:false Debug:false NFd:16 OomKillDisable:true NGoroutines:23 SystemTime:2019-04-18T10:26:47.873639519+05:30 LoggingDriver:json-file CgroupDriver:systemd NEventsListener:0 KernelVersion:3.10.0-957.el7.x86_64 OperatingSystem:CentOS Linux 7 (Core) OSType:linux Architecture:x86_64 IndexServerAddress:https://index.docker.io/v1/ RegistryConfig:0xc4208af5e0 NCPU:4 MemTotal:8370298880 GenericResources:[] DockerRootDir:/var/lib/docker HTTPProxy:http://sbstjsvfw01:8080/ HTTPSProxy:http://sbstjsvfw01:8080/ NoProxy: 192.168.62.95, localhost,.cluster.local,.svc,127.0.0.1,169.254.169.254,172.30.0.1,192.168.62.95,sbstjvmlx605.suntecsbs.com Name:SBSTJVMLX605.SUNTECSBS.COM Labels:[] ExperimentalBuild:false ServerVersion:1.13.1 ClusterStore: ClusterAdvertise: Runtimes:map[docker-runc:{Path:/usr/libexec/docker/docker-runc-current Args:[]} runc:{Path:docker-runc Args:[]}] DefaultRuntime:docker-runc Swarm:{NodeID: NodeAddr: LocalNodeState:inactive ControlAvailable:false Error: RemoteManagers:[] Nodes:0 Managers:0 Cluster:0xc420c46dc0} LiveRestoreEnabled:false Isolation: InitBinary:/usr/libexec/docker/docker-init-current ContainerdCommit:{ID: Expected:aa8187dbd3b7ad67d8e5e3a15115d3eef43a7ed1} RuncCommit:{ID:df5c38a9167e87f53a9894d77c0950e178a745e7 Expected:9df8b306d01f59d3a8029be411de015b7304dd8f} InitCommit:{ID:fec3683b971d9c3ef73f284f176672c44b448662 Expected:949e6facb77383876aeff8a6944dde66b3089574} SecurityOptions:[name=seccomp,profile=/etc/docker/seccomp.json name=selinux]}
Apr 18 10:26:47 SBSTJVMLX605.SUNTECSBS.COM origin-node[31207]: I0418 10:26:47.883740 31207 docker_service.go:271] Setting cgroupDriver to systemd
Apr 18 10:26:47 SBSTJVMLX605.SUNTECSBS.COM origin-node[31207]: I0418 10:26:47.883810 31207 kubelet.go:628] Starting the GRPC server for the docker CRI shim.
Apr 18 10:26:47 SBSTJVMLX605.SUNTECSBS.COM origin-node[31207]: I0418 10:26:47.883872 31207 docker_server.go:59] Start dockershim grpc server
Apr 18 10:26:47 SBSTJVMLX605.SUNTECSBS.COM origin-node[31207]: W0418 10:26:47.883909 31207 util_unix.go:75] Using "/var/run/dockershim.sock" as endpoint is deprecated, please consider using full url format "unix:///var/run/dockershim.sock".
Apr 18 10:26:47 SBSTJVMLX605.SUNTECSBS.COM origin-node[31207]: I0418 10:26:47.890481 31207 oom_linux.go:65] attempting to set "/proc/19601/oom_score_adj" to "-999"
Apr 18 10:26:47 SBSTJVMLX605.SUNTECSBS.COM origin-node[31207]: I0418 10:26:47.890657 31207 oom_linux.go:65] attempting to set "/proc/19610/oom_score_adj" to "-999"
Apr 18 10:26:47 SBSTJVMLX605.SUNTECSBS.COM origin-node[31207]: I0418 10:26:47.900614 31207 remote_runtime.go:43] Connecting to runtime service /var/run/dockershim.sock
Apr 18 10:26:47 SBSTJVMLX605.SUNTECSBS.COM origin-node[31207]: W0418 10:26:47.900638 31207 util_unix.go:75] Using "/var/run/dockershim.sock" as endpoint is deprecated, please consider using full url format "unix:///var/run/dockershim.sock".
Apr 18 10:26:47 SBSTJVMLX605.SUNTECSBS.COM origin-node[31207]: I0418 10:26:47.900715 31207 remote_image.go:40] Connecting to image service /var/run/dockershim.sock
Apr 18 10:26:47 SBSTJVMLX605.SUNTECSBS.COM origin-node[31207]: W0418 10:26:47.900728 31207 util_unix.go:75] Using "/var/run/dockershim.sock" as endpoint is deprecated, please consider using full url format "unix:///var/run/dockershim.sock".
Apr 18 10:26:47 SBSTJVMLX605.SUNTECSBS.COM origin-node[31207]: I0418 10:26:47.900860 31207 plugins.go:56] Registering credential provider: .dockercfg
Apr 18 10:26:47 SBSTJVMLX605.SUNTECSBS.COM origin-node[31207]: I0418 10:26:47.902596 31207 kuberuntime_manager.go:186] Container runtime docker initialized, version: 1.13.1, apiVersion: 1.26.0
</code></pre>
<p>Also a lot of connect refused on 8443 port master api.</p>
<p>Did some one came across some thing similar. I have a running cluster on 3.9 and was working properly. I tried this as a fresh installation after uninstalling 3.9 </p>
| <p>Oof could get the thing up !! </p>
<ol>
<li><p><code>Unable to update cni config: No networks found in /etc/cni/net.d.</code> The network plugin was not ready perhaps because of this. This was the thing @capt2101akash pointed also.</p>
<p>Got a work around solution from the below mailing list</p>
<p><a href="https://lists.openshift.redhat.com/openshift-archives/users/2018-November/msg00054.html" rel="nofollow noreferrer">Reference solution</a></p>
<p>Basically created a file /etc/cni/net.d/80-openshift-network.conf with content</p>
<p>{
"cniVersion": "0.2.0",
"name": "openshift-sdn",
"type": "openshift-sdn"
}</p></li>
<li><p>Again it was not coming up, Ansible scripts showed me the same old story "Control planes not up"</p>
<p>This time master logs <code>/usr/local/bin/master-logs api api</code> was showing a command not found in <code>/etc/origin/master/master.env</code> . Guessed a problem in inventory file.
The entry for proxy had an additional <code>\</code> and no proxy some spaces. </p>
<p>Santized the inventory file.</p>
<p>Redeployed and it is up and accessible.</p>
<p>This was a workaround, would post it if i get into the real cause.</p></li>
</ol>
|
<p>Using Rook 0.9.3 I was able to bring up a Ceph-based directory for a MySQL-database on a three-node Kubernetes cluster (1 master, two workers) simply as follows:</p>
<pre><code>kubectl create -f cluster/examples/kubernetes/ceph/operator.yaml
kubeclt create -f cluster/examples/kubernetes/ceph/cluster.yaml
vim cluster/examples/kubernetes/ceph/storageclass.yaml # change xfs to ext4
kubectl create -f cluster/examples/kubernetes/ceph/storageclass.yaml
kubectl create -f cluster/examples/kubernetes/mysql.yaml
</code></pre>
<p>When I now <code>bash</code> into the pod <code>wordpress-mysql-*</code> I can see that <code>/var/lib/mysql</code> is mounted from <code>/dev/rbd1</code>. If I create a random file in this directory and then delete the pod, the file has persisted when a new instance of the pod comes up.</p>
<p>My first worker contains these directories in <code>/var/lib/rook</code>: <code>mon-a</code> <code>mon-c</code> <code>mon-d</code> <code>osd0</code> <code>rook-ceph</code>. My second worker contains only one directory in <code>/var/lib/rook</code>: <code>mon-b</code>. This and other evidence (from <code>df</code>) suggest that Rook (and by extension Ceph) stores all of its file data (e.g. all blocks that constitute the mounted <code>/var/lib/mysql</code>) in <code>/var/lib/rook/osd0</code>, i.e. once on a single node. </p>
<p>I would have expected that blocks are distributed across several nodes so that when one node (the first worker, in my case) fails, data access is still available. Is this a naive expectation? If not, how can I configure Rook accordingly? Also, I have second, unformatted disks on both worker nodes, and I would prefer for Rook/Ceph to use those. How can this be accomplished?</p>
| <p>for using other partition as osd
you should change cluster.yml and add</p>
<pre><code>nodes:
- name: "kube-node1"
devices:
- name: "sdb"
- name: "kube-node2"
devices:
- name: "sdb"
- name: "kube-node3"
devices:
- name: "sdb"
</code></pre>
|
<p>I created a secret like this: </p>
<pre><code>kubectl create secret generic test --from-literal=username=testuser --from-literal=password=12345
</code></pre>
<p>I want to update the username to <code>testuser2</code> but I want to do it only with <code>kubectl patch --type='json'</code>. </p>
<p>This is how I tried to do it: </p>
<pre><code>kubectl patch secret test --type='json' -p='[{"data":{"username": "testuser 2"}}]' -v=1
</code></pre>
<p>But I received: </p>
<blockquote>
<p>The "" is invalid</p>
</blockquote>
<p>Remember, I want to do it with the option of <code>--type='json'</code>, no other workarounds.</p>
| <p>I found how to do it after I read <a href="https://kubernetes.io/docs/tasks/run-application/update-api-object-kubectl-patch/#use-a-json-merge-patch-to-update-a-deployment" rel="noreferrer">here</a> that referred me to <a href="http://erosb.github.io/post/json-patch-vs-merge-patch/" rel="noreferrer">this</a> great article.<br>
This is the JSON secret: </p>
<pre><code>{
"apiVersion": "v1",
"data": {
"password": "aWx1dnRlc3Rz",
"username": "dGVzdHVzZXI="
},
"kind": "Secret",
"metadata": {
"creationTimestamp": "2019-04-18T11:37:09Z",
"name": "test",
"namespace": "default",
"resourceVersion": "3017",
"selfLink": "/api/v1/namespaces/default/secrets/test",
"uid": "4d0a763e-61ce-11e9-92b6-0242ac110015"
},
"type": "Opaque"
}
</code></pre>
<p>Therefore, to update the user's field I needed to create the JSON Patch format: </p>
<pre><code>[
{
"op" : "replace" ,
"path" : "/data/username" ,
"value" : "dGVzdHVzZXIy" # testuser2 in base64
}
]
</code></pre>
<p>Notice that the value should be in base64. </p>
<p>The result is: </p>
<pre><code>kubectl patch secret test --type='json' -p='[{"op" : "replace" ,"path" : "/data/username" ,"value" : "dGVzdHVzZXIy"}]'
</code></pre>
|
<p>Is there any way to remove a header going upstream after the external authentication with the envoy proxy? We planned to migrate to envoy proxy for our internal API gateway, but this is a blocker now.</p>
<p>For example: the external authentication service gets the request and processes the authentication header, in case the validation fails, it throws the 401. But if it succeeds, I want to prevent the auth headers from going upstream. </p>
<p>As per the documentation <a href="https://www.envoyproxy.io/docs/envoy/v1.9.0/api-v2/config/filter/http/ext_authz/v2alpha/ext_authz.proto#envoy-api-msg-config-filter-http-ext-authz-v2alpha-httpservice" rel="noreferrer">Ext Auth</a>:</p>
<blockquote>
<p>A successful check allows the authorization service adding or overriding headers from the original request before dispatching it to the upstream. This is done by configuring which headers in the authorization response should be sent to the upstream. See allowed_authorization_headers below.</p>
</blockquote>
<p>There is no mention whether I can completely remove the header going upstream. </p>
<p>I have the option to override the headers, but that is causing header conflict at the upstream servers. So it is not a possible solution.</p>
<p>How can I achieve this?</p>
| <p>Note that I am not an expert in envoy proxy, but from what I was able to find you can actually write a Lua script that would be able to remove the headers. In the documentation you can find an example of such script, and with a little bit of tinkering you should be able to customize it if needed:</p>
<pre class="lang-lua prettyprint-override"><code>-- Remove a response header named 'foo'
response_handle:headers():remove("foo")
</code></pre>
<p>You can find more information in the official documentation. Here for <a href="https://www.envoyproxy.io/docs/envoy/v1.9.0/api-v2/config/filter/http/lua/v2/lua.proto#config-filter-http-lua-v2-lua" rel="nofollow noreferrer">config.filter.http.lua.v2.Lua</a> and here are the <a href="https://www.envoyproxy.io/docs/envoy/v1.9.0/configuration/http_filters/lua_filter#script-examples" rel="nofollow noreferrer">script examples</a>. </p>
|
<p>I am using readinessprobe for rolling updates. It works fine. But even after pods comes up. It keeps pinging healthz even after pod is running. I was assuming it will stop pinging when pods are up and running. Is it right?</p>
<pre><code>specs:
containers:
- name: ready
readinessProbe:
httpGet:
path: /healthz
port: 80
</code></pre>
| <p>The kubelet will continue to run this check every <strong>10</strong> second which is <strong>default value</strong>. You can customize it according to your need.</p>
<p>It's important data for kubelet to understand if the Container is healthy or not. if it is not healthy it will try to restart it. therefore, its a continuous process. that's how we try to achieve <strong>application availability</strong> </p>
<blockquote>
<p>periodSeconds: How often (in seconds) to perform the probe. Default to 10 seconds. Minimum value is 1.</p>
</blockquote>
<p>For further detail
<a href="https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-probes/#configure-probes" rel="nofollow noreferrer">configure-probes</a></p>
|
<p>I have a k8s deployment - I often deploy a new version to the docker repo - change the image tag - and try to replace the deployment using <code>kubectl replace -f file.yaml</code>. My replicas are set to 1 - I have only 1 pod of the deployment running at a time.</p>
<p>When I change the image tag (e.g changing v1 to v2) and try to replace it - it creates a new pod, but it remains in the 'pending' state indefinitely, while the old pod stays in 'Running' state.</p>
<p>I think the new pod waits for the old pod to be terminated - but it won't terminate by itself. I need it to be deleted by k8s so the new pod can take its place.</p>
<p>Using <code>replace --force</code> fixes this issue - but I'd like it to work using just <code>replace -f</code>. Any ideas how to achieve this?</p>
| <p>The issue you see has nothing to do with kubectl replace/apply. The real reason is that deployments by default use RollingUpdate strategy which by default waits for new pod to be Running and only then kills old pod. The reason why new pod is in Pending state is unclear from your question but in most cases this indicates lack of compute resources for new pod.</p>
<p>You may do two different things: </p>
<p>Use RollingUpdate strategy with maxUnavailable=1. This will do what you want - it will kill old pod and then create a new one.</p>
<pre><code>spec:
strategy:
type: RollingUpdate
rollingUpdate:
maxUnavailable: 1
</code></pre>
<p>OR you can specify Recreate strategy which effectively does the same:</p>
<pre><code>spec:
strategy:
type: Recreate
</code></pre>
<p>Read more about deployment strategies here: <a href="https://kubernetes.io/docs/concepts/workloads/controllers/deployment/#strategy" rel="nofollow noreferrer">https://kubernetes.io/docs/concepts/workloads/controllers/deployment/#strategy</a></p>
|
<p>I am using readinessprobe for rolling updates. It works fine. But even after pods comes up. It keeps pinging healthz even after pod is running. I was assuming it will stop pinging when pods are up and running. Is it right?</p>
<pre><code>specs:
containers:
- name: ready
readinessProbe:
httpGet:
path: /healthz
port: 80
</code></pre>
| <p><code>readinessProbe</code> and <code>livenessProbe</code> will continue to do the check depends on the periodSeconds you have set or default value which is 10 seconds.</p>
<p><code>readinessProbe</code> and <code>livenessProbe</code> do the exact same thing. The difference is the actions to be performed in case of failure.</p>
<p><code>readinessProbe</code> will shut the communication down with the service in case of failure - so that service does not send any request to the Pod.</p>
<p><code>livenessProbe</code> will restart the Pod in case of failure. </p>
|
<p>I have set up EFK on Kubernetes, currently I have access only to logs from logstash but wondering how can I install some plugins for Fluentd in order to get some logs from eg. NGINX which I use as a reverse proxy? Can someone please point me how exactly I can configure EFK on k8s and what are the best practices around it? On k8s I have eg. API service in Express JS.</p>
| <p>You will find this article interesting for the begging:<a href="https://platform9.com/blog/kubernetes-logging-and-monitoring-the-elasticsearch-fluentd-and-kibana-efk-stack-part-1-fluentd-architecture-and-configuration/" rel="nofollow noreferrer">Kubernetes Logging and Monitoring: The Elasticsearch, Fluentd, and Kibana (EFK) Stack – Part 1: Fluentd Architecture and Configuration</a></p>
<p>Also there are a lot of fluentd plugins for kubernetes here: <a href="https://www.fluentd.org/plugins/all#stq=kubernetes&stp=1" rel="nofollow noreferrer">https://www.fluentd.org/plugins/all#stq=kubernetes&stp=1</a></p>
<p>Each plugin has installation instruction, for example <a href="https://docs.fluentd.org/v0.12/articles/kubernetes-fluentd" rel="nofollow noreferrer">Kubernetes Logging with Fluentd</a></p>
<p>Also you may want to try <a href="https://github.com/fluent/fluent-bit-kubernetes-logging" rel="nofollow noreferrer">Fluent Bit</a> is a lightweight and extensible Log Processor</p>
|
<p>Kubernetes version - 1.8</p>
<ol>
<li>Created statefulset for postgres database with pvc</li>
<li>Added some tables to database</li>
<li>Restarted pod by scaling statefulset to 0 and then again 1</li>
<li>Created tables in step # 2 are no longer available</li>
</ol>
<p>Tried another scnario with steps on docker-for-desktop cluster k8s version 1.10</p>
<ol>
<li>Created statefulset for postgres database with pvc</li>
<li>Added some tables to database</li>
<li>Restarted docker for desktop</li>
<li>Created tables in step # 2 are no longer available</li>
</ol>
<p>k8s manifest</p>
<pre><code> apiVersion: v1
kind: ConfigMap
metadata:
name: postgres-config
labels:
app: postgres
data:
POSTGRES_DB: kong
POSTGRES_USER: kong
POSTGRES_PASSWORD: kong
PGDATA: /var/lib/postgresql/data/pgdata
---
apiVersion: v1
kind: PersistentVolume
metadata:
name: postgres-pv
labels:
app: postgres
spec:
storageClassName: manual
capacity:
storage: 1Gi
accessModes:
- ReadWriteOnce
hostPath:
path: "/mnt/postgresql/data"
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: postgres-pvc
labels:
app: postgres
spec:
storageClassName: manual
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 1Gi
---
apiVersion: v1
kind: Service
metadata:
name: postgres
app: postgres
spec:
ports:
- name: pgql
port: 5432
targetPort: 5432
protocol: TCP
selector:
app: postgres
---
apiVersion: apps/v1beta2 # for k8s versions before 1.9.0 use apps/v1beta2 and before 1.8.0 use extensions/v1beta1
kind: StatefulSet
metadata:
name: postgres
spec:
serviceName: "postgres"
replicas: 1
selector:
matchLabels:
app: postgres
template:
metadata:
labels:
app: postgres
spec:
containers:
- name: postgres
image: postgres:9.6
imagePullPolicy: "IfNotPresent"
ports:
- containerPort: 5432
envFrom:
- configMapRef:
name: postgres-config
volumeMounts:
- mountPath: /var/lib/postgresql/data
name: postgredb
volumes:
- name: postgredb
persistentVolumeClaim:
claimName: postgres-pvc
---
</code></pre>
| <p>If you have multiple nodes - the issue you see is totally expected. So if you want to use hostPath as a Persistent Volume in a multi-node cluster - you must use some shared filesystem like Glusterfs or Ceph and place your /mnt/postgresql/data folder onto that shared filesystem.</p>
|
<p>I try to submit a Spark application to a Kubernetes cluster (Minikube).
When running my spark submit in client mode, everything goes well. 3 executors are created in 3 pods, and the code is executed. Here is my submit command : </p>
<pre><code>[MY_PATH]/bin/spark-submit \
--master k8s://https://[API_SERVER_IP]:8443 \
--deploy-mode client \
--name [Name] \
--class [MyClass] \
--conf spark.kubernetes.container.image=spark:2.4.0 \
--conf spark.executor.instances=3 \
[PATH/TO/MY/JAR].jar
</code></pre>
<p>Now, I adapted it to run in cluster mode : </p>
<pre><code>[MY_PATH]/bin/spark-submit \
--master k8s://https://[API_SERVER_IP]:8443 \
--deploy-mode cluster \
--name [Name] \
--class [MyClass] \
--conf spark.kubernetes.container.image=spark:2.4.0 \
--conf spark.executor.instances=3 \
local://[PATH/TO/MY/JAR].jar
</code></pre>
<p>This time, a driver pod is created as well as a driver service, and then the driver pod fail. On the Kubernetes I can see the following error : </p>
<pre><code>MountVolume.SetUp failed for volume "spark-conf-volume" : configmap "sparkpi-1555314081444-driver-conf-map" not found
</code></pre>
<p>And in the pod logs I have the error : </p>
<pre><code>Forbidden!Configured service account doesn't have access.
Service account may have been revoked.
pods "sparkpi-1555314081444-driver" is forbidden: User "system:serviceaccount:default:default" cannot get resource "pods" in API group "" in the namespace "default".
</code></pre>
<p>Here is the full stacktrace :</p>
<pre><code>org.apache.spark.SparkException: External scheduler cannot be instantiated
at org.apache.spark.SparkContext$.org$apache$spark$SparkContext$$createTaskScheduler(SparkContext.scala:2794)
at org.apache.spark.SparkContext.<init>(SparkContext.scala:493)
at org.apache.spark.SparkContext$.getOrCreate(SparkContext.scala:2520)
at org.apache.spark.sql.SparkSession$Builder$$anonfun$7.apply(SparkSession.scala:935)
at org.apache.spark.sql.SparkSession$Builder$$anonfun$7.apply(SparkSession.scala:926)
at scala.Option.getOrElse(Option.scala:121)
at org.apache.spark.sql.SparkSession$Builder.getOrCreate(SparkSession.scala:926)
at org.apache.spark.examples.SparkPi$.main(SparkPi.scala:31)
at org.apache.spark.examples.SparkPi.main(SparkPi.scala)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.apache.spark.deploy.JavaMainApplication.start(SparkApplication.scala:52)
at org.apache.spark.deploy.SparkSubmit.org$apache$spark$deploy$SparkSubmit$$runMain(SparkSubmit.scala:849)
at org.apache.spark.deploy.SparkSubmit.doRunMain$1(SparkSubmit.scala:167)
at org.apache.spark.deploy.SparkSubmit.submit(SparkSubmit.scala:195)
at org.apache.spark.deploy.SparkSubmit.doSubmit(SparkSubmit.scala:86)
at org.apache.spark.deploy.SparkSubmit$$anon$2.doSubmit(SparkSubmit.scala:924)
at org.apache.spark.deploy.SparkSubmit$.main(SparkSubmit.scala:933)
at org.apache.spark.deploy.SparkSubmit.main(SparkSubmit.scala)
Caused by: io.fabric8.kubernetes.client.KubernetesClientException: Failure executing: GET at: https://kubernetes.default.svc/api/v1/namespaces/default/pods/sparkpi-1555314081444-driver. Message: Forbidden!Configured service account doesn't have access. Service account may have been revoked. pods "sparkpi-1555314081444-driver" is forbidden: User "system:serviceaccount:default:default" cannot get resource "pods" in API group "" in the namespace "default".
at io.fabric8.kubernetes.client.dsl.base.OperationSupport.requestFailure(OperationSupport.java:470)
at io.fabric8.kubernetes.client.dsl.base.OperationSupport.assertResponseCode(OperationSupport.java:407)
at io.fabric8.kubernetes.client.dsl.base.OperationSupport.handleResponse(OperationSupport.java:379)
at io.fabric8.kubernetes.client.dsl.base.OperationSupport.handleResponse(OperationSupport.java:343)
at io.fabric8.kubernetes.client.dsl.base.OperationSupport.handleGet(OperationSupport.java:312)
at io.fabric8.kubernetes.client.dsl.base.OperationSupport.handleGet(OperationSupport.java:295)
at io.fabric8.kubernetes.client.dsl.base.BaseOperation.handleGet(BaseOperation.java:783)
at io.fabric8.kubernetes.client.dsl.base.BaseOperation.getMandatory(BaseOperation.java:217)
at io.fabric8.kubernetes.client.dsl.base.BaseOperation.get(BaseOperation.java:184)
at org.apache.spark.scheduler.cluster.k8s.ExecutorPodsAllocator$$anonfun$1.apply(ExecutorPodsAllocator.scala:57)
at org.apache.spark.scheduler.cluster.k8s.ExecutorPodsAllocator$$anonfun$1.apply(ExecutorPodsAllocator.scala:55)
at scala.Option.map(Option.scala:146)
at org.apache.spark.scheduler.cluster.k8s.ExecutorPodsAllocator.<init>(ExecutorPodsAllocator.scala:55)
at org.apache.spark.scheduler.cluster.k8s.KubernetesClusterManager.createSchedulerBackend(KubernetesClusterManager.scala:89)
at org.apache.spark.SparkContext$.org$apache$spark$SparkContext$$createTaskScheduler(SparkContext.scala:2788)
... 20 more
</code></pre>
<p>What should I do to make it work ?</p>
| <p>You have to create an authorized service account: <a href="https://spark.apache.org/docs/latest/running-on-kubernetes.html#rbac" rel="noreferrer">https://spark.apache.org/docs/latest/running-on-kubernetes.html#rbac</a></p>
<pre><code>kubectl create serviceaccount spark
kubectl create clusterrolebinding spark-role --clusterrole=edit --serviceaccount=default:spark --namespace=default
</code></pre>
<p>And then pass it as a parameter to the submit</p>
<pre><code>--conf spark.kubernetes.authenticate.driver.serviceAccountName=spark
</code></pre>
|
<p>I am trying to initialize a fresh instance of MariaDB (putting my .sql file inside /docker-entrypoint-initdb.d) using the official helm chart at <a href="https://github.com/helm/charts/tree/master/stable/mariadb#initialize-a-fresh-instance" rel="nofollow noreferrer">https://github.com/helm/charts/tree/master/stable/mariadb#initialize-a-fresh-instance</a>.</p>
<p>But I find the instructions quite unclear:</p>
<blockquote>
<p>In order to execute the scripts, they must be located inside the chart folder <code>files/docker-entrypoint-initdb.d</code> so they can be consumed as a ConfigMap.</p>
</blockquote>
<p>Since the only thing I do to set up the Mariadb cluster is using their <code>helm install --name my-release stable/mariadb -f values-production.yaml</code> I am quite confuse.</p>
<p>Where is this folder ?</p>
<hr />
<h3>Edit</h3>
<p>I downloaded <a href="https://github.com/helm/charts/tree/master/stable/mariadb" rel="nofollow noreferrer">https://github.com/helm/charts/tree/master/stable/mariadb</a> and placing (the whole folder) and placed my SQL file inside <code>files/docker-entrypoint-initdb.d</code>.</p>
<p>I then used <code>helm package ./mariadb</code> followed by <code>helm install ./mariadb -f ./mariadb/values-production.yaml</code>. But the master pod has "CrashLoopBackOff" as status.</p>
<p>Here are the master logs</p>
<pre><code>==> ** Starting MariaDB setup **
==> Validating settings in MYSQL_*/MARIADB_* env vars..
==> Initializing mariadb database...
==> Persisted data detected. Restoring...
==> Loading user's custom files from /docker-entrypoint-initdb.d ...
==> Stopping mariadb...
</code></pre>
<p>I also tried this way, but the db keep crashing</p>
<pre><code>kubectl create configmap db-scheme --from-file=db.sql
helm install --name db-test stable/mariadb -f .values-production.yml --set rootUser.password=ROOT_PASSWORD --set replication.password=REPLICATION_PASSWORD --set initdbScriptsConfigMap=db-scheme
</code></pre>
<p>Here are the logs :</p>
<p><img src="https://user-images.githubusercontent.com/36083584/56321611-65442000-6167-11e9-97f2-d8136d64a741.png" alt="image" /></p>
<hr />
<h3>Edit2</h3>
<p>I created a folder named <code>files/docker-entrypoint-initdb.d</code></p>
<p>My current directory:</p>
<pre><code>.
├── values-production.yml
│
├── files
│ └── docker-entrypoint-initdb.d
│ └── db.sql
</code></pre>
<p>And run this command from the current directory:</p>
<pre><code>helm install --name test stable/mariadb -f .\values-production.yml --set rootUser.password=ROOT_PASSWORD --set replication.password=REPLICATION_PASSWORD
</code></pre>
<p>MariaDB boots up but without my SQL tables.</p>
| <p>My issue is more complex than it seems :
<a href="https://github.com/bitnami/bitnami-docker-mariadb/issues/182" rel="nofollow noreferrer">https://github.com/bitnami/bitnami-docker-mariadb/issues/182</a></p>
<p>Something apart, creating a configmap does indeed work :</p>
<pre><code>kubectl create configmap db-scheme --from-file=db.sql
helm install --name db-test stable/mariadb -f .values-production.yml --set rootUser.password=ROOT_PASSWORD --set replication.password=REPLICATION_PASSWORD --set initdbScriptsConfigMap=db-scheme
</code></pre>
|
<p>We have a situation where Kubernetes is killing Mongo containers when it reaches max memory limit of the container. Even though its expected to K8s to work in that way but feel like Mongo is not reusing its memory as its keep on growing the memory usage day by day even though the user load & transactions are the same so what to check how we can limit the Mongo in reaching max memory of the container or flush Mongo memory at regular intervals.</p>
<p>I have tried to increase the memory which helped the pods to keep running a couple of more days before K8 killing it</p>
<pre><code> "containers": [
{
"name": "mongo",
"image": "dockercentral.com:5870/com.public/mongodb:3.6",
"ports": [
{
"containerPort": 27017,
"protocol": "TCP"
}
]
"resources": {
"limits": {
"cpu": "1",
"memory": "24Gi"
},
"requests": {
"cpu": "250m",
"memory": "24Gi"
}
}
"name": "MONGO_SECURITY",
"value": "true"
}
],
"resources": {
"limits": {
"cpu": "500m",
"memory": "1Gi"
},
"requests": {
"cpu": "150m",
"memory": "256Mi"
}
},
</code></pre>
| <p>Based on what <strong>Stennie from MongoDB, Inc.</strong> wrote in comment to question.</p>
<p>this command in kube .yaml works for me:</p>
<pre><code> command:
- "sh"
- "-c"
- >
echo "storage:" >> /etc/mongod.conf;
echo " wiredTiger:" >> /etc/mongod.conf;
echo " engineConfig:" >> /etc/mongod.conf;
echo " cacheSizeGB: 2" >> /etc/mongod.conf;
echo "replication:" >> /etc/mongod.conf;
echo " replSetName: YOUR_REPL_NAME" >> /etc/mongod.conf;
mongod --config /etc/mongod.conf;
</code></pre>
<p>also there is a way to set it in runtime:</p>
<pre><code>db.adminCommand( { "setParameter": 1, "wiredTigerEngineRuntimeConfig":"cache_size=2G"})
</code></pre>
<p>which also works just fine, but it looks easier through kuberneties yaml file because to issue a command you have to wait until mongo is up and running.</p>
<p>NOTE:
make sure that your:</p>
<pre><code> resources:
limits:
memory:
</code></pre>
<p>is allowing <strong>extra 1G</strong> for system.</p>
|
<p>I want to remove cpu limits for a specific container where the namespace has default cpu limits (via limitrange).
Per <a href="https://kubernetes.io/docs/tasks/administer-cluster/manage-resources/memory-default-namespace/#what-if-you-specify-a-container-s-request-but-not-its-limit" rel="nofollow noreferrer">docs</a> the default value will be assigned.
When I explicitly set limits.cpu to 0, I got an error that tells me requests value 20m should be less than or equal to limits value.</p>
<p>So is it possible to force no limits in that case?</p>
| <p>After more research, it is not possible to achieve. It does make sense to me it is not possible as stated by Frank Gu: <strong>because that would pretty much defeat the purpose of resource quotas in the first place</strong></p>
|
<p>Situation: </p>
<ul>
<li>server A: we run Gitlab in a container. </li>
<li>server B: we have Kubernetes.</li>
</ul>
<p>Gitlab uses Kubernetes runner. Some of our projects then build applications using docker container with Git and Maven.</p>
<p>Maven always has to download all kinds of things into it's /root/.m2 cache.
What I need to do is create a persistent volume that these jobs can use, so once it's downloaded, it doesn't have to do it again each time someone wants to build or test something. These containers are always built anew using one premade image.</p>
<p>Pretty basic stuff except I am absolutely new to Gitlab and Kubernetes.</p>
<p>Where do I need to create the volume? I tried to change config.toml in the runner to include host_path type volume, but I don't know if I succeeded and Maven certainly has to download all the requirements every time. I don't even know if the runner container has to be restarted for the changes to be applicated, and how.
This is the runner's config.toml :</p>
<pre><code>listen_address = "[::]:9252"
concurrent = 4
check_interval = 3
log_level = "info"
[session_server]
session_timeout = 1800
[[runners]]
name = "runner-gitlab-runner-c55d9bf98-2nn7c"
url = "https://private_network:8443/"
token = "yeah, token"
executor = "kubernetes"
[runners.cache]
[runners.cache.s3]
[runners.cache.gcs]
[runners.kubernetes]
host = ""
bearer_token_overwrite_allowed = false
image = "ubuntu:16.04"
namespace = "gitlab-managed-apps"
namespace_overwrite_allowed = ""
privileged = true
service_account_overwrite_allowed = ""
pod_annotations_overwrite_allowed = ""
[runners.kubernetes.volumes.host_path]
name = "maven-volume"
mount_path = "/root/.m2"
read_only = false
</code></pre>
<p>I don't know enough to know what I am missing. Maybe I have to define something in .gitlab-ci.yml in those projects, or something else. I have looked into tutorials, I have tried Gitlab help pages, but I still can't find a working solution.</p>
<p>Running GitLab Community Edition 11.6.5.</p>
| <p>1) Create a Kubernetes PersistentVolume (I use NFS as PersistentVolume type) :</p>
<pre><code>apiVersion: v1
kind: PersistentVolume
metadata:
name: gitlabrunner-nfs-volume
spec:
accessModes:
- ReadWriteMany
capacity:
storage: 15Gi
mountOptions:
- nolock
nfs:
path: /kubernetes/maven/
server: NFS_SERVER_IP
persistentVolumeReclaimPolicy: Recycle
</code></pre>
<p>2) create a Kubernetes PersistentVolumeClaim : </p>
<pre><code>apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: gitlabrunner-claim
namespace: gitlab
spec:
accessModes:
- ReadWriteMany
resources:
requests:
storage: 15Gi
volumeName: gitlabrunner-nfs-volume
status:
accessModes:
- ReadWriteMany
capacity:
storage: 15Gi
</code></pre>
<p>3) Refer the PersistentVolumeClaim in your config.toml :</p>
<pre><code> [[runners.kubernetes.volumes.pvc]]
mount_path = "/cache/maven.repository"
name = "gitlabrunner-claim"
</code></pre>
<p>This enables to mount the volume each time a container is launched with this configuration. </p>
<p>4) in .gitlab-ci.yml file, set the MVN_OPTS like answered by @thomas :</p>
<pre><code>variables:
MVN_OPTS: "-Dmaven.repo.local=/cache/maven.repository"
</code></pre>
|
<p>After trying with various providers(bare kubernetes, openshift, aws eks) we have found that even if node has enough resources(cpu, ram, hdd) after reaching ~110 pods new pods are hanging in Pending state without any events or errors except the event </p>
<pre><code>"Successfully assigned {namespace}/{pod_name} to {node_name}"
</code></pre>
<p>We have tried to search for any related logs in kubelet, scheduler, etc - but there is nothing except this event mentioned earlier.</p>
<p>Did someone succeed in running more than 110 pods per node? What are we doing wrong?</p>
<p>The only thing worth mentioning additionally is that in our case it is not 110 replicas of same pod but a 110 various pods from various deployments/daemon sets. And of course we have tweaked node pod_limit > 110.</p>
| <p>kunernetes supports 110 pods per node. There are requests coming from multiple channels to increase the pods per node.</p>
<p>There is PR raised to support 500 pods per node. it is still open though. you can track the status at the below link</p>
<p><a href="https://github.com/kubernetes/kubernetes/issues/23349" rel="nofollow noreferrer">PR to support 500 pods per node</a></p>
|
<p>I'm deploying a Spring Boot app in minikube that connects to a database running on the host. Following the 12 factor app recommendations I use environment variables for the necessary configuration:</p>
<pre><code>SPRING_DATASOURCE_DRIVER_CLASS_NAME=org.postgresql.Driver
SPRING_DATASOURCE_PASSWORD=...
SPRING_DATASOURCE_URL=jdbc:postgresql://<HOST_IP_FROM_K8S>:5432/myservice
SPRING_DATASOURCE_USERNAME=...
</code></pre>
<p>The kubernetes docs only show how to set environment variables in the service and deployment .yaml files which I don't want to do. Is there a way to pass environment variables on the command line for minikube or kubectl when I create the deployment? (In Docker I do this with -e.)</p>
<p>Note that the environment variables have to be set before starting the app or it crashes.</p>
| <p>Following Ansil's comment above I used <code>configmap</code> and <code>secret</code> to pass the configuration like this:</p>
<pre><code>kubectl create secret generic springdatasourcepassword --from-literal=SPRING_DATASOURCE_PASSWORD=postgres
kubectl create secret generic springdatasourceusername --from-literal=SPRING_DATASOURCE_USERNAME=postgres
kubectl create configmap springdatasourcedriverclassname --from-literal=SPRING_DATASOURCE_DRIVER_CLASS_NAME=org.postgresql.Driver
kubectl create configmap springdatasourceurl --from-literal=SPRING_DATASOURCE_URL=jdbc:postgresql://172.18.0.1:5432/bookservice
</code></pre>
<p>These are referenced in the deployment.yaml file like this:</p>
<pre><code>env:
- name: GET_HOSTS_FROM
value: dns
- name: SPRING_DATASOURCE_DRIVER_CLASS_NAME
valueFrom:
configMapKeyRef:
name: springdatasourcedriverclassname
key: SPRING_DATASOURCE_DRIVER_CLASS_NAME
- name: SPRING_DATASOURCE_URL
valueFrom:
configMapKeyRef:
name: springdatasourceurl
key: SPRING_DATASOURCE_URL
- name: SPRING_DATASOURCE_PASSWORD
valueFrom:
secretKeyRef:
name: springdatasourcepassword
key: SPRING_DATASOURCE_PASSWORD
- name: SPRING_DATASOURCE_USERNAME
valueFrom:
secretKeyRef:
name: springdatasourceusername
key: SPRING_DATASOURCE_USERNAME
</code></pre>
<p>A full explanation can be found <a href="https://medium.com/google-cloud/kubernetes-configmaps-and-secrets-68d061f7ab5b" rel="nofollow noreferrer">here</a>.</p>
|
<p>I am facing issue. I am trying to access Kubernetes API from Docker Container (Created .NetCore). I am getting Error Message <strong>"Connection Refused"</strong>.</p>
<p>Can anyone help?
I shall be thankful.</p>
<pre><code>using (HttpClient client = new HttpClient()) {
var request_json = JsonConvert.SerializeObject(obj).ToString();
var content = new StringContent(request_json, Encoding.UTF8, "application/json");
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", "Token");
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
client.DefaultRequestHeaders.Connection.Add("close");
var result = await client.PostAsync("http://127.0.0.1:8001/apis/batch/v1/namespaces/default", content);
var result_string = await result.Content.ReadAsStringAsync()`enter code here`;
return result_string.ToString();
}
</code></pre>
| <p>If your docker container is running inside a kubernetes cluster, you can access the kubernetes API through a service. In the default namespace the service is already provided as <code>kubernetes</code>, so the connection url would be <code>https://kubernetes/</code>.</p>
<p>If you are running the docker container locally and want to use the <code>kubectl proxy</code> to access the kubernetes api the docker container must be running without network isolation in order to be able to access the local proxy port: <code>docker run --net=host</code>. This only works if you are using linux, on MacOS or Windows a virtual machine is used to host the docker containers and <code>localhost</code> is then the VM, not your desktop. You would then use one of the special host names <code>docker.for.mac.host.internal</code> or <code>docker.for.win.localhost</code>, but you will need to launch the kubectl-proxy accordingly to listen not only on the loopback network interface, since the request will come from the docker-vm, which is external.</p>
<p>BTW: If you are using kubectl-proxy, it will automatically authenticate the requests and there is no need to add a bearer token.</p>
|
<p>I am new to Kubernetes and Minikube.
I was trying to run <code>kubectl apply -f ./deployment.yaml</code></p>
<p>I tried to put version apps/v1beta1 as the error showed, but it's still wrong.</p>
<p>Error:
<code>error: SchemaError(io.k8s.api.storage.v1beta1.CSINodeDriver): invalid object doesn't have additional properties</code></p>
<p>Here's my yaml file:</p>
<pre><code>apiVersion: apps/v1beta2
kind: Deployment
metadata:
name: tomcat-deployment
spec:
selector:
matchLabels:
app: tomcat
replicas: 1
template:
metadata:
labels:
app: tomcat
spec:
containers:
- name: tomcat
image: tomcat:9.0
ports:
- containerPort: 8080
</code></pre>
<p>Expected output:</p>
<p>deployment "tomcat-deployment" created</p>
| <p>tl;dr</p>
<p>It's a version issue. I had 1.10, and the working is 1.14.</p>
<hr>
<p>Apparently the <code>kubectl version</code> of my mac is 1.10. </p>
<p>I tried to see if I can do a <code>brew install kubectl</code> and it said that I already have kubectl.</p>
<pre><code>Warning: kubernetes-cli 1.14.0 is already installed, it's just not linked
You can use `brew link kubernetes-cli` to link this version.
To force the link and overwrite all conflicting files:
brew link --overwrite kubernetes-cli
</code></pre>
<p>I saw that the current version in my local is 1.10. and homebrew is saying 1.14</p>
<p>I overwrote the symlink via brew link, and it worked.</p>
|
<p>When I am using <code>kubectl get namespace</code> command in my Kubernetes master node, I am getting proper output. And also I configured kubectl in my local machine. When I am running the same command from local machine configured with kubectl, I am getting error like the following,</p>
<pre><code>Error from server (Forbidden): namespaces is forbidden: User "system:node:mildevkub020" cannot list resource "namespaces" in API group "" at the cluster scope
</code></pre>
<p>I copied the configuration file kubelet.conf from cluster and copied into .kube/config. And also installed the kubectl. This is the process what did till now.</p>
<p>Result of kubectl config view is like the following,</p>
<p><a href="https://i.stack.imgur.com/nAZO2.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/nAZO2.png" alt="enter image description here"></a></p>
<p>How can I resolve this issue?</p>
| <p>Kubespray by default saves cluster admin kubeconfig file as inventory/mycluster/artifacts/admin.conf. Read more here: <a href="https://github.com/kubernetes-sigs/kubespray/blob/master/docs/getting-started.md#accessing-kubernetes-api" rel="nofollow noreferrer">https://github.com/kubernetes-sigs/kubespray/blob/master/docs/getting-started.md#accessing-kubernetes-api</a> </p>
|
<p>I have a service that, in some contexts, sends requests to itself.
I can reach the service from outside the cluster, but the self-requests fail (time-out).</p>
<p>Environment: </p>
<ul>
<li>minikube v0.34.1</li>
<li>Linux version 4.15.0 (jenkins@jenkins) (gcc version 7.3.0 (Buildroot 2018.05)) #1 SMP Fri Feb 15 19:27:06 UTC 2019</li>
</ul>
<p>I've been using <a href="https://kubernetes.io/docs/tasks/debug-application-cluster/debug-service/#a-pod-cannot-reach-itself-via-service-ip" rel="nofollow noreferrer">https://kubernetes.io/docs/tasks/debug-application-cluster/debug-service/#a-pod-cannot-reach-itself-via-service-ip</a> as a troubleshooting guide, but I'm down the step that says "seek help".</p>
<p>Troubleshooting results:</p>
<pre><code>journalctl -u kubelet | grep -i hairpin
Feb 26 19:57:10 minikube kubelet[3066]: W0226 19:57:10.124151 3066 docker_service.go:540] Hairpin mode set to "promiscuous-bridge" but kubenet is not enabled, falling back to "hairpin-veth"
Feb 26 19:57:10 minikube kubelet[3066]: I0226 19:57:10.124295 3066 docker_service.go:236] Hairpin mode set to "hairpin-veth"
</code></pre>
<p>The troubleshooting guide indicates that "hairpin-veth" is OK.</p>
<pre><code>for intf in /sys/devices/virtual/net/docker0/brif/veth*; do cat $intf/hairpin_mode; done
0
...
0
</code></pre>
<p>Note that the guide used <code>/sys/devices/virtual/net/cbr0/brif/*</code>, but in this version of minikube, the path is <code>/sys/devices/virtual/net/docker0/brif/veth*</code>. I'd like to understand why the paths are different, but it appears that hairpin_mode is not enabled.</p>
<p>The next step in the guide is: <code>Seek help if none of above works out.</code></p>
<ol>
<li>Am I correct in believing that I need to enable hairpin_mode?</li>
<li>If so, how do I do so?</li>
</ol>
| <p>It seems like known issue, more information <a href="https://github.com/kubernetes/minikube/issues/1568" rel="nofollow noreferrer">here</a>: </p>
<p>As workaround you can try:</p>
<pre><code>minikube ssh -- sudo ip link set docker0 promisc on
</code></pre>
<p>Please share with the reulsts.</p>
|
<p>I have the following in my Dockerfile to run my Springboot app:</p>
<pre><code>ENTRYPOINT [ "java", "-jar", "/code/myapp/target/myapp.jar", "--spring.profiles.active=$ENV_PROFILE"]
</code></pre>
<p>I defined my environment variable (ENV_PROFILE) in my k8 YAML config as:</p>
<pre><code> spec:
containers:
- name: myspringboot
image: myrepo/myapp:latest
imagePullPolicy: Always
resources:
requests:
cpu: 100m
memory: 100Mi
env:
- name: ENV_PROFILE
value: "test"
</code></pre>
<p>However, the environment name is not getting injected into the java springboot app. It shows as "$ENV_PROFILE" in the log. I also tried with application.properties by adding <code>spring.profiles.active=$ENV_PROFILE</code>
and that does not work either.</p>
| <p>You can also override the Spring properties (and other properties defined in the application properties) by default, without specifying what environment variable to pass in your properties file. Environment variables have higher precedence then the properties file values. </p>
<p>See also <a href="https://docs.spring.io/spring-boot/docs/current/reference/html/boot-features-external-config.html" rel="noreferrer">Spring Externalized Configuration</a>.</p>
<p>For example:</p>
<pre><code> spec:
containers:
- name: myspringboot
image: myrepo/myapp:latest
imagePullPolicy: Always
resources:
requests:
cpu: 100m
memory: 100Mi
env:
- name: SPRING_PROFILES_ACTIVE
value: "test"
</code></pre>
|
<p>I am running some services in minikube and trying to connect to mysql running on localhost(127.0.0.1) on 3306 port. </p>
<p>I read <a href="https://stackoverflow.com/a/43477742/9958058">this</a> and trying to create <code>service</code> and <code>Endpoints</code>. However, when I specify <code>127.0.0.1</code> as IP, it throws error as below:</p>
<p><code>The Endpoints "mysql-service" is invalid: subsets[0].addresses[0].ip: Invalid value: "127.0.0.1": may not be in the loopback range (127.0.0.0/8)</code></p>
<p>my deployment is like below:</p>
<pre><code>---
apiVersion: v1
kind: Service
metadata:
name: mysql-service
spec:
ports:
- protocol: TCP
port: 1443
targetPort: mysql
---
apiVersion: v1
kind: Endpoints
metadata:
name: mysql-service
subsets:
- addresses:
- ip: 127.0.0.1
ports:
- name: mysql
port: 3306
</code></pre>
<p>Please assist me to understand how can I connect to <code>mysql</code> db from <code>minikube</code>.</p>
<p>I have also tried replacing <code>127.0.0.1</code> with public IP of my computer(Don't know why though) and connection was timed out.</p>
<p>Any help or guide towards right direction is appreciated.</p>
| <p>As the OS and minikube <code>vm-driver</code> wasn't mentioned, I assume it is <code>--vm-driver=virtualbox</code> because it's probably most common case. If you use something different you need to adjust this solution according to your configuration.</p>
<h3>Explanation:</h3>
<p><code>127.0.0.1</code> is a <code>localhost</code>(<code>lo0</code>) interface IP address. Nodes, Hosts and Pods have their own localhost interfaces and they are not connected to each other.</p>
<p>Your <code>mysql-server</code> is running on the Host machine and cannot be accessible using the <code>localhost</code> (or it's IP range) from inside a minikube cluster pod or from inside minikube vm.</p>
<h3>Solution:</h3>
<ol>
<li><p>You should have a network between minikube VM and the host. Default NAT network in Virtualbox is not good for that, so it's better to create another host-only network. Let's <a href="https://www.techrepublic.com/article/how-to-create-virtualbox-networks-with-the-host-network-manager/" rel="noreferrer">create</a> additional host-only network in Virtualbox UI with the name <code>vmnet2</code> and IP range <code>192.168.77.1/24</code> . You don't need to enable DHCP for that network.</p>
</li>
<li><p>You have to configure mysql to listen on the interface vmnet2 or ip <code>192.168.77.1</code> which is by default used for the host machine. Check if it's accessible from the host:</p>
</li>
</ol>
<pre><code>mysql -h 192.168.77.1 -u root -p
</code></pre>
<ol start="3">
<li><p>To attach this network to minikube VM --host-only-cidr key should be used. Different type of <code>vm-driver</code> use different cli options for this purpose. Check the <code>minikube start --help</code> output. So, for <code>virtualbox</code> it will look like the following:</p>
<pre><code>minikube start --cpus 2 \
--memory 2048 \
--disk-size 20g \
--vm-driver virtualbox \
--network-plugin flannel \
--kubernetes-version v1.12.2 \
--host-only-cidr 192.168.77.1/24
</code></pre>
<p>I wrote other most common cli options just for convenience.</p>
<p>MinikubeVM will get the following IP address: <code>192.168.77.100</code> (<a href="https://stackoverflow.com/questions/53871053/how-to-completely-purge-minikube-config-or-reset-ip-back-to-192-168-99-100">at least the first time.</a>)
You can check it using <code>minikube ssh</code> and then <code>ifconfig</code> commands.</p>
</li>
<li><p>Last part - we need to create a Service and Endpoint for it inside the <code>minikube</code> cluster:</p>
</li>
</ol>
<pre><code>kubectl apply -f mysql-service.yaml
</code></pre>
<p>Here is a content of the <code>mysql-service.yaml</code> file:</p>
<pre><code>---
apiVersion: v1
kind: Service
metadata:
name: mysql-service
spec:
type: ClusterIP
ports:
- protocol: TCP
port: 3306
targetPort: 3306
---
apiVersion: v1
kind: Endpoints
metadata:
name: mysql-service
subsets:
- addresses:
- ip: 192.168.77.1
ports:
- port: 3306
</code></pre>
<ol start="5">
<li>Now we can use the <code>mysql-service</code> name and port <code>3306</code> inside any pod of this cluster as a destination point.</li>
</ol>
|
<p>I have installed the rabbitmq cluster using helm chart. Rabbitmq using statefulsets so is there any way to auto scale this ? </p>
<p>Also one more question how to auto scale (HPA) deployment having PVC ? </p>
| <p>StatefulSets can be autoscaled with HPA:</p>
<pre><code>apiVersion: autoscaling/v2beta1
kind: HorizontalPodAutoscaler
metadata:
annotations:
name: some-service
spec:
maxReplicas: 4
metrics:
- resource:
name: memory
targetAverageUtilization: 80
type: Resource
- resource:
name: cpu
targetAverageUtilization: 80
type: Resource
minReplicas: 2
scaleTargetRef:
apiVersion: apps/v1
kind: StatefulSet
name: some-service
</code></pre>
<p>Regarding PVC and StatefulSets and HPA - I'm not sure but I think that depends on reclaimPolicy of StorageClass of your PVC. Just make sure you have <code>reclaimPolicy: Retain</code> in your StorageClass definition. Having that you should preserve data on scaling events.</p>
<p>If you mean Deployments with HPA and PVC - it should work, but always remember that if you have multiple replicas with one shared PVC - all replicas will try to mount it. If PVC is ReadWriteMany - there should be no issues. If it is ReadWriteOnce - then all replicas will be scheduled on one node. If there is not enough resources on node to fit all replicas - you will get some pods in Pending state forever.</p>
|
<p>Is there any way to run Firecracker inside Docker container.</p>
<p>I tried the basic networking in firecracker although having containerized firecracker can have many benefits</p>
<ol>
<li>No hurdle to create and manage overlay network and attach</li>
<li>Deploy in Docker swarm and in Kubernetes</li>
<li>No need to clean IPTables/Network rules
etc.</li>
</ol>
| <p>You can use kata-containers to simplify</p>
<p><a href="https://github.com/kata-containers/documentation/wiki/Initial-release-of-Kata-Containers-with-Firecracker-support" rel="nofollow noreferrer">https://github.com/kata-containers/documentation/wiki/Initial-release-of-Kata-Containers-with-Firecracker-support</a></p>
|
<p>I am new to Docker and Kubernetes.
Technologies used:</p>
<ul>
<li>Dotnet Core 2.2</li>
<li>Asp.NET Core WebAPI 2.2</li>
<li>Docker for windows(Edge) with Kubernetes support enabled</li>
<li><a href="https://github.com/vkgpt11/StackOverFlowSuppot/tree/master/DotnetCore" rel="nofollow noreferrer">Code</a> </li>
</ul>
<p>I am having two services hosted into two docker containers container1 and container2. </p>
<p>Below is my deploy.yaml</p>
<pre><code>apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: webapi-dockerkube
spec:
replicas: 1
template:
metadata:
labels:
app: webapi-dockerkube
spec:
containers:
- name: webapi-dockerkube
image: "webapidocker:latest"
imagePullPolicy: IfNotPresent
ports:
- containerPort: 80
livenessProbe:
httpGet:
path: /api/values
port: 80
readinessProbe:
httpGet:
path: /api/values
port: 80
- name: webapi-dockerkube2
image: "webapidocker2:latest"
imagePullPolicy: IfNotPresent
ports:
- containerPort: 80
livenessProbe:
httpGet:
path: /api/other/values
port: 80
readinessProbe:
httpGet:
path: /api/other/values
port: 80
</code></pre>
<p>When I am running command:</p>
<pre><code>kubectl create -f .\deploy.yaml
</code></pre>
<p>I am getting status as <code>CrashLoopBackOff</code>. </p>
<p>But same is running fine when i have only one container configured.
When checking logs I am getting following error:
<code>Error from server (BadRequest): a container name must be specified for pod webapi-dockerkube-8658586998-9f8mk, choose one of: [webapi-dockerkube webapi-dockerkube2]</code></p>
| <p>You are running two containers in the same pod which bind both to port 80. This is not possible within the same pod.
Think of a pod like a 'server' and you can't have two processes bind to the same port.</p>
<p>Solution in your situation: Use different ports inside the pod or use separate pods. From your deployment there seems to be no shared resources like filesystem, so it would be easy to split the containers to separate pods.</p>
<p>Note that it will not suffice to change the pod definition if you want to have both containers running in the same pod with different ports. The application in the container must bind to a different port as well. </p>
|
<p>i am trying to deploy a cluster of etcd+flanneld+kubernetes on CentOS machines. etcd and flanneld are running fine. But not kubernetes.</p>
<p>My environment:</p>
<pre><code>coreos05: CentOS7 - 192.168.0.114
coreos08: CentOS7 - 192.168.2.57
</code></pre>
<p>ETCD:</p>
<pre><code>[root@coreos05 ~]# etcdctl -C 192.168.0.114:4001 member list
e83ffc60b9b71862: name=coreos05 peerURLs=http://coreos05:2380,http://coreos05:7001 clientURLs=http://192.168.0.114:2379,http://192.168.0.114:4001
f877fb31ab0f7105: name=coreos08 peerURLs=http://coreos08:2380,http://coreos08:7001 clientURLs=http://192.168.2.57:2379,http://192.168.2.57:4001
[root@coreos05 ~]# etcdctl -C 192.168.2.57:4001 member list
e83ffc60b9b71862: name=coreos05 peerURLs=http://coreos05:2380,http://coreos05:7001 clientURLs=http://192.168.0.114:2379,http://192.168.0.114:4001
f877fb31ab0f7105: name=coreos08 peerURLs=http://coreos08:2380,http://coreos08:7001 clientURLs=http://192.168.2.57:2379,http://192.168.2.57:4001
</code></pre>
<p>INTER-NODE COMMUNICATIONS BETWEEN ECTD AND FLANNELD:</p>
<pre><code>[root@coreos05 ~]# netstat -putona | egrep 'etcd|flanneld' |grep 2.57
tcp 0 0 192.168.0.114:4001 192.168.2.57:42996 ESTABLISHED 16288/etcd keepalive (14,65/0/0)
tcp 0 0 192.168.0.114:2380 192.168.2.57:32817 ESTABLISHED 16288/etcd off (0.00/0/0)
[root@coreos05 ~]#
</code></pre>
<p>STATUS OF ALL SERVICES IN THE MASTER:</p>
<pre><code>[root@coreos05 ~]# for SERVICES in etcd flanneld kube-apiserver kube-controller-manager kube-scheduler; do systemctl status $SERVICES ; done
etcd.service - Etcd Server
Loaded: loaded (/usr/lib/systemd/system/etcd.service; enabled)
Active: active (running) since mar 2015-05-12 11:54:16 CEST; 33min ago
Main PID: 16590 (etcd)
CGroup: /system.slice/etcd.service
└─16590 /usr/bin/etcd
may 12 11:54:16 coreos05 etcd[16590]: 2015/05/12 11:54:16 raft: e83ffc60b9b71862 became follower at term 46
may 12 11:54:16 coreos05 etcd[16590]: 2015/05/12 11:54:16 raft: newRaft e83ffc60b9b71862 [peers: [], term: 46, commit: 5235, applied: 0, lastindex: 5235, lastterm: 46]
may 12 11:54:16 coreos05 etcd[16590]: 2015/05/12 11:54:16 etcdserver: added local member e83ffc60b9b71862 [http://coreos05:2380 http://coreos05:7001] to cluster 85bb0f76f652d0f6
may 12 11:54:16 coreos05 etcd[16590]: 2015/05/12 11:54:16 etcdserver: added member f877fb31ab0f7105 [http://coreos08:2380 http://coreos08:7001] to cluster 85bb0f76f652d0f6
may 12 11:54:17 coreos05 etcd[16590]: 2015/05/12 11:54:17 raft: e83ffc60b9b71862 [term: 46] received a MsgVote message with higher term from f877fb31ab0f7105 [term: 47]
may 12 11:54:17 coreos05 etcd[16590]: 2015/05/12 11:54:17 raft: e83ffc60b9b71862 became follower at term 47
may 12 11:54:17 coreos05 etcd[16590]: 2015/05/12 11:54:17 raft: e83ffc60b9b71862 [logterm: 46, index: 5235, vote: 0] voted for f877fb31ab0f7105 [logterm: 46, index: 5235] at term 47
may 12 11:54:17 coreos05 etcd[16590]: 2015/05/12 11:54:17 raft.node: e83ffc60b9b71862 elected leader f877fb31ab0f7105 at term 47
may 12 11:54:17 coreos05 etcd[16590]: 2015/05/12 11:54:17 rafthttp: starting client stream to f877fb31ab0f7105 at term 47
may 12 11:54:17 coreos05 etcd[16590]: 2015/05/12 11:54:17 etcdserver: published {Name:coreos05 ClientURLs:[http://192.168.0.114:2379 http://192.168.0.114:4001]} to cluster 85bb0f76f652d0f6
flanneld.service - Flanneld overlay address etcd agent
Loaded: loaded (/usr/lib/systemd/system/flanneld.service; enabled)
Active: active (running) since mar 2015-05-12 11:54:17 CEST; 33min ago
Main PID: 16611 (flanneld)
CGroup: /system.slice/flanneld.service
└─16611 /usr/bin/flanneld -etcd-endpoints=http://192.168.0.114:4001 -etcd-prefix=/kuberdock/network/ --iface=enp3s0
may 12 11:54:17 coreos05 systemd[1]: Starting Flanneld overlay address etcd agent...
may 12 11:54:17 coreos05 flanneld[16611]: I0512 11:54:17.024119 16611 main.go:247] Installing signal handlers
may 12 11:54:17 coreos05 flanneld[16611]: I0512 11:54:17.025078 16611 main.go:205] Using 192.168.0.114 as external interface
may 12 11:54:17 coreos05 flanneld[16611]: I0512 11:54:17.868493 16611 subnet.go:83] Subnet lease acquired: 10.10.93.0/24
may 12 11:54:17 coreos05 flanneld[16611]: I0512 11:54:17.869081 16611 main.go:215] UDP mode initialized
may 12 11:54:17 coreos05 flanneld[16611]: I0512 11:54:17.869106 16611 udp.go:239] Watching for new subnet leases
may 12 11:54:17 coreos05 flanneld[16611]: I0512 11:54:17.871602 16611 udp.go:264] Subnet added: 10.10.65.0/24
may 12 11:54:17 coreos05 systemd[1]: Started Flanneld overlay address etcd agent.
kube-apiserver.service - Kubernetes API Server
Loaded: loaded (/usr/lib/systemd/system/kube-apiserver.service; enabled)
Drop-In: /etc/systemd/system/kube-apiserver.service.d
└─pre-start.conf
Active: active (running) since mar 2015-05-12 11:54:17 CEST; 33min ago
Docs: https://github.com/GoogleCloudPlatform/kubernetes
Main PID: 16690 (kube-apiserver)
CGroup: /system.slice/kube-apiserver.service
└─16690 /usr/bin/kube-apiserver --logtostderr=true --v=0 --etcd_servers=http://coreos05:4001 --address=0.0.0.0 --port=8080 --kubelet_port=10250 --allow_privileged=false --portal_net=10.10.0.0/16 --admission_control=Namespac...
may 12 11:54:17 coreos05 kube-apiserver[16690]: E0512 11:54:17.985524 16690 reflector.go:123] Failed to list *api.Namespace: Get http://0.0.0.0:8080/api/v1beta3/namespaces: dial tcp 0.0.0.0:8080: connection refused
may 12 11:54:17 coreos05 kube-apiserver[16690]: I0512 11:54:17.986149 16690 master.go:236] Will report 192.168.0.114 as public IP address.
may 12 11:54:17 coreos05 kube-apiserver[16690]: E0512 11:54:17.987132 16690 reflector.go:123] Failed to list *api.LimitRange: Get http://0.0.0.0:8080/api/v1beta3/limitranges: dial tcp 0.0.0.0:8080: connection refused
may 12 11:54:17 coreos05 kube-apiserver[16690]: E0512 11:54:17.987437 16690 reflector.go:123] Failed to list *api.ResourceQuota: Get http://0.0.0.0:8080/api/v1beta3/resourcequotas: dial tcp 0.0.0.0:8080: connection refused
may 12 11:54:18 coreos05 kube-apiserver[16690]: [restful] 2015/05/12 11:54:18 log.go:30: [restful/swagger] listing is available at https://192.168.0.114:6443/swaggerapi/
may 12 11:54:18 coreos05 kube-apiserver[16690]: [restful] 2015/05/12 11:54:18 log.go:30: [restful/swagger] https://192.168.0.114:6443/swaggerui/ is mapped to folder /swagger-ui/
may 12 11:54:18 coreos05 kube-apiserver[16690]: I0512 11:54:18.093361 16690 server.go:353] Serving read-only insecurely on 0.0.0.0:7080
may 12 11:54:18 coreos05 kube-apiserver[16690]: I0512 11:54:18.093784 16690 server.go:390] Serving securely on 0.0.0.0:6443
may 12 11:54:18 coreos05 kube-apiserver[16690]: I0512 11:54:18.100679 16690 server.go:418] Serving insecurely on 0.0.0.0:8080
may 12 11:54:18 coreos05 kube-apiserver[16690]: I0512 11:54:18.925329 16690 server.go:400] Using self-signed cert (/var/run/kubernetes/apiserver.crt, /var/run/kubernetes/apiserver.key)
kube-controller-manager.service - Kubernetes Controller Manager
Loaded: loaded (/usr/lib/systemd/system/kube-controller-manager.service; enabled)
Active: active (running) since mar 2015-05-12 11:54:18 CEST; 33min ago
Docs: https://github.com/GoogleCloudPlatform/kubernetes
Main PID: 16714 (kube-controller)
CGroup: /system.slice/kube-controller-manager.service
└─16714 /usr/bin/kube-controller-manager --logtostderr=true --v=0 --machines=coreos08
may 12 12:26:48 coreos05 kube-controller-manager[16714]: I0512 12:26:48.282325 16714 nodecontroller.go:504] Evicting pods2: 2015-05-12 12:26:48.282313291 +0200 CEST is later than 2015-05-12 12:26:48.282311109 +0200 CEST + 4m20s
may 12 12:26:53 coreos05 kube-controller-manager[16714]: I0512 12:26:53.468254 16714 nodecontroller.go:504] Evicting pods2: 2015-05-12 12:26:53.468242266 +0200 CEST is later than 2015-05-12 12:26:53.468240541 +0200 CEST + 4m20s
may 12 12:26:58 coreos05 kube-controller-manager[16714]: I0512 12:26:58.677179 16714 nodecontroller.go:504] Evicting pods2: 2015-05-12 12:26:58.677166286 +0200 CEST is later than 2015-05-12 12:26:58.67716449 +0200 CEST + 4m20s
may 12 12:27:03 coreos05 kube-controller-manager[16714]: I0512 12:27:03.778387 16714 nodecontroller.go:504] Evicting pods2: 2015-05-12 12:27:03.778376111 +0200 CEST is later than 2015-05-12 12:27:03.778374466 +0200 CEST + 4m20s
may 12 12:27:08 coreos05 kube-controller-manager[16714]: I0512 12:27:08.879548 16714 nodecontroller.go:504] Evicting pods2: 2015-05-12 12:27:08.879537205 +0200 CEST is later than 2015-05-12 12:27:08.879535608 +0200 CEST + 4m20s
may 12 12:27:13 coreos05 kube-controller-manager[16714]: I0512 12:27:13.980986 16714 nodecontroller.go:504] Evicting pods2: 2015-05-12 12:27:13.980974374 +0200 CEST is later than 2015-05-12 12:27:13.980972639 +0200 CEST + 4m20s
may 12 12:27:19 coreos05 kube-controller-manager[16714]: I0512 12:27:19.574960 16714 nodecontroller.go:504] Evicting pods2: 2015-05-12 12:27:19.574947254 +0200 CEST is later than 2015-05-12 12:27:19.574945586 +0200 CEST + 4m20s
may 12 12:27:24 coreos05 kube-controller-manager[16714]: I0512 12:27:24.699798 16714 nodecontroller.go:504] Evicting pods2: 2015-05-12 12:27:24.699787548 +0200 CEST is later than 2015-05-12 12:27:24.699785704 +0200 CEST + 4m20s
may 12 12:27:29 coreos05 kube-controller-manager[16714]: I0512 12:27:29.876981 16714 nodecontroller.go:504] Evicting pods2: 2015-05-12 12:27:29.876968588 +0200 CEST is later than 2015-05-12 12:27:29.876966413 +0200 CEST + 4m20s
may 12 12:27:34 coreos05 kube-controller-manager[16714]: I0512 12:27:34.988483 16714 nodecontroller.go:504] Evicting pods2: 2015-05-12 12:27:34.988471519 +0200 CEST is later than 2015-05-12 12:27:34.988469853 +0200 CEST + 4m20s
kube-scheduler.service - Kubernetes Scheduler Plugin
Loaded: loaded (/usr/lib/systemd/system/kube-scheduler.service; enabled)
Active: active (running) since mar 2015-05-12 11:54:18 CEST; 33min ago
Docs: https://github.com/GoogleCloudPlatform/kubernetes
Main PID: 16734 (kube-scheduler)
CGroup: /system.slice/kube-scheduler.service
└─16734 /usr/bin/kube-scheduler --logtostderr=true --v=0
may 12 11:54:18 coreos05 systemd[1]: kube-scheduler.service: main process exited, code=exited, status=2/INVALIDARGUMENT
may 12 11:54:18 coreos05 systemd[1]: Unit kube-scheduler.service entered failed state.
may 12 11:54:18 coreos05 systemd[1]: Starting Kubernetes Scheduler Plugin...
may 12 11:54:18 coreos05 systemd[1]: Started Kubernetes Scheduler Plugin.
may 12 11:54:18 coreos05 kube-scheduler[16734]: W0512 11:54:18.139880 16734 server.go:83] Neither --kubeconfig nor --master was specified. Using default API client. This might not work.
may 12 12:09:18 coreos05 kube-scheduler[16734]: E0512 12:09:18.150197 16734 reflector.go:158] watch of *api.Service ended with: very short watch
may 12 12:09:18 coreos05 kube-scheduler[16734]: E0512 12:09:18.156710 16734 reflector.go:158] watch of *api.Node ended with: very short watch
may 12 12:24:19 coreos05 kube-scheduler[16734]: E0512 12:24:19.154734 16734 reflector.go:158] watch of *api.Service ended with: very short watch
may 12 12:24:19 coreos05 kube-scheduler[16734]: E0512 12:24:19.160947 16734 reflector.go:158] watch of *api.Node ended with: very short watch
</code></pre>
<p>NOTE errors in kube-apiserver.service</p>
<pre><code>Failed to list *api.Namespace: Get http://0.0.0.0:8080/api/v1beta3/namespaces: dial tcp 0.0.0.0:8080: connection refused
</code></pre>
<p>KUBECTL NODE STATUS:</p>
<pre><code> [root@coreos05 ~]# kubectl get node
NAME LABELS STATUS
coreos08 <none> NotReady
</code></pre>
<p>Why nodes are not ready?</p>
| <p>I can think of three possible cases due to which you might be facing this issue. Whenever I have seen that one/more nodes are in Not ready state, I have observed that either the DNS is not configured properly or network plugin is not running or kubelet is not running.
Since I see that you are using flannel for networking and it is running properly, there problem can be due to the other two reasons.
Try the following to pin point the issue:</p>
<ol>
<li><p>To check whether DNS is properly configured or not, run the following command:</p>
<p>kubectl get pods -o wide --all-namespaces</p></li>
</ol>
<p>Check if the pods with the name kube-dns or coredns are running or not. If it's not running then this is the problem.</p>
<ol start="2">
<li><p>To check whether kubectl is running properly or not, run the following command:</p>
<p>systemctl get status kubectl</p></li>
</ol>
<p>If it is not running then we have found the problem.
We have to see the logs of kubectl and fix it.</p>
|
<p>I'm trying to pull a private image from docker hub and every time I get the error "ImagePullBackOff" using describe on the pods I see the error "unauthorized: incorrect username or password", I created the secret in the cluster using the following guide: <a href="https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/" rel="nofollow noreferrer">https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/</a> using the cli method with the correct credentials (I checked and I can login on the website with these one) and this is my yaml file.</p>
<pre><code>apiVersion: apps/v1
kind: Deployment
metadata:
name: app-typescript
labels:
app: app-typescript
spec:
selector:
matchLabels:
app: app-typescript
replicas: 1
minReadySeconds: 15
strategy:
type: RollingUpdate
rollingUpdate:
maxUnavailable: 1
maxSurge: 1
template:
metadata:
labels:
app: app-typescript
spec:
containers:
- name: api
image: dockerhuborg/api:latest
imagePullPolicy: Always
env:
- name: "ENV_TYPE"
value: "production"
- name: "NODE_ENV"
value: "production"
- name: "MONGODB_URI"
value: "mongodb://mongo-mongodb/db"
ports:
- containerPort: 4000
imagePullSecrets:
- name: regcred
</code></pre>
| <p>I found a solution, apparently the problem is that docker hub use different domains for login and containers pulling, so you must edit your secret created with the kubectl command and replace the base64 of .dockerconfigjson with an encoded base64 version of this json (yeah I know maybe I added too much domain but I'm trying to fix this sh*t from about 2 days I don't have patience anymore to find the exact ones) </p>
<pre><code>{
"auths":{
"https://index.docker.io/v1/":{
"username":"user",
"password":"password",
"email":"yourdockeremail@gmail.com",
"auth":"base64 of string user:password"
},
"auth.docker.io":{
"username":"user",
"password":"password",
"email":"yourdockeremail@gmail.com",
"auth":"base64 of string user:password"
},
"registry.docker.io":{
"username":"user",
"password":"password",
"email":"yourdockeremail@gmail.com",
"auth":"base64 of string user:password"
},
"docker.io":{
"username":"user",
"password":"password",
"email":"yourdockeremail@gmail.com",
"auth":"base64 of string user:password"
},
"https://registry-1.docker.io/v2/": {
"username":"user",
"password":"password",
"email":"yourdockeremail@gmail.com",
"auth":"base64 of string user:password"
},
"registry-1.docker.io/v2/": {
"username":"user",
"password":"password",
"email":"yourdockeremail@gmail.com",
"auth":"base64 of string user:password"
},
"registry-1.docker.io": {
"username":"user",
"password":"password",
"email":"yourdockeremail@gmail.com",
"auth":"base64 of string user:password"
},
"https://registry-1.docker.io": {
"username":"user",
"password":"password",
"email":"yourdockeremail@gmail.com",
"auth":"base64 of string user:password"
}
}
}
</code></pre>
|
<p>I'm developing a Go executable on Ubuntu and running a kubernetes cluster in minikube. The pod+container that's running in minikube is based on Ubuntu, and I just want to replace the executable in the container. More or less bypassing the need to remake the container because executable is the only thing that needs to change. When my changes are 'ready' I plan to remake the image the container is based on, etc., but that's down the road.</p>
<p>I'm looking to iterate a bit quicker really.</p>
<p>Is this possible? Is there a better way?</p>
| <p>For development purposes ONLY (quite hacky solution), you can have your Ubuntu-Go container running <code>tail -f /dev/null</code> to keep it from finishing, and use a <code>hostPath</code> to mount the path containing your executable to your container. You can run your Go application by running a <code>kubectl exec</code> and any changes you make to your application on your host will be reflected in the container. You can restart the application, again with <code>kubectl exec</code> whenever the executable is updated.</p>
<p><a href="https://github.com/kubernetes/minikube/blob/master/docs/host_folder_mount.md" rel="nofollow noreferrer">Here</a> is a good readme on how to use minikube's hostPath.</p>
<p>REMEMBER IN PRODUCTION to rebuild your container with the correct binary, define the correct entrypoint, and fix your deployment/pod definition to exclude the hostPath.</p>
|
<p>I am installing Kubernetes on Oracle Virtualbox in my laptop using Kubeadm .
Everything worked fine till i run this command on Kuberenets Worker node to join with Master node
I got the error after running </p>
<pre><code>sudo kubeadm join 192.168.56.100:6443 --token 0i2osm.vsp2mk63v1ypeyjf --discovery-token-ca-cert-hash sha256:18511321fcc4b622628dd1ad2f56dbdd319bf024740d58127818720828cc7bf0
</code></pre>
<p>Error </p>
<pre><code>[preflight] Running pre-flight checks
[WARNING IsDockerSystemdCheck]: detected "cgroupfs" as the Docker cgroup driver. The recommended driver is "systemd". Please follow the guide at https://kubernetes.io/docs/setup/cri/
error execution phase preflight: [preflight] Some fatal errors occurred:
[ERROR DirAvailable--etc-kubernetes-manifests]: /etc/kubernetes/manifests is not empty
[ERROR FileAvailable--etc-kubernetes-kubelet.conf]: /etc/kubernetes/kubelet.conf already exists
[ERROR Port-10250]: Port 10250 is in use
[ERROR FileAvailable--etc-kubernetes-pki-ca.crt]: /etc/kubernetes/pki/ca.crt already exists
[preflight] If you know what you are doing, you can make a check non-fatal with `--ignore-preflight-errors=...`
</code></pre>
<p>I tried deleting files manually and ran the command again but it didnt resolve the port issue .
and whenever i stop the kubectl which is running on 10250 port and then run the command it gives error to " kubectl needs to be started and when i start the kubectl then it gives error for port 10250 is in use "</p>
<p>Its a kind of chicken and egg thing </p>
<p>Any views on how i can resolve it ?</p>
| <p>you should first try</p>
<pre><code> #kubeadm reset
</code></pre>
<p>because you already have kubernetes it gets error.</p>
|
<p>I changed the size of pvc.</p>
<p>According to the documents on the Internet, I went through the following steps.
I first added the following command line to the <code>storageclass</code> file.</p>
<pre><code>allowVolumeExpansion: true
</code></pre>
<p>After changing the size with the following command ,I removed the pod to be made again with pvc.
But at the end of the steps, the amount of pvc does not change.</p>
<pre><code>kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: pvc-fp
spec:
accessModes:
- ReadWriteOnce
volumeMode: Filesystem
resources:
requests:
storage: 2Gi
storageClassName: rook-ceph-blockp
</code></pre>
<p>The output of these commands should be resized in pvc.
While not changing.</p>
| <ol>
<li>What is the version of your Kubernetes cluster ? PVC resize feature is by default enabled only for k8s version 1.11 and above. For prior versions of k8s, <code>ExpandPersistentVolumes</code> feature and <code>PersistentVolumeClaimResize</code> admission controller needs to be enabled explicitly.</li>
<li>What is backend storage provider ? Does it supports volume resize with PVC ?
As of now bellow providers support PVC resize:</li>
</ol>
<pre><code>AWS-EBS, GCE-PD, Azure Disk, Azure File, Glusterfs, Cinder, Portworx, and Ceph RBD
</code></pre>
<p>You can find more information at <a href="https://kubernetes.io/blog/2018/07/12/resizing-persistent-volumes-using-kubernetes/" rel="nofollow noreferrer">https://kubernetes.io/blog/2018/07/12/resizing-persistent-volumes-using-kubernetes/</a></p>
|
<p>I have created a Kubernetes clusters with sample Spring Boot application and it works well from public ip. Now I want to access the end point of Spring boot in Kubernetes clusters. I have already followed the tutorial from Google for Configuring Serverless VPC Access. (<a href="https://cloud.google.com/vpc/docs/configure-serverless-vpc-access?hl=bg" rel="nofollow noreferrer">https://cloud.google.com/vpc/docs/configure-serverless-vpc-access?hl=bg</a>). I have created the Serverless VPC access and used in one of cloud function. </p>
<p>Now my problem is, how can I connect the internal ip of Kubernetes clusters from my cloud function?. I have written code in Go. </p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-html lang-html prettyprint-override"><code>package p
import (
"fmt"
"io/ioutil"
"net/http"
)
func HelloWorld(w http.ResponseWriter, r *http.Request) {
fmt.Println("Starting the application...")
response, err := http.Get("http://10.59.247.177:47002/")
if err != nil {
fmt.Fprint(w, "The HTTP request failed with error %s\n", err)
} else {
data, _ := ioutil.ReadAll(response.Body)
fmt.Fprint(w, string(data))
}
}</code></pre>
</div>
</div>
</p>
<p>But I am getting error: The HTTP request failed with error %s
Get <a href="http://10.59.247.177:47002/" rel="nofollow noreferrer">http://10.59.247.177:47002/</a>: dial tcp 10.59.247.177:47002: i/o timeout</p>
| <p>By default Kubernetes services are internal to Kubernetes cluster. You have to expose services so that applications from outside of Kubernetes can connect to it. </p>
<p>There are 3 main ways to expose service in Kubernetes:</p>
<ol>
<li>Public load balancer. Service is exposed to Internet. </li>
<li>Internal load balancer. Service is exposed internally within VPC and region.</li>
<li>NodePort. Service is exposed on Kube nodes IP addresses on some high number port. This makes service visible internally and between regions within VPC.</li>
</ol>
<p>Read more here <a href="https://kubernetes.io/docs/concepts/services-networking/service/#publishing-services-service-types" rel="nofollow noreferrer">https://kubernetes.io/docs/concepts/services-networking/service/#publishing-services-service-types</a> and here <a href="https://cloud.google.com/kubernetes-engine/docs/tutorials/http-balancer" rel="nofollow noreferrer">https://cloud.google.com/kubernetes-engine/docs/tutorials/http-balancer</a></p>
|
<p>I'm trying to learn Kubernetes to push up my microservices solution to some Kubernetes in the Cloud (e.g. Azure Kubernetes Service, etc)</p>
<p>As part of this, I'm trying to understand the main concepts, specifically around <code>Pods</code> + <code>Workers</code> and (in the yml file) <code>Pods</code> + <code>Services</code>. To do this, I'm trying to compare what I have inside my <code>docker-compose</code> file against the new concepts.</p>
<h3>Context</h3>
<p>I currently have a docker-compose.yml file which contains about 10 images. I've split the solution up into two 'networks': <code>frontend</code> and <code>backend</code>. The <code>backend</code> network contains 3 microservices and cannot be accessed at all via a browser. The <code>frontend</code> network contains a reverse-proxy (aka. Traefik, which is just like nginx) which is used to route all requests to the appropriate <code>backend</code> microservice and a simple SPA web app. All works 100% awesome.</p>
<p>Each backend Microservice has at least one of these:</p>
<ul>
<li>Web API host</li>
<li>Background tasks host</li>
</ul>
<p>So this means, I could scale out the WebApi hosts, if required .. but I should never scale out the background tasks hosts.</p>
<p>Here's a simple diagram of the solution:</p>
<p><a href="https://i.stack.imgur.com/aitJa.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/aitJa.png" alt="enter image description here"></a></p>
<p>So if the SPA app tries to request some data with the following route:</p>
<p><code>https://api.myapp.com/account/1</code> this will hit the reverse-proxy and match a rule to then forward onto <code><microservice b>/account/1</code></p>
<p>So it's from here, I'm trying to learn how to write up an Kubernetes deployment file based on these docker-compose concepts.</p>
<h3>Questions</h3>
<ul>
<li>Each 'Pod' has it's own IP so I should create a Pod per container. (Yes, a Pod can have multiple containers and to me, that's like saying 'install these software products on the same machine') </li>
<li>A 'Worker Node' is what we replicate/scale out, so we should put our <code>Pod</code>s into a <code>Node</code> based on the scaling scenario. For example, the Background Task hosts should go into one <code>Node</code> because they shouldn't be scaled. Also, the hardware requirements for that node are really small. While the <code>Web Api</code>'s should go into another <code>Node</code> so they can be replicated/scaled out</li>
</ul>
<p>If I'm on the right path with the understanding above, then I'll have a lot of nodes and pods ... which feels ... weird?</p>
| <p>The pod is the unit of Workload, and has one or more containers. Exactly one container is normal. You scale that workload by changing the number of Pod Replicas in a ReplicaSet (or Deployment).</p>
<p>A Pod is mostly an accounting construct with no direct parallel to base docker. It's similar to docker-compose's Service. A pod is mostly immutable after creation. Like every resource in kubernetes, a pod is a declaration of desired state - containers to be running somewhere. All containers defined in a pod are scheduled together and share resources (IP, memory limits, disk volumes, etc).</p>
<p>All Pods within a ReplicaSet are both fungible and mortal - a request can be served by any pod in the ReplicaSet, and any pod can be replaced at any time. Each pod does get its own IP, but a replacement pod will probably get a different IP. And if you have multiple replicas of a pod they'll all have different IPs. You don't want to manage or track pod IPs. Kubernetes Services provide discovery (how do I find those pods' IPs) and routing (connect to any Ready pod without caring about its identity) and load balancing (round robin over that group of Pods).</p>
<p>A Node is the compute machine (VM or Physical) running a kernel and a kubelet and a dockerd. (This is a bit of a simplification. Other container runtimes than just dockerd exist, and the virtual-kubelet project aims to turn this assumption on its head.)</p>
<p>All pods are Scheduled on Nodes. When a pod (with containers) is scheduled on a node, the kubelet responsible for & running on that node does things. The kubelet talks to dockerd to start containers.</p>
<p>Once scheduled on a node, a pod is not moved to another node. Nodes are fungible & mortal too, though. If a node goes down or is being decommissioned, the pod will be evicted/terminated/deleted. If that pod was created by a ReplicaSet (or Deployment) then the ReplicaSet Controller will create a new replica of that pod to be scheduled somewhere else.</p>
<p>You normally start many (1-100) pods+containers on the same node+kubelet+dockerd. If you have more pods than that (or they need a lot of cpu/ram/io), you need more nodes. So the nodes are also a unit of scale, though very much indirectly wrt the web-app.</p>
<p>You do not normally care which Node a pod is scheduled on. You let kubernetes decide.</p>
|
<p>I have Apache Spark 2.4.1 environment on Kubernetes(Azure Kubernetes Service).</p>
<p>The Spark container image is made from official binary file(spark-2.4.1-bin-hadoop2.7.tgz).
It works fine on example program(e.g. PI calculation).</p>
<p>But I use my Scala program that use MlLib and save Word2Vec model, Spark returns an bellow error:</p>
<pre><code>19/04/21 09:08:00 WARN TaskSetManager: Lost task 0.0 in stage 7.0 (TID 29, 10.244.0.43, executor 1): org.apache.spark.SparkException: Task failed while writing rows.
at org.apache.spark.sql.execution.datasources.FileFormatWriter$.org$apache$spark$sql$execution$datasources$FileFormatWriter$$executeTask(FileFormatWriter.scala:257)
at org.apache.spark.sql.execution.datasources.FileFormatWriter$$anonfun$write$1.apply(FileFormatWriter.scala:170)
at org.apache.spark.sql.execution.datasources.FileFormatWriter$$anonfun$write$1.apply(FileFormatWriter.scala:169)
at org.apache.spark.scheduler.ResultTask.runTask(ResultTask.scala:90)
at org.apache.spark.scheduler.Task.run(Task.scala:121)
at org.apache.spark.executor.Executor$TaskRunner$$anonfun$10.apply(Executor.scala:403)
at org.apache.spark.util.Utils$.tryWithSafeFinally(Utils.scala:1360)
at org.apache.spark.executor.Executor$TaskRunner.run(Executor.scala:409)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.UnsatisfiedLinkError: /tmp/snappy-1.1.7-c798b2d2-1676-4e8a-bc38-a0d90c37c80d-libsnappyjava.so: Error loading shared library ld-linux-x86-64.so.2: No such file or directory (needed by /tmp/snappy-1.1.7-c798b2d2-1676-4e8a-bc38-a0d90c37c80d-libsnappyjava.so)
at java.lang.ClassLoader$NativeLibrary.load(Native Method)
at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1941)
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1824)
at java.lang.Runtime.load0(Runtime.java:809)
at java.lang.System.load(System.java:1086)
at org.xerial.snappy.SnappyLoader.loadNativeLibrary(SnappyLoader.java:179)
at org.xerial.snappy.SnappyLoader.loadSnappyApi(SnappyLoader.java:154)
at org.xerial.snappy.Snappy.<clinit>(Snappy.java:47)
at org.apache.parquet.hadoop.codec.SnappyCompressor.compress(SnappyCompressor.java:67)
at org.apache.hadoop.io.compress.CompressorStream.compress(CompressorStream.java:81)
at org.apache.hadoop.io.compress.CompressorStream.finish(CompressorStream.java:92)
at org.apache.parquet.hadoop.CodecFactory$HeapBytesCompressor.compress(CodecFactory.java:165)
at org.apache.parquet.hadoop.ColumnChunkPageWriteStore$ColumnChunkPageWriter.writePage(ColumnChunkPageWriteStore.java:95)
at org.apache.parquet.column.impl.ColumnWriterV1.writePage(ColumnWriterV1.java:147)
at org.apache.parquet.column.impl.ColumnWriterV1.flush(ColumnWriterV1.java:235)
at org.apache.parquet.column.impl.ColumnWriteStoreV1.flush(ColumnWriteStoreV1.java:122)
at org.apache.parquet.hadoop.InternalParquetRecordWriter.flushRowGroupToStore(InternalParquetRecordWriter.java:172)
at org.apache.parquet.hadoop.InternalParquetRecordWriter.close(InternalParquetRecordWriter.java:114)
at org.apache.parquet.hadoop.ParquetRecordWriter.close(ParquetRecordWriter.java:165)
at org.apache.spark.sql.execution.datasources.parquet.ParquetOutputWriter.close(ParquetOutputWriter.scala:42)
at org.apache.spark.sql.execution.datasources.FileFormatDataWriter.releaseResources(FileFormatDataWriter.scala:57)
at org.apache.spark.sql.execution.datasources.FileFormatDataWriter.commit(FileFormatDataWriter.scala:74)
at org.apache.spark.sql.execution.datasources.FileFormatWriter$$anonfun$org$apache$spark$sql$execution$datasources$FileFormatWriter$$executeTask$3.apply(FileFormatWriter.scala:247)
at org.apache.spark.sql.execution.datasources.FileFormatWriter$$anonfun$org$apache$spark$sql$execution$datasources$FileFormatWriter$$executeTask$3.apply(FileFormatWriter.scala:242)
at org.apache.spark.util.Utils$.tryWithSafeFinallyAndFailureCallbacks(Utils.scala:1394)
at org.apache.spark.sql.execution.datasources.FileFormatWriter$.org$apache$spark$sql$execution$datasources$FileFormatWriter$$executeTask(FileFormatWriter.scala:248)
... 10 more
</code></pre>
<p>Do you have any advice?</p>
| <p>According to the error message states that *libsnappyjava.so cannot find ld-linux-x86-64.so.2. This is a glibc dynamic loader. So you have two solution:</p>
<ol>
<li><p>Use another compression lib, such gzip.</p></li>
<li><p>Edit your DockerFile Install libc6-compat in your docker image</p></li>
</ol>
<p>Reference:</p>
<ul>
<li><a href="https://stackoverflow.com/questions/50288034/unsatisfiedlinkerror-tmp-snappy-1-1-4-libsnappyjava-so-error-loading-shared-li">libsnappyjava-so-error-loading</a></li>
</ul>
|
<p>I've been setting up a kubernetes cluster and want to protect the dashboard (running at <code>kube.example.com</code>) behind the <code>bitly/oauth2_proxy</code> (running at <code>example.com/oauth2</code> on image <code>a5huynh/oauth2_proxy:latest</code>) as I want to re-use the OAuth proxy for other services I will be running. Authentication is working perfectly but after a user logs in, i.e. the callback returns, they are sent to <code>example.com</code> where instead they should be sent to the original host <code>kube.example.com</code> that initiated the flow. How can I do this? (I am using the nginx-ingress-controller).</p>
<p>Annotation on OAuth2 Proxy:</p>
<pre><code>kubernetes.io/ingress.class: "nginx",
nginx.ingress.kubernetes.io/force-ssl-redirect: "true",
nginx.ingress.kubernetes.io/secure-backends: "true",
nginx.ingress.kubernetes.io/ssl-passthrough: "true"
</code></pre>
<p>Annotation on Dashboard:</p>
<pre><code>kubernetes.io/ingress.class: "nginx",
nginx.ingress.kubernetes.io/auth-signin: "https://example.com/oauth2/start",
nginx.ingress.kubernetes.io/auth-url: "https://example.com/oauth2/auth",
nginx.ingress.kubernetes.io/backend-protocol: "HTTPS",
nginx.ingress.kubernetes.io/force-ssl-redirect: "true",
nginx.ingress.kubernetes.io/secure-backends: "true",
nginx.ingress.kubernetes.io/ssl-passthrough: "true",
nginx.ingress.kubernetes.io/ssl-redirect: "true"
</code></pre>
<p>I expect to be redirected to the original host <code>kube.example.com</code> after OAuth flow is complete but am being sent back to the OAuth2 host <code>example.com</code></p>
| <p>After searching for a bit I came across a <a href="https://www.callumpember.com/Kubernetes-A-Single-OAuth2-Proxy-For-Multiple-Ingresses/" rel="noreferrer">blog post</a> about performing this in a super simple manor. Unfortunately I found the provided <a href="https://www.callumpember.com/assets/attachments/github-oauth2/full-deployment.yml.txt" rel="noreferrer">yaml</a> did not quite work correctly as the oauth2_proxy was never being hit due to nginx intercepting all requests (I am not sure if mine was not working due to me wanting the oauth-proxy url to be <code>example.com/oauth2</code> rather than <code>oauth2.example.com</code>). To fix this I added back the oauth2-proxy path to the Ingress for the proxy i.e.</p>
<pre><code>apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: oauth2-proxy
namespace: default
annotations:
kubernetes.io/ingress.class: "nginx"
spec:
rules:
- host: example.com
http:
paths:
- backend:
serviceName: oauth2-proxy
servicePort: 80
path: /
- backend:
serviceName: oauth2-proxy
servicePort: 4180
path: /oauth2
</code></pre>
<p>and made sure that the service was also still exposed i.e.</p>
<pre><code>apiVersion: v1
kind: Service
metadata:
labels:
k8s-app: oauth2-proxy
name: oauth2-proxy
namespace: default
spec:
ports:
- name: http
port: 80
protocol: TCP
targetPort: 80
- name: http-proxy
port: 4180
protocol: TCP
targetPort: 4180
selector:
k8s-app: oauth2-proxy
</code></pre>
<p>Then to protect services behind the oauth proxy I just need to place the following in the Ingress annotations:</p>
<pre><code> nginx.ingress.kubernetes.io/auth-url: "https://example.com/oauth2/auth"
nginx.ingress.kubernetes.io/auth-signin: "https://example.com/oauth2/start?rd=/redirect/$http_host$request_uri"
</code></pre>
|
<p>I'm learning Kubernetes, and trying to setup a cluster that could handle a single Wordpress site with high traffic. From reading multiple examples online from both Google Cloud and Kubernetes.io - they all set the "accessMode" - "readWriteOnce" when creating the PVCs. </p>
<p>Does this mean if I scaled the Wordpress Deployment to use multiple replicas, they all use the same single PVC to store persistent data - read/write data. (Just like they use the single DB instance?) </p>
<p>The google example here only uses a single-replica, single-db instance - <a href="https://cloud.google.com/kubernetes-engine/docs/tutorials/persistent-disk" rel="nofollow noreferrer">https://cloud.google.com/kubernetes-engine/docs/tutorials/persistent-disk</a></p>
<p>My question is how do you handle persistent storage on a multiple-replica instance?</p>
| <p>ReadWriteOnce means all replicas will use the same volume and therefore they will all run on one node. This can be suboptimal.</p>
<p>You can set up ReadWriteMany volume (NFS, GlusterFS, CephFS and others) storage class that will allow multiple nodes to mount one volume. </p>
<p>Alternatively you can run your application as StatefulSet with volumeClaimTemplate which ensures that each replica will mount its own ReadWriteOnce volume.</p>
|
<p>I have a live Kubernetes cluster, version 1.12, in which I need to change the default pod hard eviction values for every kubelet. I've read through <a href="https://kubernetes.io/docs/setup/independent/kubelet-integration/" rel="nofollow noreferrer">https://kubernetes.io/docs/setup/independent/kubelet-integration/</a> but it falls short for my particular use case. In that article, it seems to implicitly assumes a static set of nodes in the cluster. In my case I have a cluster autoscaler managing several AWS autoscale groups. I need a way to reconfigure the kubelet on each live node as well as any future nodes which are dynamically started (via <code>kubeadm join</code>).</p>
<p>My thought is to manually edit the kubelet-config-1.12 configmap to change the eviction thresholds then update the live nodes using the method in the article listed above.</p>
<p>Is there any issue with manually editing th the kubelet-config-1.12 configmap? Will the edits get carried over to the 1.13 version when the cluster is upgraded to that version?</p>
<p>Or if anyone has a better solution I'd like to hear it.</p>
| <p>In addition to what <a href="https://stackoverflow.com/users/9892073/aurelius">aurelius</a> wrote in his answer,</p>
<p><a href="https://kubernetes.io/docs/reference/command-line-tools-reference/feature-gates/" rel="nofollow noreferrer">DynamicKubeletConfig</a> Feature Gate is enabled by default starting from Kubernetes v1.11, but you need some additional steps to activate it.</p>
<p>As mentioned in the <a href="https://kubernetes.io/docs/tasks/administer-cluster/reconfigure-kubelet/#reconfiguring-the-kubelet-on-a-live-node-in-your-cluster" rel="nofollow noreferrer">documentation</a> (but can be missed easily): </p>
<ul>
<li>The Kubelet’s <code>--dynamic-config-dir</code> flag must be set to a writable directory on the Node.</li>
</ul>
<p>and by <code>kubelet -h</code></p>
<blockquote>
<p><strong>--dynamic-config-dir string</strong><br>
The Kubelet will use this directory for checkpointing downloaded configurations and tracking configuration health.<br>
The Kubelet will create this directory if it does not already exist.<br>
The path may be absolute or relative; relative paths start at the Kubelet's current working directory.<br>
<strong>Providing this flag enables dynamic Kubelet configuration.</strong><br>
The DynamicKubeletConfig feature gate must be enabled to pass this flag; this gate currently defaults to true because the feature is beta.</p>
</blockquote>
<p>The best place to set this flag (for Ubuntu) is to add it to <code>/etc/defaults/kubelet</code>:</p>
<pre><code>$KUBELET_EXTRA_ARGS=--dynamic-config-dir=/var/lib/kubelet-dynamic
</code></pre>
<p>Restart <code>kubelet</code> service after that:</p>
<pre><code>$ sudo systemctl restart kubelet
$ ps aux | grep kubelet
root 8610 4.1 1.1 1115992 90652 ? Ssl 14:57 0:46 /usr/bin/kubelet --bootstrap-kubeconfig=/etc/kubernetes/bootstrap-kubelet.conf
--kubeconfig=/etc/kubernetes/kubelet.conf --config=/var/lib/kubelet/config.yaml
--cgroup-driver=cgroupfs --network-plugin=cni
--pod-infra-container-image=k8s.gcr.io/pause:3.1
--dynamic-config-dir=/var/lib/kubelet-dynamic
</code></pre>
<p>After that <code>kubelet</code> creates directory tree under this directory to maintain checkpoints:</p>
<pre><code>$ sudo tree /var/lib/kubelet-dynamic/
/var/lib/kubelet-dynamic/
└── store
├── checkpoints
│ └── 009e03e7-62ad-11e9-9043-42010a9c0003
│ └── 12399979
│ └── kubelet
└── meta
├── assigned
└── last-known-good
</code></pre>
<p>From this point everything should work as mentioned in documentation.</p>
|
<p>I have k8s cluster with three workers and when I explicitly creates the pod, corresponding docker images get downloaded to worker. When I explicitly deletes the pods corresponding docker images are still present on worker nodes. Is this expected case? </p>
| <blockquote>
<p>Is this expected case?</p>
</blockquote>
<p>Possibly, considering the <a href="https://kubernetes.io/docs/concepts/cluster-administration/kubelet-garbage-collection/" rel="noreferrer">Kubernetes Garbage collection policy for images</a>:</p>
<blockquote>
<p>Kubernetes manages lifecycle of all images through <code>imageManager</code>, with the cooperation of <code>cadvisor</code>.</p>
<p>The policy for garbage collecting images takes two factors into consideration: <code>HighThresholdPercent</code> and <code>LowThresholdPercent</code>.<br />
Disk usage above the high threshold will trigger garbage collection.<br />
The garbage collection will delete least recently used images until the low threshold has been met.</p>
</blockquote>
|
<p>I am using Kubernetes helm chart for my Kubernetes service deployment. I have different services now, called x1, x2 upto x10. So now I created x1.yaml inside my templates folder. And running the 'helm install ./mychart'. And now I am getting deployment inside my Kubernetes cluster.</p>
<p>Can I add .yaml files (x2.yaml to x10.yaml) for all my Kubernetes service inside templates folder, and can I deploy together all by using 1 chart ?</p>
<p>I did not properly understood the hierarchy of Helm chart for Kubernetes resource deployment.</p>
| <p>Anything that you put into templates/ folder will be rendered as Kube manifest. If you add 10 manifests there - 10 manifests will be applied on "helm install". It is up to you how you want this to work. </p>
<p>You can put all your apps into single Helm chart and create one values.yaml for all your applications. This is absolutely valid practice although not very popular. Whenever you change values.yaml and issue "helm upgrade" - changed manifests will be reapplied.</p>
<p>Or you can create separate chart per application, that's how most of charts look like. In that case you will upgrade applications separately from each other. I think this method is preferred.</p>
|
<p>In the Minikube , I created a pod with the configuration provided below </p>
<pre><code>kind: Pod
metadata:
name: node-js-pod
spec:
containers:
- name: node-js-pod
image: bitnami/apache:latest
ports:
- containerPort: 8080
</code></pre>
<p>then i created a service of type cluster-ip with configuration provided below</p>
<pre><code>kind: Service
metadata:
name: node-js-internal
labels:
name: node-js-internal
spec:
ports:
- port: 8081
selector:
name: node-js
</code></pre>
<p>After creating the service i checked the cluster ip of service using command:
<code>kubectl get services -l name=node-js-internal</code>
which gave output as:</p>
<pre><code>NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
node-js-internal ClusterIP 10.106.71.114 <none> 8081/TCP 18m
</code></pre>
<p>Once I created this service i tried to access this service internally from node-js-pod using command:
<code>kubectl exec node-js-pod -- curl 10.106.71.114:8081</code>
Which gave error message as curl 7 connection timed out :</p>
<pre><code>$ kubectl exec node-js-pod -- curl 10.106.71.114:8081
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- 0:02:10 --:--:-- 0curl: (7) Failed to connect to 10.106.71.114 port 8081: Connection timed out
command terminated with exit code 7
</code></pre>
<p>How to connect to the node-js-internal service from pod node-js in minikube?</p>
| <p>Use the same port in the service as the container is listening to.</p>
<pre><code>kind: Service
metadata:
name: node-js-internal
labels:
name: node-js-internal
spec:
ports:
- port: 8080
selector:
name: node-js-pod
</code></pre>
<p>If you want to have a different port in the service, than the container is listening to, you need to specify a mapping in the service</p>
<pre><code>ports:
- protocol: TCP
port: 8081
targetPort: 8080
</code></pre>
|
<p>I'm running Ignite in a Kubernetes cluster with persistence enabled. Each machine has a Java Heap of 24GB with 20GB devoted to durable memory with a memory limit of 110GB. My relevant JVM options are <code>-XX:+AlwaysPreTouch -XX:+UseG1GC -XX:+ScavengeBeforeFullGC</code>. After running DataStreamers on every node for several hours, nodes on my cluster hit their k8s memory limit triggering an OOM kill. After running Java NMT, I was surprised to find a huge amount of space allocated to internal memory.</p>
<pre><code>Java Heap (reserved=25165824KB, committed=25165824KB)
(mmap: reserved=25165824KB, committed=25165824KB)
Internal (reserved=42425986KB, committed=42425986KB)
(malloc=42425954KB #614365)
(mmap: reserved=32KB, committed=32KB)
</code></pre>
<p>Kubernetes metrics confirmed this:</p>
<p><a href="https://i.stack.imgur.com/RUYIe.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/RUYIe.png" alt="enter image description here"></a></p>
<p>"Ignite Cache" is kernel page cache. The last panel "Heap + Durable + Buffer" is the sum of the ignite metrics <code>HeapMemoryUsed</code> + <code>PhysicalMemorySize</code> + <code>CheckpointBufferSize</code>.</p>
<p>I knew this couldn't be a result of data build-up because the DataStreamers are flushed after each file they read (up to about 250MB max), and no node is reading more than 4 files at once. After ruling out other issues on my end, I tried setting <code>-XX:MaxDirectMemorySize=10G</code>, and invoking manual GC, but nothing seems to have an impact other than periodically shutting down all of my pods and restarting them.</p>
<p>I'm not sure where to go from here. Is there a workaround in Ignite that doesn't force me to use a third-party database?</p>
<p>EDIT: My DataStorageConfiguration</p>
<pre><code> <property name="dataStorageConfiguration">
<bean class="org.apache.ignite.configuration.DataStorageConfiguration">
<property name="metricsEnabled" value="true"/>
<property name="checkpointFrequency" value="300000"/>
<property name="storagePath" value="/var/lib/ignite/data/db"/>
<property name="walFlushFrequency" value="10000"/>
<property name="walMode" value="LOG_ONLY"/>
<property name="walPath" value="/var/lib/ignite/data/wal"/>
<property name="walArchivePath" value="/var/lib/ignite/data/wal/archive"/>
<property name="walSegmentSize" value="2147483647"/>
<property name="maxWalArchiveSize" value="4294967294"/>
<property name="walCompactionEnabled" value="false"/>
<property name="writeThrottlingEnabled" value="False"/>
<property name="pageSize" value="4096"/>
<property name="defaultDataRegionConfiguration">
<bean class="org.apache.ignite.configuration.DataRegionConfiguration">
<property name="persistenceEnabled" value="true"/>
<property name="checkpointPageBufferSize" value="2147483648"/>
<property name="name" value="Default_Region"/>
<property name="maxSize" value="21474836480"/>
<property name="metricsEnabled" value="true"/>
</bean>
</property>
</bean>
</property>
</code></pre>
<p>UPDATE: When I disable persistence, internal memory is properly disposed of:</p>
<p><a href="https://i.stack.imgur.com/vDFxS.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/vDFxS.png" alt="enter image description here"></a></p>
<p>UPDATE: The issue is demonstrated <a href="https://github.com/kellanburket/ignite-leak" rel="nofollow noreferrer">here</a> with a reproducible example. It's runnable on a machine with at least 22GB of memory for docker and about 50GB of storage. Interestingly the leak is only really noticeable when passing in a Byte Array or String as the value. </p>
| <h1>TLDR</h1>
<p>Set <code>walSegmentSize=64mb</code> (or just remove the setting and use the default) AND set <code>-XX:MaxDirectMemorySize=<walSegmentSize * 4></code>.</p>
<h1>Explanation</h1>
<p>One thing people often forget when calculating Ignite's memory needs is direct memory buffer size.</p>
<p>Direct memory buffers are JVM-managed buffers allocated from a separate space in the Java process - it is neither Java heap, Ignite data region or Ignite checkpoint buffer.</p>
<p>Direct memory buffers are the normal way of interacting with non-heap memory in Java. There is a lot of things that use that (from JVM's internal code to applications) but in Ignite servers the main user of the direct memory pool is write-ahead log.</p>
<p>By default, Ignite writes to WAL using a memory-mapped file - which works through a direct memory buffer. The size of that buffer is the size of the WAL segment. And here we get to the fun stuff.</p>
<p>Your WAL segments are huge! 2GB - it's A LOT. Default is 64mb, and I've rarely seen an environment that would use more than that. In some specific workloads and for some specific disks we would recommend to set 256mb.</p>
<p>So, you have a 2GB buffers that are being created in the direct memory pool. The maximum size of the direct memory by default is equal to <code>-Xmx</code> - in your case, 24GB. I can see a scenario when your direct memory pool would bloat to 24GB (from the non-yet-cleared old buffered), making the total size of your application at least <code>20 + 2 + 24 + 24 = 70GB</code>!.</p>
<p>This explains the 40GB of internal JVM memory (I think that's the data region + direct). This also explains why you don't see an issue when persistence is off - you don't have WAL in that case.</p>
<h1>What to do</h1>
<ol>
<li><p>Choose a sane <code>walSegmentSize</code>. I don't know the reason behind the 2GB choice but I would recommend to go either for the default of 64mb or for 256mb if you're sure you had issues with small WAL segments.</p></li>
<li><p>Set a limit to JVM's direct memory pool via <code>-XX:MaxDirectMemorySize=<size></code>. I find it a safe choice to set it to the value of <code>walSegmentSize * 4</code>, i.e. somewhere in the range 256mb-1gb.</p></li>
</ol>
<p>Even if you see issues with memory consumption after making the above changes - keep them anyway, just because they are the best choice in for 99% of clusters.</p>
|
<p>I have a helm chart that I use to add a list of users to my cluster, but I would like to modify my <code>default</code> service account to include an image pull secret. There doesn't seem to be any patch functionality in helm.</p>
<p>Is a post-install hook the best I can do?</p>
| <p>I had the same issue. What I did is:</p>
<pre><code>apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
name: default
namespace: YOUR_NAMESPACE
rules:
- apiGroups:
- ""
resources:
- serviceaccounts
verbs:
- get
---
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: default
namespace: YOUR_NAMESPACE
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: Role
name: default
subjects:
- kind: ServiceAccount
name: default
namespace: YOUR_NAMESPACE
</code></pre>
<p>and then:</p>
<pre><code>apiVersion: batch/v1
kind: Job
metadata:
name: create-image-pull-secret
annotations:
"helm.sh/hook": pre-install
"helm.sh/hook-delete-policy": hook-succeeded
spec:
template:
spec:
restartPolicy: Never
containers:
- name: k8s
image: google/cloud-sdk
imagePullPolicy: IfNotPresent
command: ["/bin/sh","-c", "kubectl patch serviceaccount default -p '{\"imagePullSecrets\": [{\"name\": \"YOUR_SECRET_NAME\"}]}'"]
</code></pre>
<p>Note that I use a <code>pre-install</code> hook. I did that because I needed the imagePullSecret working for my child dependencies. Also, the patch command allowed to use a secret name that doesn't exist yet.</p>
|
<p>I have multiple configuration files in two directories. For example, </p>
<ul>
<li>conf.d/parentconf1.conf</li>
<li>con.d/node1/child1.conf</li>
<li>conf.d/node2/child2.conf</li>
</ul>
<p>I need to mount these configuration files in the same directory structure to kubernetes pod using <code>ConfigMap</code>. </p>
<p>Tried using the</p>
<pre><code>kubectl create configmap --from-file=./conf.d --from-file=./conf.d/node1/child1.conf --from-file=./conf.d/node2/child2.conf.
</code></pre>
<p>Config map created, as expected, cannot express the nested directory structure. </p>
<p>Is it possible to create ConfigMap recursively from folders and still retain the folder structure in the name of the key entry for the ConfigMap - since the intention is to mount these ConfigMaps into pods?</p>
| <p>Unfortunately, reflecting directory structure in configmap is not supported currently. Workaround is to express directory hierarchy like this:</p>
<pre><code>apiVersion: v1
kind: ConfigMap
metadata:
name: testconfig
data:
file1: |
This is file1
file2: |
This is file2 in subdir directory
---
apiVersion: v1
kind: Pod
metadata:
name: testpod
spec:
restartPolicy: Never
containers:
- name: test-container
image: gcr.io/google_containers/busybox
command: [ "/bin/sh","-c", "sleep 1000" ]
volumeMounts:
- name: config-volume
mountPath: /etc/config
volumes:
- name: config-volume
configMap:
name: testconfig
items:
- key: file2
path: subdir/file2
- key: file1
path: file1
</code></pre>
|
<p>There are 2 questions about Calico applying to k8s cluster.</p>
<ol>
<li><p>Calico creates etcd for own data, but I don't want to create another etcd because k8s already have it. Can I use k8s etcd for Calico?</p></li>
<li><p>Calico prepares Typha for using Kubernetes API Datastore. Then, What does Typha exactly do? I read Typha's code, and assumed that Typha takes snapshots and deltas for adapting network policy and constantly broadcast them to all client which Typha connects to. But I'm not familiar with golang so I don't have confidence of my understanding.</p></li>
</ol>
<p>I'm absolutely new to Calico and k8s, so I'm sorry if I miss some document related to above questions.</p>
| <p>We are using shared ETCD for calico as well as kubernetes, we did not face any issue. But it probably depends on the size of the k8s cluster and the kind of workloads being used. If there are too many short jobs, it could be an issue as there would be an increased load on ETCD in comparison to the ones with few - but long running - jobs</p>
|
<p>Is there any advantage if I use Cloud Run instead of deploying a normal service/container in GKE?</p>
| <p>I will try to add my perspective.</p>
<p>This answer does not cover running containers in Google Cloud Run Kubernetes. The reason is that we wanted an almost zero cost solution for a legacy PHP website. Cloud Run fit perfectly and we had an easy time both porting the code and learning Cloud Run.</p>
<p>We needed to do something with a legacy PHP website. This website was running on Windows Server 2012, IIS and PHP 7.0x. The cost was over $100.00 per month - mostly for Windows licensing fees for a VM in the cloud. The site was not accessed very much but was needed for various business reasons.</p>
<p>A decision was made Thursday (4/18/2019) was that we needed to learn Google Cloud Run, so we decided to port this site to a container and try to run the container in Google Cloud. Nothing like a real world example to learn the details.</p>
<p>Friday, we ported the PHP code to Apache. Very easy process. We did not worry about SSL as we intend to use Cloud Run SSL.</p>
<p>Saturday we started to learn Cloud Run. Within an hour we had the Hello World PHP example running. <a href="https://cloud.google.com/run/docs/quickstarts/build-and-deploy" rel="noreferrer">Link</a>.</p>
<p>Within two hours we had the containerized website running in Cloud Run. Again, very simple.</p>
<p>Then we learned how to configure Cloud Run SSL with our DNS server.</p>
<p>End result:</p>
<ol>
<li>Almost zero cost for a PHP website running in Cloud Run.</li>
<li>Approximately 1.5 days of effort to port the legacy code and learn Cloud Run.</li>
<li>Savings of about $100.00 per month (no Windows IIS server).</li>
<li>We do not have to worry about SSL certificates from now on for this site.</li>
</ol>
<p>For small websites that are static, Cloud Run is a killer product. The learning curve is very small even if you do not know Google Cloud. You just need to configure gcloud for container builds and deployment. This means developers can be independant of needing to master GCP.</p>
|
<p>I have this ansible (working) playbook that looks at the output of <code>kubectl get pods -o json</code> until the pod is in the <code>Running</code> state. Now I want to extend this to multiple pods. The core issue is that the json result of the kubectl query is a list, I know how to access the first item, but not all of the items... </p>
<pre><code>- name: wait for pods to come up
shell: kubectl get pods -o json
register: kubectl_get_pods
until: kubectl_get_pods.stdout|from_json|json_query('items[0].status.phase') == "Running"
retries: 20
</code></pre>
<p>The json object looks like,</p>
<pre><code>[ { ... "status": { "phase": "Running" } },
{ ... "status": { "phase": "Running" } },
...
]
</code></pre>
<p>Using <code>[0]</code> to access the first item worked for handling one object in the list, but I can't figure out how to extend it to multiple items. I tried <code>[*]</code> which did not work.</p>
| <h2>The <code>kubectl wait</code> command</h2>
<p>Kubernetes introduced the <code>kubectl wait</code> in <code>v1.11</code> version:</p>
<p><a href="https://github.com/kubernetes/kubernetes/blob/master/CHANGELOG-1.11.md" rel="noreferrer">CHANGELOG-1.11:</a></p>
<blockquote>
<ul>
<li><code>kubectl wait</code> is a new command that allows waiting for one or more
resources to be deleted or to reach a specific condition. It adds a
<code>kubectl wait --for=[delete|condition=condition-name]</code> resource/string
command.</li>
</ul>
</blockquote>
<p><a href="https://github.com/kubernetes/kubernetes/blob/master/CHANGELOG-1.13.md" rel="noreferrer">CHANGELOG-1.13:</a></p>
<blockquote>
<ul>
<li><code>kubectl wait</code> now supports condition value checks other than true
using <code>--for condition=available=false</code></li>
</ul>
</blockquote>
<p><a href="https://github.com/kubernetes/kubernetes/blob/master/CHANGELOG-1.14.md" rel="noreferrer">CHANGELOG-1.14:</a></p>
<blockquote>
<ul>
<li>Expanded <code>kubectl wait</code> to work with more types of selectors.</li>
<li><code>kubectl wait</code> command now supports the <code>--all</code> flag to select all
resources in the namespace of the specified resource types.</li>
</ul>
</blockquote>
<p>It is not intended to wait for <em>phases</em>, but for <em>conditions</em>. I think that waiting for conditions is much more assertive than waiting for phases. See the following <a href="https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle/#pod-conditions" rel="noreferrer"><em>conditions</em></a>:</p>
<blockquote>
<ul>
<li><strong>PodScheduled</strong>: the Pod has been scheduled to a node; </li>
<li><strong>Ready</strong>: the Pod is able to serve requests and should be added to the load balancing pools of all matching Services;</li>
<li><strong>Initialized</strong>: all init containers have started successfully;</li>
<li><strong>ContainersReady</strong>: all containers in the Pod are ready.</li>
</ul>
</blockquote>
<hr>
<h2>Using <code>kubectl wait</code> with Ansible</h2>
<p>Suppose that you are automating a Kubernetes install with <code>kubeadm</code> + Ansible, and need to wait for the installation to complete:</p>
<pre><code>- name: Wait for all control-plane pods become created
shell: "kubectl get po --namespace=kube-system --selector tier=control-plane --output=jsonpath='{.items[*].metadata.name}'"
register: control_plane_pods_created
until: item in control_plane_pods_created.stdout
retries: 10
delay: 30
with_items:
- etcd
- kube-apiserver
- kube-controller-manager
- kube-scheduler
- name: Wait for control-plane pods become ready
shell: "kubectl wait --namespace=kube-system --for=condition=Ready pods --selector tier=control-plane --timeout=600s"
register: control_plane_pods_ready
- debug: var=control_plane_pods_ready.stdout_lines
</code></pre>
<p><strong>Result Example:</strong></p>
<pre><code>TASK [Wait for all control-plane pods become created] ******************************
FAILED - RETRYING: Wait all control-plane pods become created (10 retries left).
FAILED - RETRYING: Wait all control-plane pods become created (9 retries left).
FAILED - RETRYING: Wait all control-plane pods become created (8 retries left).
changed: [localhost -> localhost] => (item=etcd)
changed: [localhost -> localhost] => (item=kube-apiserver)
changed: [localhost -> localhost] => (item=kube-controller-manager)
changed: [localhost -> localhost] => (item=kube-scheduler)
TASK [Wait for control-plane pods become ready] ********************************
changed: [localhost -> localhost]
TASK [debug] *******************************************************************
ok: [localhost] => {
"control_plane_pods_ready.stdout_lines": [
"pod/etcd-localhost.localdomain condition met",
"pod/kube-apiserver-localhost.localdomain condition met",
"pod/kube-controller-manager-localhost.localdomain condition met",
"pod/kube-scheduler-localhost.localdomain condition met"
]
}
</code></pre>
|
<p>Following <a href="https://kubernetes.io/blog/2019/03/15/kubernetes-setup-using-ansible-and-vagrant/" rel="nofollow noreferrer">https://kubernetes.io/blog/2019/03/15/kubernetes-setup-using-ansible-and-vagrant/</a> , tried to setup Kubernetes using vagrant on Mac. With the Ansible Playbook Step:</p>
<pre><code> - name: Initialize the Kubernetes cluster using kubeadm
command: kubeadm init --apiserver-advertise-address="192.168.50.10" --apiserver-cert-extra-sans="192.168.50.10" --node-name k8s-master --pod-network-cidr=192.168.0.0/16
</code></pre>
<p>I get error:</p>
<blockquote>
<p>fatal: [k8s-master]: FAILED! => {"changed": true, "cmd": ["kubeadm",
"init", "--apiserver-advertise-address=192.168.50.10",
"--apiserver-cert-extra-sans=192.168.50.10", "--node-name",
"k8s-master", "--pod-network-cidr=192.168.0.0/16"], "delta":
"0:00:03.446240", "end": "2019-04-22 08:32:03.655520", "msg":
"non-zero return code", "rc": 1, "start": "2019-04-22
08:32:00.209280", "stderr": "I0422 08:32:00.877733 5038
version.go:96] could not fetch a Kubernetes version from the internet:
unable to get URL \"<a href="https://dl.k8s.io/release/stable-1.txt" rel="nofollow noreferrer">https://dl.k8s.io/release/stable-1.txt</a>\": Get
<a href="https://dl.k8s.io/release/stable-1.txt" rel="nofollow noreferrer">https://dl.k8s.io/release/stable-1.txt</a>: x509: certificate signed by
unknown authority\nI0422 08:32:00.877767 5038 version.go:97]
falling back to the local client version: v1.14.1\n\t[WARNING
IsDockerSystemdCheck]: detected \"cgroupfs\" as the Docker cgroup
driver. The recommended driver is \"systemd\". Please follow the guide
at <a href="https://kubernetes.io/docs/setup/cri/" rel="nofollow noreferrer">https://kubernetes.io/docs/setup/cri/</a>\nerror execution phase
preflight: [preflight] Some fatal errors occurred:\n\t[ERROR
ImagePull]: failed to pull image k8s.gcr.io/kube-apiserver:v1.14.1:
output: Error response from daemon: Get <a href="https://k8s.gcr.io/v2/" rel="nofollow noreferrer">https://k8s.gcr.io/v2/</a>: x509:
certificate signed by unknown authority\n,</p>
</blockquote>
<p>so I tried to run the Kubeadm init command manually:</p>
<pre><code>kubeadm init --apiserver-advertise-address="192.168.50.10" --apiserver-cert-extra-sans="192.168.50.10" --node-name k8s-master --pod-network-cidr=192.168.0.0/16 --ignore-preflight-errors all
I0422 08:51:06.815553 6537 version.go:96] could not fetch a Kubernetes version from the internet: unable to get URL "https://dl.k8s.io/release/stable-1.txt": Get https://dl.k8s.io/release/stable-1.txt: x509: certificate signed by unknown authority
I0422 08:51:06.815587 6537 version.go:97] falling back to the local client version: v1.14.1
</code></pre>
<p>I tried the same command with --ignore-preflight-errors all</p>
<pre><code>kubeadm init --apiserver-advertise-address="192.168.50.10" --apiserver-cert-extra-sans="192.168.50.10" --node-name k8s-master --pod-network-cidr=192.168.0.0/16 --ignore-preflight-errors all
I0422 08:51:35.741958 6809 version.go:96] could not fetch a Kubernetes version from the internet: unable to get URL "https://dl.k8s.io/release/stable-1.txt": Get https://dl.k8s.io/release/stable-1.txt: x509: certificate signed by unknown authority
I0422 08:51:35.742030 6809 version.go:97] falling back to the local client version: v1.14.1
[init] Using Kubernetes version: v1.14.1
[preflight] Running pre-flight checks
[WARNING IsDockerSystemdCheck]: detected "cgroupfs" as the Docker cgroup driver. The recommended driver is "systemd". Please follow the guide at https://kubernetes.io/docs/setup/cri/
[preflight] Pulling images required for setting up a Kubernetes cluster
[preflight] This might take a minute or two, depending on the speed of your internet connection
[preflight] You can also perform this action in beforehand using 'kubeadm config images pull'
[WARNING ImagePull]: failed to pull image k8s.gcr.io/kube-apiserver:v1.14.1: output: Error response from daemon: Get https://k8s.gcr.io/v2/: x509: certificate signed by unknown authority
, error: exit status 1
[WARNING ImagePull]: failed to pull image k8s.gcr.io/kube-controller-manager:v1.14.1: output: Error response from daemon: Get https://k8s.gcr.io/v2/: x509: certificate signed by unknown authority
, error: exit status 1
[WARNING ImagePull]: failed to pull image k8s.gcr.io/kube-scheduler:v1.14.1: output: Error response from daemon: Get https://k8s.gcr.io/v2/: x509: certificate signed by unknown authority
, error: exit status 1
[WARNING ImagePull]: failed to pull image k8s.gcr.io/kube-proxy:v1.14.1: output: Error response from daemon: Get https://k8s.gcr.io/v2/: x509: certificate signed by unknown authority
, error: exit status 1
[WARNING ImagePull]: failed to pull image k8s.gcr.io/pause:3.1: output: Error response from daemon: Get https://k8s.gcr.io/v2/: x509: certificate signed by unknown authority
, error: exit status 1
[WARNING ImagePull]: failed to pull image k8s.gcr.io/etcd:3.3.10: output: Error response from daemon: Get https://k8s.gcr.io/v2/: x509: certificate signed by unknown authority
, error: exit status 1
[WARNING ImagePull]: failed to pull image k8s.gcr.io/coredns:1.3.1: output: Error response from daemon: Get https://k8s.gcr.io/v2/: x509: certificate signed by unknown authority
, error: exit status 1
[kubelet-start] Writing kubelet environment file with flags to file "/var/lib/kubelet/kubeadm-flags.env"
[kubelet-start] Writing kubelet configuration to file "/var/lib/kubelet/config.yaml"
[kubelet-start] Activating the kubelet service
[certs] Using certificateDir folder "/etc/kubernetes/pki"
[certs] Generating "front-proxy-ca" certificate and key
[certs] Generating "front-proxy-client" certificate and key
[certs] Generating "etcd/ca" certificate and key
[certs] Generating "etcd/server" certificate and key
[certs] etcd/server serving cert is signed for DNS names [k8s-master localhost] and IPs [192.168.50.10 127.0.0.1 ::1]
[certs] Generating "etcd/healthcheck-client" certificate and key
[certs] Generating "etcd/peer" certificate and key
[certs] etcd/peer serving cert is signed for DNS names [k8s-master localhost] and IPs [192.168.50.10 127.0.0.1 ::1]
---
- hosts: all
become: true
tasks:
- name: Install packages that allow apt to be used over HTTPS
apt:
name: "{{ packages }}"
state: present
update_cache: yes
vars:
packages:
- apt-transport-https
- ca-certificates
- curl
- gnupg-agent
- software-properties-common
- name: Add an apt signing key for Docker
apt_key:
url: https://download.docker.com/linux/ubuntu/gpg
state: present
- name: Add apt repository for stable version
apt_repository:
repo: deb [arch=amd64] https://download.docker.com/linux/ubuntu xenial stable
state: present
- name: Install docker and its dependecies
apt:
name: "{{ packages }}"
state: present
update_cache: yes
vars:
packages:
- docker-ce
- docker-ce-cli
- containerd.io
notify:
- docker status
- name: Add vagrant user to docker group
user:
name: vagrant
group: docker
/Initialize
[certs] Generating "apiserver-etcd-client" certificate and key
[certs] Generating "ca" certificate and key
[certs] Generating "apiserver-kubelet-client" certificate and key
[certs] Generating "apiserver" certificate and key
[certs] apiserver serving cert is signed for DNS names [k8s-master kubernetes kubernetes.default kubernetes.default.svc kubernetes.default.svc.cluster.local] and IPs [10.96.0.1 192.168.50.10 192.168.50.10]
[certs] Generating "sa" key and public key
[kubeconfig] Using kubeconfig folder "/etc/kubernetes"
[kubeconfig] Writing "admin.conf" kubeconfig file
[kubeconfig] Writing "kubelet.conf" kubeconfig file
[kubeconfig] Writing "controller-manager.conf" kubeconfig file
[kubeconfig] Writing "scheduler.conf" kubeconfig file
[control-plane] Using manifest folder "/etc/kubernetes/manifests"
[control-plane] Creating static Pod manifest for "kube-apiserver"
[control-plane] Creating static Pod manifest for "kube-controller-manager"
[control-plane] Creating static Pod manifest for "kube-scheduler"
[etcd] Creating static Pod manifest for local etcd in "/etc/kubernetes/manifests"
[wait-control-plane] Waiting for the kubelet to boot up the control plane as static Pods from directory "/etc/kubernetes/manifests". This can take up to 4m0s
[kubelet-check] Initial timeout of 40s passed.
Unfortunately, an error has occurred:
timed out waiting for the condition
This error is likely caused by:
- The kubelet is not running
- The kubelet is unhealthy due to a misconfiguration of the node in some way (required cgroups disabled)
If you are on a systemd-powered system, you can try to troubleshoot the error with the following commands:
- 'systemctl status kubelet'
- 'journalctl -xeu kubelet'
Additionally, a control plane component may have crashed or exited when started by the container runtime.
To troubleshoot, list all containers using your preferred container runtimes CLI, e.g. docker.
Here is one example how you may list all Kubernetes containers running in docker:
- 'docker ps -a | grep kube | grep -v pause'
Once you have found the failing container, you can inspect its logs with:
- 'docker logs CONTAINERID'
error execution phase wait-control-plane: couldn't initialize a Kubernetes cluster
</code></pre>
<p>based on the valuable suggestions, I tried the command:</p>
<pre><code>kubeadm init --apiserver-advertise-address="192.168.50.10" --apiserver-cert-extra-sans="192.168.50.10" --pod-network-cidr=192.168.0.0/16 --kubernetes-version="v1.14.1" --ignore-preflight-errors all --cert-dir=/etc/ssl/cert
</code></pre>
<p>but got error response:</p>
<blockquote>
<p>[init] Using Kubernetes version: v1.14.1 [preflight] Running
pre-flight checks [WARNING
FileAvailable--etc-kubernetes-manifests-kube-apiserver.yaml]:
/etc/kubernetes/manifests/kube-apiserver.yaml already exists [WARNING
FileAvailable--etc-kubernetes-manifests-kube-controller-manager.yaml]:
/etc/kubernetes/manifests/kube-controller-manager.yaml already exists
[WARNING
FileAvailable--etc-kubernetes-manifests-kube-scheduler.yaml]:
/etc/kubernetes/manifests/kube-scheduler.yaml already exists [WARNING
FileAvailable--etc-kubernetes-manifests-etcd.yaml]:
/etc/kubernetes/manifests/etcd.yaml already exists [WARNING
IsDockerSystemdCheck]: detected "cgroupfs" as the Docker cgroup
driver. The recommended driver is "systemd". Please follow the guide
at <a href="https://kubernetes.io/docs/setup/cri/" rel="nofollow noreferrer">https://kubernetes.io/docs/setup/cri/</a> [WARNING Port-10250]: Port
10250 is in use [preflight] Pulling images required for setting up a
Kubernetes cluster [preflight] This might take a minute or two,
depending on the speed of your internet connection [preflight] You can
also perform this action in beforehand using 'kubeadm config images
pull' [WARNING ImagePull]: failed to pull image
k8s.gcr.io/kube-apiserver:v1.14.1: output: Error response from daemon:
Get <a href="https://k8s.gcr.io/v2/" rel="nofollow noreferrer">https://k8s.gcr.io/v2/</a>: x509: certificate signed by unknown
authority , error: exit status 1 [WARNING ImagePull]: failed to pull
image k8s.gcr.io/kube-controller-manager:v1.14.1: output: Error
response from daemon: Get <a href="https://k8s.gcr.io/v2/" rel="nofollow noreferrer">https://k8s.gcr.io/v2/</a>: x509: certificate
signed by unknown authority , error: exit status 1 [WARNING
ImagePull]: failed to pull image k8s.gcr.io/kube-scheduler:v1.14.1:
output: Error response from daemon: Get <a href="https://k8s.gcr.io/v2/" rel="nofollow noreferrer">https://k8s.gcr.io/v2/</a>: x509:
certificate signed by unknown authority , error: exit status 1
[WARNING ImagePull]: failed to pull image
k8s.gcr.io/kube-proxy:v1.14.1: output: Error response from daemon: Get
<a href="https://k8s.gcr.io/v2/" rel="nofollow noreferrer">https://k8s.gcr.io/v2/</a>: x509: certificate signed by unknown authority
, error: exit status 1 [WARNING ImagePull]: failed to pull image
k8s.gcr.io/pause:3.1: output: Error response from daemon: Get
<a href="https://k8s.gcr.io/v2/" rel="nofollow noreferrer">https://k8s.gcr.io/v2/</a>: x509: certificate signed by unknown authority
, error: exit status 1 [WARNING ImagePull]: failed to pull image
k8s.gcr.io/etcd:3.3.10: output: Error response from daemon: Get
<a href="https://k8s.gcr.io/v2/" rel="nofollow noreferrer">https://k8s.gcr.io/v2/</a>: x509: certificate signed by unknown authority
, error: exit status 1 [WARNING ImagePull]: failed to pull image
k8s.gcr.io/coredns:1.3.1: output: Error response from daemon: Get
<a href="https://k8s.gcr.io/v2/" rel="nofollow noreferrer">https://k8s.gcr.io/v2/</a>: x509: certificate signed by unknown authority
, error: exit status 1 [kubelet-start] Writing kubelet environment
file with flags to file "/var/lib/kubelet/kubeadm-flags.env"
[kubelet-start] Writing kubelet configuration to file
"/var/lib/kubelet/config.yaml" [kubelet-start] Activating the kubelet
service [certs] Using certificateDir folder "/etc/ssl/cert" [certs]
Generating "ca" certificate and key [certs] Generating "apiserver"
certificate and key [certs] apiserver serving cert is signed for DNS
names [k8s-master kubernetes kubernetes.default kubernetes.default.svc
kubernetes.default.svc.cluster.local] and IPs [10.96.0.1 192.168.50.10
192.168.50.10] [certs] Generating "apiserver-kubelet-client" certificate and key [certs] Generating "front-proxy-ca" certificate
and key [certs] Generating "front-proxy-client" certificate and key
[certs] Generating "etcd/ca" certificate and key [certs] Generating
"apiserver-etcd-client" certificate and key [certs] Generating
"etcd/server" certificate and key [certs] etcd/server serving cert is
signed for DNS names [k8s-master localhost] and IPs [192.168.50.10
127.0.0.1 ::1] [certs] Generating "etcd/peer" certificate and key [certs] etcd/peer serving cert is signed for DNS names [k8s-master
localhost] and IPs [192.168.50.10 127.0.0.1 ::1] [certs] Generating
"etcd/healthcheck-client" certificate and key [certs] Generating "sa"
key and public key [kubeconfig] Using kubeconfig folder
"/etc/kubernetes" error execution phase kubeconfig/admin: a kubeconfig
file "/etc/kubernetes/admin.conf" exists already but has got the wrong
CA cert</p>
</blockquote>
<p>command:</p>
<pre><code>kubeadm init --apiserver-advertise-address="192.168.50.10" --apiserver-cert-extra-sans="192.168.50.10" --pod-network-cidr=192.168.0.0/16 --kubernetes-version="v1.14.1" --ignore-preflight-errors all --cert-dir=/etc/kubernetes/pki
</code></pre>
<p>error trace:</p>
<pre><code>Unfortunately, an error has occurred:
timed out waiting for the condition
This error is likely caused by:
- The kubelet is not running
- The kubelet is unhealthy due to a misconfiguration of the node in some way (required cgroups disabled)
If you are on a systemd-powered system, you can try to troubleshoot the error with the following commands:
- 'systemctl status kubelet'
- 'journalctl -xeu kubelet'
Additionally, a control plane component may have crashed or exited when started by the container runtime.
To troubleshoot, list all containers using your preferred container runtimes CLI, e.g. docker.
Here is one example how you may list all Kubernetes containers running in docker:
- 'docker ps -a | grep kube | grep -v pause'
Once you have found the failing container, you can inspect its logs with:
- 'docker logs CONTAINERID'
error execution phase wait-control-plane: couldn't initialize a Kubernetes cluster
</code></pre>
<p>furthermore:</p>
<pre><code>root@k8s-master:~# systemctl status kubelet
● kubelet.service - kubelet: The Kubernetes Node Agent
Loaded: loaded (/lib/systemd/system/kubelet.service; enabled; vendor preset: enabled)
Drop-In: /etc/systemd/system/kubelet.service.d
└─10-kubeadm.conf
Active: active (running) since Wed 2019-04-24 00:13:07 UTC; 9min ago
Docs: https://kubernetes.io/docs/home/
Main PID: 9746 (kubelet)
Tasks: 16
Memory: 27.7M
CPU: 9.026s
CGroup: /system.slice/kubelet.service
└─9746 /usr/bin/kubelet --bootstrap-kubeconfig=/etc/kubernetes/bootstrap-kubelet.conf --kubeconfig=/etc/kubernetes/kubelet.conf --config=/var/lib/kubelet/config.yaml --cgroup-driver=cgroupfs --network-plugin=cni --pod-infra-container-image=k8s.gcr.io/pause:3.1
Apr 24 00:22:19 k8s-master kubelet[9746]: E0424 00:22:19.652197 9746 kubelet.go:2244] node "k8s-master" not found
Apr 24 00:22:19 k8s-master kubelet[9746]: E0424 00:22:19.711938 9746 controller.go:115] failed to ensure node lease exists, will retry in 7s, error: Get https://192.168.50.10:6443/apis/coordination.k8s.io/v1beta1/namespaces/kube-node-lease/leases/k8s-master?timeout=10s: dial tcp 192.168.50.10:6443: connect: connection refused
Apr 24 00:22:19 k8s-master kubelet[9746]: E0424 00:22:19.752613 9746 kubelet.go:2244] node "k8s-master" not found
Apr 24 00:22:19 k8s-master kubelet[9746]: E0424 00:22:19.818002 9746 reflector.go:126] k8s.io/client-go/informers/factory.go:133: Failed to list *v1beta1.CSIDriver: Get https://192.168.50.10:6443/apis/storage.k8s.io/v1beta1/csidrivers?limit=500&resourceVersion=0: dial tcp 192.168.50.10:6443: connect: connection refused
Apr 24 00:22:19 k8s-master kubelet[9746]: E0424 00:22:19.859028 9746 kubelet.go:2244] node "k8s-master" not found
Apr 24 00:22:19 k8s-master kubelet[9746]: E0424 00:22:19.960182 9746 kubelet.go:2244] node "k8s-master" not found
Apr 24 00:22:20 k8s-master kubelet[9746]: E0424 00:22:20.018188 9746 reflector.go:126] k8s.io/client-go/informers/factory.go:133: Failed to list *v1beta1.RuntimeClass: Get https://192.168.50.10:6443/apis/node.k8s.io/v1beta1/runtimeclasses?limit=500&resourceVersion=0: dial tcp 192.168.50.10:6443: connect: connection refused
Apr 24 00:22:20 k8s-master kubelet[9746]: E0424 00:22:20.061118 9746 kubelet.go:2244] node "k8s-master" not found
Apr 24 00:22:20 k8s-master kubelet[9746]: E0424 00:22:20.169412 9746 kubelet.go:2244] node "k8s-master" not found
Apr 24 00:22:20 k8s-master kubelet[9746]: E0424 00:22:20.250762 9746 reflector.go:126] k8s.io/kubernetes/pkg/kubelet/kubelet.go:442: Failed to list *v1.Service: Get https://192.168.50.10:6443/api/v1/services?limit=500&resourceVersion=0: dial tcp 192.168.50.10:6443: connect: connection refused
root@k8s-master:~#
</code></pre>
<p>looking at all docker containers:</p>
<pre><code>root@k8s-master:~# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
a22812e3c702 20a2d7035165 "/usr/local/bin/kube…" 4 minutes ago Up 4 minutes k8s_kube-proxy_kube-proxy-t7nq9_kube-system_20f8d57d-6628-11e9-b099-080027ee87c4_0
b2a89f8418bb k8s.gcr.io/pause:3.1 "/pause" 4 minutes ago Up 4 minutes k8s_POD_kube-proxy-t7nq9_kube-system_20f8d57d-6628-11e9-b099-080027ee87c4_0
6c327b9d36f2 cfaa4ad74c37 "kube-apiserver --ad…" 5 minutes ago Up 5 minutes k8s_kube-apiserver_kube-apiserver-k8s-master_kube-system_0260f2060ab76fc71c634c4499054fe6_1
a1f1b3396810 k8s.gcr.io/etcd "etcd --advertise-cl…" 5 minutes ago Up 5 minutes k8s_etcd_etcd-k8s-master_kube-system_64388d0f4801f9b4aa01c8b7505258c9_0
0a3619df6a61 k8s.gcr.io/kube-controller-manager "kube-controller-man…" 5 minutes ago Up 5 minutes k8s_kube-controller-manager_kube-controller-manager-k8s-master_kube-system_07bbd1f39b3ac969cc18015bbdce8871_0
ffb435b6adfe k8s.gcr.io/kube-apiserver "kube-apiserver --ad…" 5 minutes ago Exited (255) 5 minutes ago k8s_kube-apiserver_kube-apiserver-k8s-master_kube-system_0260f2060ab76fc71c634c4499054fe6_0
ffb463d4cbc6 k8s.gcr.io/pause:3.1 "/pause" 5 minutes ago Up 5 minutes k8s_POD_etcd-k8s-master_kube-system_64388d0f4801f9b4aa01c8b7505258c9_0
a9672f233952 k8s.gcr.io/kube-scheduler "kube-scheduler --bi…" 5 minutes ago Up 5 minutes k8s_kube-scheduler_kube-scheduler-k8s-master_kube-system_f44110a0ca540009109bfc32a7eb0baa_0
2bc0ab68870b k8s.gcr.io/pause:3.1 "/pause" 5 minutes ago Up 5 minutes k8s_POD_kube-controller-manager-k8s-master_kube-system_07bbd1f39b3ac969cc18015bbdce8871_0
667ae6988f2b k8s.gcr.io/pause:3.1 "/pause" 5 minutes ago Up 5 minutes k8s_POD_kube-apiserver-k8s-master_kube-system_0260f2060ab76fc71c634c4499054fe6_0
b4e6c37f5300 k8s.gcr.io/pause:3.1 "/pause" 5 minutes ago Up 5 minutes k8s_POD_kube-scheduler-k8s-master_kube-system_f44110a0ca540009109bfc32a7eb0baa_0
</code></pre>
| <p>remove the below param from init command </p>
<p>--node-name k8s-master</p>
<p>Include below param to deploy required kubernetes version</p>
<pre><code>--kubernetes-version v1.14.1
</code></pre>
|
<p>I have 3 nodes in k8s and i'm running kafka (3 cluster).
While deploying zk/broker/rest-proxy, its not getting deployed in all the available nodes. How can i make sure that all pods are deployed in different nodes. Do i need to use nodeaffinity or podaffinity ?</p>
| <p>If you want all pods to run on different nodes - you must use <a href="https://kubernetes.io/docs/concepts/configuration/assign-pod-node/#inter-pod-affinity-and-anti-affinity-beta-feature" rel="nofollow noreferrer">PodAntiAffinity</a>. If this is hard requirement - you must use <code>requiredDuringSchedulingIgnoredDuringExecution</code> rule. If it's not - use <code>preferredDuringSchedulingIgnoredDuringExecution</code>. </p>
<p><code>topologyKey</code> should be kubernetes.io/hostname. </p>
<p>In <code>labelSelector</code> put your pod's labels.</p>
|
<p>I'm fairly new to k8s, so forgive me if I misuse k8s terminology. I'm hoping someone could point me in the right direction and advise the best way to do this.</p>
<p>I have a k8s cluster running on a group of raspberry pis. I want to add a database volume accessible by all workers. I plan to use a usb external drive to store the database content.</p>
<p>Do I want to mount the external drive to the master node?</p>
<p>How is the external drive declared as a k8s resource?</p>
<p>Once configured, how is this external drive accessible by pods in other k8s nodes?</p>
<p>After reading through k8s Volumes page, it sounds like I might be looking for a Volume of "local" type. If I mount a local volume to the master node, will I be able to run a postgres container in a worker node and access the volume mounted on the master node?</p>
| <p>Easiest thing is to <a href="https://www.htpcguides.com/configure-nfs-server-and-nfs-client-raspberry-pi/" rel="nofollow noreferrer">set up NFS server</a> on master node, export your USB drive over NFS and then mount it as Persistent Volume in pod. For this you need first to create PersistentVolume:</p>
<pre><code>apiVersion: v1
kind: PersistentVolume
metadata:
name: nfs
spec:
capacity:
storage: 5Gi
accessModes:
- ReadWriteMany
nfs:
server: master-node-ip
path: /mnt/nfsserver
</code></pre>
<p>And then create PersistentVolumeClaim of the same size:</p>
<pre><code>apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: nfs
spec:
accessModes:
- ReadWriteMany
storageClassName: ""
resources:
requests:
storage: 5Gi
</code></pre>
<p>After that you can mount this PVC on all needed pods:</p>
<pre><code> volumeMounts:
- name: nfs
mountPath: "/usr/share/nginx/html"
volumes:
- name: nfs
persistentVolumeClaim:
claimName: nfs
</code></pre>
|
<p>I need a sidecar in kubernetes cluster which runs initialization script and then terminates or sleep forever. I can't do this in postStart as postStart does not guarantee the CMD / ENTRYPOINT in main container has started. Any advice and insight is appreciated.</p>
| <p>I use Job to accomplish the task.</p>
<pre><code>apiVersion: batch/v1
kind: Job
</code></pre>
|
<p>I have 2 Slave and 1 Master node kubernetes cluster.When a node down it takes approximately 5 minutes to kubernetes see that failure.I am using dynamic provisioning for volumes and this time is a little bit much for me.How can i reduce that detecting failure time ?
I found a post about it:
<a href="https://fatalfailure.wordpress.com/2016/06/10/improving-kubernetes-reliability-quicker-detection-of-a-node-down/" rel="nofollow noreferrer">https://fatalfailure.wordpress.com/2016/06/10/improving-kubernetes-reliability-quicker-detection-of-a-node-down/</a> </p>
<p>At the bottom of the post,it says, we can reduce that detection time by changing that parameters:</p>
<p><b>kubelet: node-status-update-frequency=4s (from 10s)<br>
controller-manager: node-monitor-period=2s (from 5s)<br>
controller-manager: node-monitor-grace-period=16s (from 40s)<br>
controller-manager: pod-eviction-timeout=30s (from 5m)</b></p>
<p>i can change node-status-update-frequency parameter from kubelet but i don't have any controller manager program or command on the cli.How can i change that parameters? Any other suggestions about reducing detect downtime will be appreciated.</p>
| <blockquote>
<p>..but i don't have any controller manager program or command on the
cli.How can i change that parameters?</p>
</blockquote>
<p>You can change/add that parameter in <code>controller-manger</code> systemd unit file and restart the daemon. Please check the man pages for <code>controller-manager</code> <a href="https://kubernetes.io/docs/reference/command-line-tools-reference/kube-controller-manager/" rel="nofollow noreferrer">here</a>. </p>
<p>If you deploy <code>controller-manager</code> as micro service(pod), check the manifest file for that pod and change the parameters at container's <code>command</code> section(For example like <a href="https://github.com/veerendra2/my-k8s-applications/blob/master/nodecellar/nodecellar-deployement.yaml#L23" rel="nofollow noreferrer">this</a>)</p>
|
<p>There're some ways to expose services: NodePort, LoadBalancer, etc</p>
<p>K8s cluster is in-network 192.168.10.0/24 but I want to access it from 10.100.10.0/24, assume that we have a firewall configured.</p>
<p>How can I access services in the k8s cluster from an external local network 10.100.10.0/24?</p>
| <p>You've already mentioned it <a href="https://kubernetes.io/docs/concepts/services-networking/service/#nodeport" rel="nofollow noreferrer"><code>NodePort</code></a> and <a href="https://kubernetes.io/docs/concepts/services-networking/service/#loadbalancer" rel="nofollow noreferrer"><code>LoadBalancer</code></a>. </p>
<p>In the case of <code>NodePort</code>, you would use the IP address of the node and the specific TCP/UDP port on that node.</p>
<p>In the case of <code>LoadBalancer</code>, you would you use an <a href="https://kubernetes.io/docs/concepts/services-networking/service/#internal-load-balancer" rel="nofollow noreferrer">'internal'</a> load balancer and use the IP or DNS entry for that load balancer.</p>
|
<p>Considering a very simple <strong>service.yaml</strong> file:</p>
<pre><code>kind: Service
apiVersion: v1
metadata:
name: gateway-service
spec:
type: NodePort
selector:
app: gateway-app
ports:
- name: gateway-service
protocol: TCP
port: 80
targetPort: 8080
nodePort: 30080
</code></pre>
<p>We know that service will route all the requests to the pods with this label <code>app=gateway-app</code> at port <code>8080</code> (a.k.a. <code>targetPort</code>). There is another <code>port</code> field in the service definition, which is <code>80</code> in this case here. What is this <code>port</code> used for? When should we use it? </p>
<p>From the documentation, there is also this line:</p>
<blockquote>
<p>By default the <code>targetPort</code> will be set to the same value as the port field.</p>
<p>Reference: <a href="https://kubernetes.io/docs/concepts/services-networking/service/" rel="noreferrer">https://kubernetes.io/docs/concepts/services-networking/service/</a></p>
</blockquote>
<p>In other words, when should we keep <code>targetPort</code> and <code>port</code> the same and when not?</p>
| <p>In a <code>nodePort</code> service you can have 3 types of ports defined:</p>
<p><strong>TargetPort</strong>:</p>
<p>As you mentioned in your question, this is the corresponding port to your pod and essentially the <code>containerPort</code>s you have defined in your replica manifest. </p>
<p><strong>Port (servicePort)</strong>: </p>
<p>This defines the port that other local resources can refer to. Quoting from the Kubernetes docs: </p>
<blockquote>
<p>this Service will be visible [locally] as .spec.clusterIP:spec.ports[*].port</p>
</blockquote>
<p>Meaning, this is not accessible publicly, however you can refer to your service port through other resources (within the cluster) with this port. An example is when you are creating an ingress for this service. In your ingress you will be required to present this port in the <code>servicePort</code> field:</p>
<pre><code> ...
backend:
serviceName: test
servicePort: 80
</code></pre>
<p><strong>NodePort</strong>: </p>
<p>This is the port on your node which publicly exposes your service. Again quoting from the docs:</p>
<blockquote>
<p>this Service will be visible [publicly] as [NodeIP]:spec.ports[*].nodePort</p>
</blockquote>
|
<p>I am trying to create a certain kind of networking infrastructure, and have been looking at Amazon ECS and Kubernetes. However I am not quite sure if these systems do what I am actually seeking, or if I am contorting them to something else. If I could describe my task at hand, could someone please verify if Amazon ECS or Kubernetes actually will aid me in this effort, and this is the right way to think about it?</p>
<p>What I am trying to do is on-demand single-task processing on an AWS instance. What I mean by this is, I have a resource heavy application which I want to run in the cloud and have process a chunk of data submitted by a user. I want to submit a this data to be processed on the application, have an EC2 instance spin up, process the data, upload the results to S3, and then shutdown the EC2 instance.</p>
<p>I have already put together a functioning solution for this using Simple Queue Service, EC2 and Lambda. But I am wondering would ECS or Kubernetes make this simpler? I have been going through the ECS documenation and it seems like it is not very concerned with starting up and shutting down instances. It seems like it wants to have an instance that is constantly running, then docker images are fed to it as task to run. Can Amazon ECS be configured so if there are no task running it automatically shuts down all instances?</p>
<p>Also I am not understanding how exactly I would submit a specific chunk of data to be processed. It seems like "Tasks" as defined in Amazon ECS really correspond to a single Docker container, not so much what kind of data that Docker container will process. Is that correct? So would I still need to feed the data-to-be-processed into the instances via simple queue service, or other? Then use Lambda to poll those queues to see if they should submit tasks to ECS?</p>
<p>This is my naive understanding of this right now, if anyone could help me understand the things I've described better, or point me to better ways of thinking about this it would be appreciated.</p>
| <p>This is a complex subject and many details for a good answer depend on the exact requirements of your domain / system. So the following information is based on the very high level description you gave.</p>
<p>A lot of the features of ECS, kubernetes etc. are geared towards allowing a distributed application that acts as a single service and is horizontally scalable, upgradeable and maintanable. This means it helps with unifying service interfacing, load balancing, service reliability, zero-downtime-maintenance, scaling the number of worker nodes up/down based on demand (or other metrics), etc. </p>
<p>The following describes a high level idea for a solution for your use case with kubernetes (which is a bit more versatile than AWS ECS). </p>
<p>So for your use case you could set up a kubernetes cluster that runs a distributed event queue, for example an Apache Pulsar cluster, as well as an application cluster that is being sent queue events for processing. Your application cluster size could scale automatically with the number of unprocessed events in the queue (<a href="https://docs.bitnami.com/kubernetes/how-to/configure-autoscaling-custom-metrics/" rel="nofollow noreferrer">custom pod autoscaler</a>). The cluster infrastructure would be configured to scale automatically based on the number of scheduled pods (pods reserve capacity on the infrastructure).</p>
<p>You would have to make sure your application can run in a stateless form in a container.</p>
<p>The main benefit I see over your current solution would be cloud provider independence as well as some general benefits from running a containerized system: 1. not having to worry about the exact setup of your EC2-Instances in terms of operating system dependencies of your workload. 2. being able to address the processing application as a single service. 3. Potentially increased reliability, for example in case of errors.</p>
<p>Regarding your exact questions:</p>
<blockquote>
<p>Can Amazon ECS be configured so if there are no task running it
automatically shuts down all instances?</p>
</blockquote>
<p>The keyword here is autoscaling. Note that there are two levels of scaling: 1. Infrastructure scaling (number of EC2 instances) and application service scaling (number of application containers/tasks deployed). ECS infrastructure scaling works based on EC2 autoscaling groups. For more info see <a href="https://docs.aws.amazon.com/AmazonECS/latest/developerguide/scale_cluster.html" rel="nofollow noreferrer">this link</a> . For application service scaling and serverless ECS (Fargate) see <a href="https://docs.aws.amazon.com/AmazonECS/latest/developerguide/service-auto-scaling.html" rel="nofollow noreferrer">this link</a>.</p>
<blockquote>
<p>Also I am not understanding how exactly I would submit a specific
chunk of data to be processed. It seems like "Tasks" as defined in
Amazon ECS really correspond to a single Docker container, not so much
what kind of data that Docker container will process. Is that correct?</p>
</blockquote>
<p>A "<a href="https://docs.aws.amazon.com/AmazonECS/latest/developerguide/task_definitions.html" rel="nofollow noreferrer">Task Definition</a>" in ECS is describing how one or multiple docker containers can be deployed for a purpose and what its environment / limits should be. A task is a single instance that is run in a "Service" which itself can deploy a single or multiple tasks. Similar concepts are Pod and Service/Deployment in kubernetes.</p>
<blockquote>
<p>So would I still need to feed the data-to-be-processed into the
instances via simple queue service, or other? Then use Lambda to poll
those queues to see if they should submit tasks to ECS?</p>
</blockquote>
<p>A queue is always helpful in decoupling the service requests from processing and to make sure you don't lose requests. It is not required if your application service cluster can offer a service interface and process incoming requests directly in a reliable fashion. But if your application cluster has to scale up/down frequently that may impact its ability to reliably process.</p>
|
<p>I have Prometheus setup for Windows containers which scrapes the metrics supported by the wmi_exporter. But I wanted some metrics that track the pod restarts, etc which are not part of that. I believe kube-state-metrics offers this functionality. But I could not find any way to install it on Windows containers. All the helm charts I found online have images that only work with Linux containers. So, is there any way to install it on Windows containers?</p>
<p>Is there any other better way to have alerts for pod/container restarts?</p>
| <p>You can use <a href="https://github.com/kubernetes/kube-state-metrics" rel="nofollow noreferrer">kube-state-metrics</a> like you said. From the Kubernetes control plane point of view, a pod/container restart is no different whether you are using Linux or Windows containers.</p>
<p>Keep in mind that the <a href="https://kubernetes.io/docs/setup/windows/#control-plane" rel="nofollow noreferrer">control plane</a> is only supported on Linux so in case you only have Windows nodes on your cluster you can run the kube-state-metrics pod/container in your master(s), otherwise, you will need a Linux node. Alternatively, you can build the kube-state-metrics Windows Go binary and run it on a Windows pod/container, but that could be more troublesome.</p>
<p>You can use something like <a href="https://stackoverflow.com/a/51245203/2989261">this</a> with <a href="https://prometheus.io/docs/alerting/alertmanager/" rel="nofollow noreferrer">Alertmanager</a> as an alert.</p>
|
<p>I'm trying to automate the process of simultaneously deploying an app onto multiple machines with kubernetes clusters. I'm new to kubernetes.</p>
<p>Which tool/technology should I use for this?</p>
| <p>Kubernetes doesn't really think in terms of machines (nodes in k8s jargon). When you set up a Deployment object, you specify a number of replicas to create, that's how many copies of the Pod to run. So rather than deploying on multiple machines, you create/update the Deployment once and set it to have multiple replicas which then get run on your cluster.</p>
|
<p>I'm using the nginx ingress controller on gke, by default these are what my access logs look like:</p>
<blockquote>
<p>"10.123.0.20 - [10.123.0.20] - - [22/Apr/2019:18:47:59 +0000] "GET /sdflksdf/sdfsdf HTTP/2.0" 404 0 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_2) AppleWebKit/538.12 (KHTML, like Gecko) Chrome/73.0.3683.100 Safari/537.36" 26 0.002 [default-blah-80] 10.44.0.26:80 0 0.001 404 skjf0s93jf0ws93jfsijf3s3fjs3i</p>
</blockquote>
<p>I want to add the x-forwarded-for header in my access logs. I'd like that field to be added at the end of the current log lines if possible. Or at the start of the log line would be OK too I guess.</p>
<p>Im looking at their docs and its not clear to me how to add x-forwarded-for to the access log:
<a href="https://kubernetes.github.io/ingress-nginx/user-guide/nginx-configuration/log-format/" rel="nofollow noreferrer">https://kubernetes.github.io/ingress-nginx/user-guide/nginx-configuration/log-format/</a></p>
| <p>You should use a ConfigMap to <a href="https://kubernetes.github.io/ingress-nginx/examples/customization/custom-configuration/" rel="noreferrer">customize the NGINX configuration</a>:</p>
<blockquote>
<p><a href="https://kubernetes.github.io/ingress-nginx/user-guide/nginx-configuration/configmap/" rel="noreferrer">ConfigMaps</a> allow you to decouple configuration artifacts from image
content to keep containerized applications portable.</p>
<p>The ConfigMap API resource stores configuration data as key-value
pairs. The data provides the configurations for system components for
the nginx-controller.</p>
</blockquote>
<p><strong>To configure custom logs, you need to use the <a href="https://kubernetes.github.io/ingress-nginx/user-guide/nginx-configuration/configmap/#log-format-upstream" rel="noreferrer"><code>log-format-upstream</code></a> key.</strong></p>
<p><strong>e.g.:</strong></p>
<p>Create the following configmap:</p>
<pre><code>apiVersion: v1
data:
log-format-upstream: '$remote_addr - $request_id - [$proxy_add_x_forwarded_for] - $remote_user [$time_local] "$request" $status $body_bytes_sent "$http_referer" "$http_user_agent" $request_length $request_time [$proxy_upstream_name] $upstream_addr $upstream_response_length $upstream_response_time $upstream_status'
kind: ConfigMap
metadata:
name: nginx-ingress-config
</code></pre>
<p>and make sure that you are using <code>--configmap=$(POD_NAMESPACE)/nginx-ingress-config</code> as command <code>args</code> for your nginx-ingress-controller (<a href="https://github.com/kubernetes/ingress-nginx/blob/e68b68d20cfc0e083f6b33413bc27887a05985f5/deploy/with-rbac.yaml#L30" rel="noreferrer">example from offical repo here</a>).</p>
|
<p>I have the following:</p>
<p>2 pod replicas, load balanced.
Each replica having 2 containers sharing network.</p>
<p>What I am looking for is a shared volume...</p>
<p>I am looking for a solution where the 2 pods and each of the containers in the pods can share a directory with read+write access. So if a one container from pod 1 writes to it, containers from pod 2 will be able to access the new data.</p>
<p>Is this achievable with persistent volumes and PVCs? if so what do i need and what are pointers to more details around what FS would work best, static vs dynamic, and storage class.</p>
<p>Can the volume be an S3 bucket?</p>
<p>Thank you!</p>
| <p>There are several options depending on price and efforts needed:</p>
<ol>
<li>Simplest but a bit more expensive solution is to use <a href="https://aws.amazon.com/efs/" rel="nofollow noreferrer">EFS</a> + <a href="https://kubernetes.io/docs/concepts/storage/volumes/#nfs" rel="nofollow noreferrer">NFS Persistent Volumes</a>. However, EFS has serious throughput limitations, read <a href="https://docs.aws.amazon.com/efs/latest/ug/performance.html" rel="nofollow noreferrer">here</a> for details.</li>
<li>You can create pod with NFS-server inside and again mount NFS Persistent Volumes into pods. See example <a href="https://medium.com/platformer-blog/nfs-persistent-volumes-with-kubernetes-a-case-study-ce1ed6e2c266" rel="nofollow noreferrer">here</a>. This requires more manual work and not completely highly available. If NFS-server pod fails, then you will observe some (hopefully) short downtime before it gets recreated.</li>
<li>For HA configuration you can provision <a href="https://github.com/gluster/gluster-kubernetes" rel="nofollow noreferrer">GlusterFS</a> on Kubernetes. This requires the most efforts but allows for great flexibility and speed.</li>
<li>Although mounting S3 into pods is somehow possible using awful crutches, this solution has numerous drawbacks and overall is not production grade. For testing purposes you can do that.</li>
</ol>
|
<p>Back-off restarting the failed container, the description is Container image <code>mongo:3.4.20</code> already present on the machine</p>
<p>I have removed all container into that system name mongo, removed all POD, svc, deployment, and rc, but getting the same error, also I tried to label another node with a different name and used that label in <code>yaml</code> but I got the same error. </p>
<p>I used below <code>yaml</code> for creating Deployment, in this case, I used to map system with name <code>app=mongodb</code>, also attached one 8 GB disk in AWS as <code>persistentVolumeClaim</code>.</p>
<pre><code>kind: Deployment
metadata:
name: mongo-deployment
labels:
app: mongo
spec:
replicas: 1
selector:
matchLabels:
app: mongodb
template:
metadata:
labels:
app: mongodb
spec:
containers:
- image: mongo:3.4.20
name: mongo
ports:
- name: mongo
containerPort: 27017
hostPort: 27017
volumeMounts:
- mountPath: "/data/db"
name: db-storage
volumes:
- name: db-storage
persistentVolumeClaim:
claimName: db-storage
</code></pre>
<p>why its always going failed and saying Container image already present on the machine, any cache?</p>
| <p>Addressed in comments, "already present on the machine" is not an error message. That's a pod event and is there only for debugging and tracing to give you an idea of what steps the kubelet is taking during the pod setup process.</p>
|
<p>I'm trying to automate the process of simultaneously deploying an app onto multiple machines with kubernetes clusters. I'm new to kubernetes.</p>
<p>Which tool/technology should I use for this?</p>
| <p>In kubernetes, you can control the nodes no which service to deploy or if multiple pods of same application should not be deployed on same node. Use <code>node-selector</code> or <code>node-affinity</code> or <code>node-anti-affinity</code>. For details check <a href="https://kubernetes.io/docs/concepts/configuration/assign-pod-node/" rel="nofollow noreferrer">https://kubernetes.io/docs/concepts/configuration/assign-pod-node/</a></p>
|
<p>I use Docker to package the Angular project (container use Nginx). When running on Docker, the images shows up ok, but when deploying to Kubernetes, using Ingress, all images in the <code>assets</code> folder do not appear.</p>
<p>Content-Type running on Docker. It's OK:</p>
<p><a href="https://i.stack.imgur.com/9qPUh.png" rel="nofollow noreferrer">Link Image</a></p>
<p>But when running on Kubernetes. Content type always is text/html:</p>
<p><a href="https://i.stack.imgur.com/MitKR.png" rel="nofollow noreferrer">Link Image</a></p>
<p>Config Ingress Kubernetes. Service name <code>ssite</code>.</p>
<pre><code>apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: abc-ingress
annotations:
kubernetes.io/ingress.global-static-ip-name: "swing-static-ip"
ingress.kubernetes.io/force-ssl-redirect: "true"
ingress.gcp.kubernetes.io/pre-shared-cert: "abc,xyz"
spec:
rules:
- host: abc.com
http:
paths:
- backend:
serviceName: sservice
servicePort: 8000
- host: xyz.com
http:
paths:
- path : /
backend:
serviceName: ssite
servicePort: 80
- path : /*
backend:
serviceName: ssite
servicePort: 80
</code></pre>
| <p>In your nginx config set <a href="http://nginx.org/en/docs/http/ngx_http_core_module.html#default_type" rel="nofollow noreferrer">default_type</a> directive </p>
<blockquote>
<p>Defines the default MIME type of a response. Mapping of file name
extensions to MIME types can be set with the types directive.</p>
</blockquote>
<pre><code>server {
...
default_type text/html;
location /assets/imgs {
default_type image/png;
}
location /assets/imgs {
default_type image/jpeg;
}
}
</code></pre>
|
<p>I have implemented leader election using kubernetes/client-go leader election. I have 2 replicas. For the first time both pod is selecting as leader, but same pod is not elected as leader after this. And the leader election get stopped after some time. I tried to delete one pod, then the new pod that is created is selected as leader. Again once the pod stopped leading, no pod is acting as leader. I am using configmap for resource lock. Please help me to solve the issue.</p>
<pre><code>func NewElectorWithCallbacks(namespace, configMapName, identity string, ttl time.Duration, client cli.CoreV1Interface, callbacks *leaderelection.LeaderCallbacks) (*leaderelection.LeaderElector, error) {
hostname, err := os.Hostname()
if err != nil {
return nil, err
}
broadcaster := record.NewBroadcaster()
broadcaster.StartLogging(log.Printf)
broadcaster.StartRecordingToSink(&cli.EventSinkImpl{Interface: client.Events(namespace)})
recorder := broadcaster.NewRecorder(scheme.Scheme, api.EventSource{Component: identity, Host: hostname})
cmLock := &resourcelock.ConfigMapLock{
Client: client,
ConfigMapMeta: meta.ObjectMeta{
Namespace: namespace,
Name: configMapName,
},
LockConfig: resourcelock.ResourceLockConfig{
Identity: identity,
EventRecorder: recorder,
},
}
if callbacks == nil {
callbacks = NewDefaultCallbacks()
}
config := leaderelection.LeaderElectionConfig{
Lock: cmLock,
LeaseDuration: ttl,
RenewDeadline: ttl / 2,
RetryPeriod: ttl / 4,
Callbacks: *callbacks,
}
return leaderelection.NewLeaderElector(config)
}
config, err = rest.InClusterConfig()
v1Client, err := v1.NewForConfig(config)
callbacks := &leaderelection.LeaderCallbacks{
OnStartedLeading: func(context.Context) {
// do the work
fmt.Println("selected as leader")
// Wait forever
select {}
},
OnStoppedLeading: func() {
fmt.Println("Pod stopped leading")
},
}
elector, err := election.NewElectorWithCallbacks(namespace, electionName, hostname, ttl, v1Client, callbacks)
elector.Run(context.TODO())
</code></pre>
<p><a href="https://i.stack.imgur.com/CZxx5.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/CZxx5.png" alt="enter image description here"></a></p>
| <p>You can deploy the pods as <code>statefullsets</code> & <code>headless service</code>. Please refer the <a href="https://kubernetes.io/docs/tutorials/stateful-application/basic-stateful-set/" rel="nofollow noreferrer">docs</a></p>
<p>Why?</p>
<ul>
<li>Pods will create sequentially. You define the first pod being launched is <code>Master</code> and rest are slaves. </li>
<li>Pods in a StatefulSet have a unique ordinal index and a stable network identity. For example below,</li>
</ul>
<pre><code> kubectl get pods -l app=nginx
NAME READY STATUS RESTARTS AGE
web-0 1/1 Running 0 1m
web-1 1/1 Running 0 1m
</code></pre>
<p>Even if the pod <code>web-0</code> restarts, the name or FQDN for pod never change.</p>
<p><code>web-0.nginx.default.svc.cluster.local</code></p>
<p><code><pod_name>.<service_name>.<namespace>.svc.cluster.local</code></p>
<p>I have only highlighted few points, please go though the docs completly. </p>
|
<p>In a classic Kubernetes Nginx ingress I know that it is possible to rewrite target url based on a specific regex by appling this annotation <code>nginx.ingress.kubernetes.io/rewrite-target: /$1
</code> </p>
<p>But this annotation does not work in AWS ALB ingress. Does anyone know if it is possible to do rewriting work with this kind of ingress?</p>
| <p>Ok, it seems not supported at this time => <a href="https://github.com/kubernetes-sigs/aws-alb-ingress-controller/issues/835" rel="noreferrer">https://github.com/kubernetes-sigs/aws-alb-ingress-controller/issues/835</a></p>
|
<p>I've recently learned about kubectl <code>--field-selector</code> flag, but ran into errors when trying to use it with various objects.</p>
<p>For example :</p>
<pre class="lang-sh prettyprint-override"><code>$ kubectl delete jobs.batch --field-selector status.succeeded==1
Error from server (BadRequest): Unable to find "batch/v1, Resource=jobs" that match label selector "", field selector "status.succeeded==1": field label "status.succeeded" not supported for batchv1.Job
</code></pre>
<p>According to <a href="https://kubernetes.io/docs/concepts/overview/working-with-objects/field-selectors/#supported-fields" rel="noreferrer">the documentation</a>, <code>Supported field selectors vary by Kubernetes resource type.</code>, so I guess this behaviour was to be expected.</p>
<p>The annoying part is that I had to try individually each field to know if I could use them or not.</p>
<p>Is there any way to get all the fields supported for a given resource type / resource version / kubectl version ?</p>
| <p>The issue in your case is that you mistakenly use <code>status.succeeded</code> instead of <code>status.successful</code>, so right command is</p>
<pre><code>kubectl delete jobs.batch --field-selector status.successful==1
No resources found
</code></pre>
<p>Regarding your question about all the fields: my suggestion is to deep into the code and search for proper resources types in conversion.go for each API.</p>
<p>Example:
<a href="https://github.com/kubernetes/kubernetes/blob/master/pkg/apis/batch/v1/conversion.go#L30-L41" rel="noreferrer">Batch Jobs conversion.go</a></p>
<pre><code> return scheme.AddFieldLabelConversionFunc(SchemeGroupVersion.WithKind("Job"),
func(label, value string) (string, string, error) {
switch label {
case "metadata.name", "metadata.namespace", "status.successful":
return label, value, nil
default:
return "", "", fmt.Errorf("field label %q not supported for batchv1.Job", label)
}
},
)
}
</code></pre>
|
<p>A cronjob we scheduled at night was started correctly but the image itself run much later than scheduled. We expect that there was a problem either pulling the image or requesting the resources from the cluster. Usually I can see such errors in the events section of the <code>kubectl describe job-name</code> output. In this section I can see events such as <code>pull image</code> <code>create container</code> etc. But after the job is finished, no events are shown anymore. </p>
<p>Is it possible the see those events for a finished job?</p>
<p>Or is there another way to investigate such a problem?</p>
| <p>The problem with storing events is wider than just cronjobs. Events in Kubernetes by default are stored only for 1 hour (--event-ttl flag for kube-apiserver). That means that if your cronjob was run two hours ago - you will not see events in "kubectl describe". </p>
<p>In order to save events for later investigations you need to export them somewhere. For example, Google Kubernetes Engine stores events into Stackdriver. For vanilla Kubernetes you may store events in Prometheus using <a href="https://github.com/caicloud/event_exporter" rel="noreferrer">event_exporter</a> or to <a href="https://github.com/alauda/event-exporter" rel="noreferrer">Elasticsearch</a>. Does that answer your question?</p>
|
<p>I have the following:</p>
<p>2 pod replicas, load balanced.
Each replica having 2 containers sharing network.</p>
<p>What I am looking for is a shared volume...</p>
<p>I am looking for a solution where the 2 pods and each of the containers in the pods can share a directory with read+write access. So if a one container from pod 1 writes to it, containers from pod 2 will be able to access the new data.</p>
<p>Is this achievable with persistent volumes and PVCs? if so what do i need and what are pointers to more details around what FS would work best, static vs dynamic, and storage class.</p>
<p>Can the volume be an S3 bucket?</p>
<p>Thank you!</p>
| <p>Refer to <a href="https://kubernetes.io/docs/concepts/storage/persistent-volumes/#access-modes" rel="nofollow noreferrer">https://kubernetes.io/docs/concepts/storage/persistent-volumes/#access-modes</a> for all available volume backends (You need <code>ReadWriteMany</code> compatibility)</p>
<p>As you can find there <code>AWSElasticBlockStore</code> doesn't support it. You will need any 3rd party volume provider which supports <code>ReadWriteMany</code>.</p>
<p>UPD: Another answer <a href="https://stackoverflow.com/a/51216537/923620">https://stackoverflow.com/a/51216537/923620</a> suggests that AWS EFS works too.</p>
|
<p>We are using kustomize for our kubernetes deployments in this way:</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:${IMAGE_VERSION}
ports:
- containerPort: 80
</code></pre>
<p>and deploy this yaml substituting the variable IMAGE_VERSION with 1.7.9</p>
<pre><code>kustomize build ./nginx/overlays/dev/ | sed -e 's|${IMAGE_VERSION}'"|1.7.9|g" | kubectl apply -f -
</code></pre>
<p>Since kubectl 1.14 supports kustomize.</p>
<p>now we can do something very nice like this</p>
<pre><code>kubectl apply -k ./
</code></pre>
<p>but how to substitute the IMAGE_VERSION variable with this new command?</p>
| <p>You have to create a <code>kustomization.yaml</code> file containing the customizations.</p>
<p>i.e:</p>
<pre><code># kustomization.yaml
bases:
- ../base
images:
- name: nginx-pod
newTag: 1.15
newName: nginx-pod-2
</code></pre>
<p>And for the templates, you create a base folder containing the kustomization.yaml with reference to the deployment and dependencies, i.e:</p>
<pre><code># ../base/kustomization.yaml
resources:
- deployment.yaml
</code></pre>
<p>and</p>
<pre><code># ../base/deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx-deployment
labels:
app: nginx
spec:
selector:
matchLabels:
app: nginx
template:
metadata:
labels:
app: nginx
spec:
containers:
- name: nginx
image: nginx-pod
</code></pre>
<p>Run the command:</p>
<p><code>kubectl apply -k</code></p>
<p>The above command will compile the customization and generate the following yaml to be applied to the cluster:</p>
<pre><code># Modified Base Resource
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app: nginx
name: nginx-deployment
spec:
selector:
matchLabels:
app: nginx
template:
metadata:
labels:
app: nginx
spec:
containers:
# The image image tag has been changed for the container
- name: nginx
image: nginx-pod-2:1.15
</code></pre>
|
<p>I am trying to understand how Kubernetes handles the persistent volumes on the node's filesystem.</p>
<p>For example, if I have a minikube as my Kubernetes cluster node, and I create multiple PVs with PVC for may pods and if I ssh to minikube, where I can find the PV on minikube's filesystem? </p>
<p>If I type </p>
<blockquote>
<p>lsblk</p>
</blockquote>
<p>I get </p>
<blockquote>
<p>sda 8:0 0 19.5G 0 disk</p>
</blockquote>
<p>but no PV disks are listed. </p>
<p>Thank you for your answers.</p>
| <p>You will not see it because it's inside API as an API Object.</p>
<p>I recommend reading Kubernetes documentation regarding <a href="https://kubernetes.io/docs/concepts/storage/persistent-volumes/" rel="nofollow noreferrer">Persistent Volumes</a>.</p>
<blockquote>
<p>A <code>PersistentVolume</code> (PV) is a piece of storage in the cluster that has been provisioned by an administrator. It is a resource in the cluster just like a node is a cluster resource. PVs are volume plugins like Volumes, but have a lifecycle independent of any individual pod that uses the PV. This API object captures the details of the implementation of the storage, be that NFS, iSCSI, or a cloud-provider-specific storage system.</p>
<p>A <code>PersistentVolumeClaim</code> (PVC) is a request for storage by a user. It is similar to a pod. Pods consume node resources and PVCs consume PV resources. Pods can request specific levels of resources (CPU and Memory). Claims can request specific size and access modes (e.g., can be mounted once read/write or many times read-only).</p>
<p>While <code>PersistentVolumeClaims</code> allow a user to consume abstract storage resources, it is common that users need <code>PersistentVolumes</code> with varying properties, such as performance, for different problems. Cluster administrators need to be able to offer a variety of <code>PersistentVolumes</code> that differ in more ways than just size and access modes, without exposing users to the details of how those volumes are implemented. For these needs there is the <code>StorageClass</code> resource.</p>
<p>Please see the <a href="https://kubernetes.io/docs/tasks/configure-pod-container/configure-persistent-volume-storage/" rel="nofollow noreferrer">detailed walkthrough with working examples</a>.</p>
</blockquote>
<p>You can also have a look at the <a href="https://matthewpalmer.net/kubernetes-app-developer/articles/kubernetes-volumes-example-nfs-persistent-volume.html" rel="nofollow noreferrer">Kubernetes Volumes Guide</a> which explains the types of storage, how long do they last and how to use them in examples.</p>
|
<p>I have different react apps and its backend-service deployed independently inside the Openshift. There is one app among them where users login and navigate to othes apps using links provided in this app.</p>
<p>Presently, the link of each app points directly to the "Openshift Route" (similar to Kube Ingress) of the react app.</p>
<p>But, this for production regions we have to change the way it works. There is one public domain exposed, say, <code>apps.mydomain.com</code>. We should make the links of each on the apps in such a way that it is loaded by this path, <code>apps.mydomain.com/reactapp1</code> should load reactapp1 & reactapp2 should be loaded in <code>apps.mydomain.com/reactapp2</code> and so on. </p>
<p>So there is one Ingress configured configured with paths</p>
<pre><code>rules:
- host: apps.mydomain.com
http:
paths:
- backend:
serviceName: home
servicePort: 8080
path: /
- backend:
serviceName: react-app-1
servicePort: 8080
path: /reactapp1
- backend:
serviceName: app-1-api
servicePort: 8080
path: /app1/api
- backend:
serviceName: react-app-2
servicePort: 8080
path: /reactapp2
- backend:
serviceName: app-2-api
servicePort: 8080
path: /app2/api
</code></pre>
<p>When I hit the url <code>https://apps.mydomain.com</code> it loads the <code>home</code> app, after login, on clicking the app links the apps doesn't load. Though I could see the browser title changed to the navigated app, I get this error <code>Uncaught SyntaxError: Unexpected token <</code>.</p>
<p>After lots of searches I find the react app should have to be configured differently if it needs to be deployed not from root.</p>
<p>What am I missing? Where am I doing wrong? Ingress or react app build? Can I have different Ingress with same domain but with different paths for each react-app & its backend api? </p>
| <p>You could use openshift routes instead of ingress for that, you can check on the docs how to apply it <a href="https://docs.openshift.com/container-platform/3.11/architecture/networking/routes.html#path-based-routes" rel="nofollow noreferrer">https://docs.openshift.com/container-platform/3.11/architecture/networking/routes.html#path-based-routes</a></p>
<p>One detail to pay attention if that your app will receive the relative path, it is not strip out of your request, for instance:</p>
<p><code>apps.mydomain.com/app2/api ---> app-2-api.svc:8080/app2/api</code></p>
|
<p>I have created a Mutating WebHook that works fine when the resulting pods reach healthy Running state. But when used with pods that ultimately fail (e.g. bad image name), the scheduler keeps creating more and more, up to 4000 pods that all error out and retry. If I disable the webhook, and the pod still fails for the same reason, then only 2 are attempted and all is normal failures. </p>
<p>Its like my webhook is creating "new" pods and not just mutating ones passed to it. This ONLY happens when the resulting pods fail to Run.</p>
<p>So what is about having the webhook in place that is causing so many additional pods to be scheduled when pods fail? </p>
| <p>Turns out I had a mistake in the webhook where instead of just adding an additional label to indicate the mutation was done, it was instead removing existing labels including the ones kube uses to manage the pod. So when the pod got mutated, it erased the control lables and consequently the scheduler thinks no pods had been created and kept creating new ones. Once fixed, all works normally.</p>
|
<p>I'm currently creating a kubernetes deployment, in this deployment I have replicas value set at X and I want to create X volume that are not empty when the corresponding pod is restarted.
I'm not using any cloud provider infrastructures then please avoid command using cloud services.</p>
<p>I've been searching answer in kubernetes doc, and my first try was to create one huge persistent volume and one persistant volume claim per pod that are bind to the pv but it's seem's to not work...</p>
<p>My expectations are to have X volumes that are not shared between pods and that are not dying when pod is killed because of a liveness probe.
I'm aware of any possibilities that can do the trick!</p>
| <p>Deployment replicas all use the same volume. There is no possibility currently to create independent volumes per replica.</p>
<p>StatefulSets can define <a href="https://kubernetes.io/docs/concepts/workloads/controllers/statefulset/#components" rel="noreferrer">volumeClaimTemplates</a> which means one or more independent volumes per replica. For that to work StorageClass must be capable of dynamic volume provisioning.</p>
|
<p>When I'm trying to describe on hpa following error is thrown:</p>
<pre><code>kubectl describe hpa go-auth
Error from server (NotFound): the server could not find the requested resource
</code></pre>
<p>My kubectl version is :</p>
<pre><code>Client Version: version.Info{Major:"1", Minor:"14", GitVersion:"v1.14.1", GitCommit:"b7394102d6ef778017f2ca4046abbaa23b88c290", GitTreeState:"clean", BuildDate:"2019-04-08T17:11:31Z", GoVersion:"go1.12.1", Compiler:"gc", Platform:"linux/amd64"}
Server Version: version.Info{Major:"1", Minor:"12+", GitVersion:"v1.12.7-gke.7", GitCommit:"b80664a77d3bce5b4701bc881d972b1a702290bf", GitTreeState:"clean", BuildDate:"2019-04-04T03:12:09Z", GoVersion:"go1.10.8b4", Compiler:"gc", Platform:"linux/amd64"}
</code></pre>
| <p>Beware of <a href="https://kubernetes.io/docs/setup/version-skew-policy/#kubectl" rel="nofollow noreferrer"><code>kubectl</code> version skew</a>. Running <code>kubectl</code> <strong>v1.14</strong> with <code>kube-apiserver</code> <strong>v1.12</strong> is not supported.</p>
<p>As per <a href="https://kubernetes.io/docs/tasks/tools/install-kubectl/#before-you-begin" rel="nofollow noreferrer"><code>kubectl</code> docs</a>:</p>
<blockquote>
<p>You must use a kubectl version that is within one minor version
difference of your cluster. For example, a v1.2 client should work
with v1.1, v1.2, and v1.3 master. Using the latest version of kubectl
helps avoid unforeseen issues.</p>
</blockquote>
<p>Give it another try using <code>kubectl</code> <strong>v1.12.x</strong> and you probably will get rid of this problem. Also, take a look at the <a href="https://github.com/kubernetes/kubectl/issues/568" rel="nofollow noreferrer">#568</a> issue (especially <a href="https://github.com/kubernetes/kubectl/issues/568#issuecomment-447924702" rel="nofollow noreferrer">this</a> comment), which addresses the same problem that you have.</p>
<p>If you are wondering on how to manage multiple <code>kubectl</code> versions, I recommend this read: <a href="https://medium.com/@eduardobaitello/using-different-kubectl-versions-with-multiple-kubernetes-clusters-a3ad8707b87b" rel="nofollow noreferrer">Using different kubectl versions with multiple Kubernetes clusters</a>.</p>
|
<p>I am writing an Airflow DAG to pull data from an API and store it in a database I own. Following best practices outlined in <a href="https://medium.com/bluecore-engineering/were-all-using-airflow-wrong-and-how-to-fix-it-a56f14cb0753" rel="nofollow noreferrer">We're All Using Airflow Wrong</a>, I'm writing the DAG as a sequence of <code>KubernetesPodOperator</code>s that run pretty simple Python functions as the entry point to the Docker image. </p>
<p>The problem I'm trying to solve is that this DAG should only pull data for the <code>execution_date</code>. </p>
<p>If I was using a <code>PythonOperator</code> (<a href="http://airflow.apache.org/_api/airflow/operators/python_operator/index.html" rel="nofollow noreferrer">doc</a>), I could use the <code>provide_context</code> argument to make the execution date available to the function. But judging from <a href="http://airflow.apache.org/_api/airflow/contrib/operators/kubernetes_pod_operator/index.html" rel="nofollow noreferrer">the KubernetesPodOperator's documentation</a>, it seems that the Kubernetes operator has no argument that does what <code>provide_context</code> does.</p>
<p>My best guess is that you could use the <code>arguments</code> command to pass in a date range, and since it's templated, you can reference it like this:</p>
<pre class="lang-py prettyprint-override"><code>my_pod_operator = KubernetesPodOperator(
# ... other args here
arguments=['python', 'my_script.py', '{{ ds }}'],
# arguments continue
)
</code></pre>
<p>And then you'd get the start date like you'd get any other argument provided to a Python file run as a script, by using <code>sys.argv</code>.</p>
<p>Is this the right way of doing it? </p>
<p>Thanks for the help.</p>
| <p>Yes, that is the correct way of doing it.</p>
<p>Each Operator would have <code>template_fields</code>. All the parameters listed in <code>template_fields</code> can render Jinja2 templates and Airflow Macros.</p>
<p>For KubernetesPodOperator, if you check <a href="http://airflow.apache.org/1.10.3/_api/airflow/contrib/operators/kubernetes_pod_operator/index.html#airflow.contrib.operators.kubernetes_pod_operator.KubernetesPodOperator.template_fields" rel="noreferrer">docs</a>, you would find:</p>
<pre><code>template_fields = ['cmds', 'arguments', 'env_vars', 'config_file']
</code></pre>
<p>which means you can pass <code>'{{ ds }}'</code>to any of the four params listed above.</p>
|
<p>I have a simple single-pod postgresql deployment running on AWS EKS (code <a href="https://github.com/seandavi/postgresql_zombodb_docker/tree/master/kubernetes" rel="nofollow noreferrer">here</a>). I have exposed the pod using a load balancer.</p>
<pre><code>kubectl get services/postgres-lb -o yaml
</code></pre>
<p>This yields the following:</p>
<pre><code>apiVersion: v1
kind: Service
metadata:
annotations:
service.beta.kubernetes.io/aws-load-balancer-connection-draining-enabled: "false"
service.beta.kubernetes.io/aws-load-balancer-type: nlb
creationTimestamp: 2019-04-23T02:36:54Z
labels:
app: postgres
name: postgres-lb
namespace: default
resourceVersion: "1522157"
selfLink: /api/v1/namespaces/default/services/postgres-lb
uid: <HASHREMOVED?
spec:
clusterIP: 10.100.94.170
externalTrafficPolicy: Cluster
ports:
- nodePort: 32331
port: 5434
protocol: TCP
targetPort: 5432
selector:
app: postgres
sessionAffinity: None
type: LoadBalancer
status:
loadBalancer:
ingress:
- hostname: ...aaadz-example.elb.us-east-1.amazonaws.com
</code></pre>
<p>This works and I can access the pod as expected. However, the connection to postgresql seems to drop about every minute or so if not active. I am pretty sure that at least some AWS load balancers behave this way to "drain connections"; hence the annotation above to NOT drain connections. However, I still see the same behavior of dropping connections if idle. </p>
<p>What is the best practice on AWS EKS for hosting a database, for example, and then exposing its single port to the internet? Web searches have turned up many variations, but all seem either overly complicated or not directly applicable. I have used GCE and found it to be much more straightforward with respect to network and exposing ports, so I feel like I am missing something obvious on AWS.</p>
| <p>Try setting <code>service.beta.kubernetes.io/aws-load-balancer-connection-idle-timeout</code> annotation to some larger value (by default it is 60 seconds in AWS).</p>
|
<p>I am trying to authenticate my Kafka rest proxy with SASL but I am having trouble transferring the configs made in my local docker compose to Kubernetes.</p>
<p>I am using JAAS configuration to achieve this.
My JAAS file looks like this.</p>
<pre><code>KafkaClient {
org.apache.kafka.common.security.plain.PlainLoginModule required
username="rest"
password="rest-secret";
};
Client {
org.apache.zookeeper.server.auth.DigestLoginModule required
username="rest"
password="restsecret";
};
</code></pre>
<p>and then in my docker compose I have done:</p>
<p><code>KAFKA_OPTS: -Djava.security.auth.login.config=/etc/kafka/secrets/rest_jaas.conf</code></p>
<p>How will I transfer this same logic to Kubernetes?
I have tried passing the env variable like this:</p>
<pre><code>env:
- name: KAFKA_OPTS
value: |
KafkaClient {
org.apache.kafka.common.security.plain.PlainLoginModule required
username="rest"
password="rest-secret";
};
Client {
org.apache.zookeeper.server.auth.DigestLoginModule required
username="rest"
password="rest-secret";
};
</code></pre>
<p>but it still fails. Here is what my logs say:</p>
<pre><code>Error: Could not find or load main class KafkaClient
/bin/sh: 3: org.apache.kafka.common.security.plain.PlainLoginModule: not found
/bin/sh: 6: Syntax error: "}" unexpected
</code></pre>
<p>Your help will be highly appreciated.</p>
| <p>Save your Kafka JAAS config file as rest_jaas.conf. Then execute:</p>
<pre><code>kubectl create secret generic kafka-secret --from-file=rest_jaas.conf
</code></pre>
<p>Then in your deployment you insert:</p>
<pre><code> env:
- name: KAFKA_OPTS
value: -Djava.security.auth.login.config=/etc/kafka/secrets/rest_jaas.conf
volumeMounts:
- name: kafka-secret
mountPath: /etc/kafka/secrets
subPath: rest_jaas.conf
volumes:
- name: kafka-secret
secret:
secretName: kafka-secret
</code></pre>
|
<p>Curiously, I saw that a pod I had had both ready 1/1 status and status <code>terminating</code> when I ran <code>kubectl get pods</code>. Are these states not mutually exclusive? Why or why not?</p>
<p>For context, this was noticed immediately after I had killed <code>skaffold</code> so these pods were in the middle of shutting down. </p>
<p><a href="https://i.stack.imgur.com/mY5S8.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/mY5S8.png" alt="enter image description here"></a></p>
| <p>When pods are in terminating state, they could still be functioning. The pod could be delayed in termination due to many reasons (eg. could be that you have a PVC attached, other pods are being terminated at the same time, etc). You could test this by running the following on a pod with a PVC attached or another reason to be terminated with a delay:</p>
<pre><code>$ kubectl delete pod mypod-xxxxx-xxxxxx
pod mypod-xxxxx-xxxxxx deleted
$ kubectl delete pod mypod-xxxxx-xxxxxx
pod mypod-xxxxx-xxxxxx deleted
$ kubectl apply mypod.yaml
pod mypod-xxxxx-xxxxxx configured
</code></pre>
<p>Sometimes this happens because the pod is still in the terminating period and is functioning normally, so it will be treated as an existing pod that gets configured (neglecting the fact that you usually can't configure pods like this, but you get the point).</p>
|
<p>I'm working with a kubernetes cluster to deploy a high available web application, the web application needs a database to store data .</p>
<p>Is it possible to ensure relational database replication (mysql, postgres or oracle) with multiple masters in kubernetes ?</p>
<p>Any helpful comments would be appreciated.</p>
| <p>If the engine can do multi-master outside of Kubernetes, it can do inside. However, I would suggest not reinvent the wheel and use existing operators (<a href="https://coreos.com/blog/introducing-operators.html" rel="nofollow noreferrer">see what operator pattern is</a>) for databases you mentioned:</p>
<ul>
<li>MySQL: <a href="https://banzaicloud.com/blog/mysql-on-kubernetes/" rel="nofollow noreferrer">https://banzaicloud.com/blog/mysql-on-kubernetes/</a></li>
<li>Postgres: <a href="https://github.com/zalando/postgres-operator" rel="nofollow noreferrer">https://github.com/zalando/postgres-operator</a></li>
<li>Postgres: <a href="https://github.com/CrunchyData/postgres-operator" rel="nofollow noreferrer">https://github.com/CrunchyData/postgres-operator</a></li>
</ul>
<p>In particular, <a href="https://github.com/oracle/mysql-operator" rel="nofollow noreferrer">https://github.com/oracle/mysql-operator</a> (described in bullet 1) claimed the support of the multi-master.</p>
|
<p>I have added several <a href="https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale/" rel="noreferrer">Horizontal Pod Autoscalers</a> (HPAs) to a Kubernetes cluster. I want to monitor the number of replicas of each pod over time.</p>
<p>Does <a href="https://cloud.google.com/stackdriver/" rel="noreferrer">StackDriver</a> have an option to monitor the number of replicas of each pod over time? When creating a metric I can't find an option that will allow me to do this.</p>
| <p>I don't think you can count pods, but you can count containers. With a constant number of containers inside the replicated Pods and proper filtering, you'll get what you need.</p>
<p>While in Stackdriver go to Dashboard -> Create dashboard. Select the following settings:</p>
<pre><code>Resource type: GKE Container
Metric: Uptime
Filter: (that's actually up to you, probably some label would work)
Group by: (use this if you want to have several lines on the chart at once)
Aggregator: count
</code></pre>
<p>What this does is basically gather all the uptimes of containers in your cluster, filter this data through your criteria, and count how many entries are left. This gives you the number of containers that were up at given time. When a container doesn't exist, there's no entry for it, so the number of entries is lower.</p>
<p>If you have only one container per pod, then that's it. If you have more, just take that into account and divide the values on the chart byt the number of containers per pod.</p>
<p><a href="https://i.stack.imgur.com/EZ3u9.png" rel="noreferrer"><img src="https://i.stack.imgur.com/EZ3u9.png" alt="example config"></a></p>
|
<p>I am trying to set up an horizontal pod auto scaling in GKE. No proper documentation found to reduce the --horizontal-pod-autoscaler-sync-period to 5 sec using kube-controller-manager. </p>
<p>In the below link it says there is a possibility of changing the flags:</p>
<p><a href="https://kubernetes.io/docs/reference/command-line-tools-reference/kube-controller-manager/" rel="nofollow noreferrer">https://kubernetes.io/docs/reference/command-line-tools-reference/kube-controller-manager/</a> </p>
<p>Is there any proper implementation steps to this?</p>
| <p>You are not able do this on GKE, EKS and other managed clusters.</p>
<p>In order to change/add flags in kube-controller-manager - you should have access to your <code>/etc/kubernetes/manifests/</code> directory on master node and be able to modify parameters in <code>/etc/kubernetes/manifests/kube-controller-manager.yaml</code>.</p>
<p>GKE, EKS and other clusters manages only by their providers without getting you permissions to have access to master nodes.</p>
<p>But you can create cluster with <a href="https://kubernetes.io/docs/setup/independent/create-cluster-kubeadm/" rel="noreferrer">kubeadm init</a> and configure/change as you like.</p>
|
<p>Im attempting to create an python script to evict nodes based on some criteria and im having trouble getting the <a href="https://github.com/kubernetes-client/python/blob/master/kubernetes/docs/CoreV1Api.md#create_namespaced_pod_eviction" rel="nofollow noreferrer">create_namespaced_pod_eviction</a>
to behave properly. From what I can tell from the api documentation my syntax looks pretty correct. Any help is appreciated. I'll also mention that the kubernetes cluster is 1.10 on AWS EKS</p>
<pre><code> for i in pods.items:
print("Deleting pod: ", i.metadata.name, i.metadata.namespace, node)
body = kubernetes.client.V1beta1Eviction()
api_response = v1.create_namespaced_pod_eviction(i.metadata.name, i.metadata.namespace, body, dry_run='All', include_uninitialized='True', pretty='True')
</code></pre>
<p>This is the output:</p>
<pre><code>('Deleting pod: ', 'ambassador-5d86576878-4kv6w', 'istio-system', 'ip-10-72-20-161.ec2.internal')
Traceback (most recent call last):
File "src/update_workernodes.py", line 105, in <module>
main()
File "src/update_workernodes.py", line 99, in main
evict_pods(old_worker_dns)
File "src/update_workernodes.py", line 82, in evict_pods
api_response = v1.create_namespaced_pod_eviction(name=i.metadata.name, namespace=i.metadata.namespace, body=body, dry_run='All', include_uninitialized='True', pretty='True')
File "/usr/local/lib/python2.7/site-packages/kubernetes/client/apis/core_v1_api.py", line 6353, in create_namespaced_pod_eviction
(data) = self.create_namespaced_pod_eviction_with_http_info(name, namespace, body, **kwargs)
File "/usr/local/lib/python2.7/site-packages/kubernetes/client/apis/core_v1_api.py", line 6450, in create_namespaced_pod_eviction_with_http_info
collection_formats=collection_formats)
File "/usr/local/lib/python2.7/site-packages/kubernetes/client/api_client.py", line 321, in call_api
_return_http_data_only, collection_formats, _preload_content, _request_timeout)
File "/usr/local/lib/python2.7/site-packages/kubernetes/client/api_client.py", line 155, in __call_api
_request_timeout=_request_timeout)
File "/usr/local/lib/python2.7/site-packages/kubernetes/client/api_client.py", line 364, in request
body=body)
File "/usr/local/lib/python2.7/site-packages/kubernetes/client/rest.py", line 266, in POST
body=body)
File "/usr/local/lib/python2.7/site-packages/kubernetes/client/rest.py", line 222, in request
raise ApiException(http_resp=r)
kubernetes.client.rest.ApiException: (400)
Reason: Bad Request
HTTP response headers: HTTPHeaderDict({'Date': 'Tue, 13 Nov 2018 02:34:52 GMT', 'Audit-Id': '7a3725ac-5b1c-470b-a743-0af202a56f7c', 'Content-Length': '175', 'Content-Type': 'application/json'})
HTTP response body: {
"kind": "Status",
"apiVersion": "v1",
"metadata": {
},
"status": "Failure",
"message": "Name parameter required.",
"reason": "BadRequest",
"code": 400
}
</code></pre>
| <p>For those who stumble across this, I was able to get this working by doing the following:</p>
<pre><code>podName = 'insert-name-of-pod'
podNamespace = 'insert-namespace-of-pod'
body = client.V1beta1Eviction(metadata=client.V1ObjectMeta(name=podName, namespace=podNamespace))
api_response = v1.create_namespaced_pod_eviction(name=podName, namespace=podNamespace, body=body)
</code></pre>
|
<p>Not sure what I am doing wrong, but I am experiencing an issue where CronJobs stop scheduling new Jobs. It <em>seems</em> like this happens only after a couple of failures to launch a new Job. In my specific case, Jobs were not able to start due an inability to pull the container image.</p>
<p>I'm not really finding any settings that would lead to this, but I'm no expert on Kubernetes CronJobs. Configuration below:</p>
<pre><code>apiVersion: batch/v1beta1
kind: CronJob
metadata:
labels:
app.kubernetes.io/instance: cron-deal-report
app.kubernetes.io/managed-by: Tiller
app.kubernetes.io/name: cron
helm.sh/chart: cron-0.1.0
name: cron-deal-report
spec:
concurrencyPolicy: Forbid
failedJobsHistoryLimit: 1
jobTemplate:
metadata:
creationTimestamp: null
spec:
template:
spec:
containers:
- args:
- -c
- npm run script
command:
- /bin/sh
env:
image: <redacted>
imagePullPolicy: Always
name: cron
resources: {}
securityContext:
runAsUser: 1000
terminationMessagePath: /dev/termination-log
terminationMessagePolicy: File
dnsPolicy: ClusterFirst
restartPolicy: Never
schedulerName: default-scheduler
securityContext: {}
terminationGracePeriodSeconds: 30
schedule: 0/15 * * * *
successfulJobsHistoryLimit: 3
suspend: false
status: {}
</code></pre>
| <h2>How kubernetes jobs handle failures</h2>
<p>As per <a href="https://kubernetes.io/docs/concepts/workloads/controllers/jobs-run-to-completion/#handling-pod-and-container-failures" rel="noreferrer">Jobs - Run to Completion - Handling Pod and Container Failures</a>:</p>
<blockquote>
<p>An entire Pod can <s>also</s> fail, for a number of reasons, such as when the
pod is kicked off the node (node is upgraded, rebooted, deleted,
etc.), <strong>or if a container of the Pod fails and the
<code>.spec.template.spec.restartPolicy = "Never"</code></strong>. When a Pod fails, then
the Job controller starts a new Pod.</p>
</blockquote>
<p>You are using <code>restartPolicy: Never</code> for your <code>jobTemplate</code>, so, see the next quote on <a href="https://kubernetes.io/docs/concepts/workloads/controllers/jobs-run-to-completion/#pod-backoff-failure-policy" rel="noreferrer">Pod backoff failure policy</a>:</p>
<blockquote>
<p>There are situations where you want to fail a Job after some amount of
retries due to a logical error in configuration etc. To do so, set
<code>.spec.backoffLimit</code> to specify the number of retries before considering
a Job as failed. <strong>The back-off limit is set by default to 6</strong>. The back-off count is reset if no new failed Pods appear before the Job’s next status check.</p>
</blockquote>
<p>The <code>.spec.backoffLimit</code> is not defined in your <code>jobTemplate</code>, so it's using the default (<code>6</code>).</p>
<p>Following, as per <a href="https://kubernetes.io/docs/concepts/workloads/controllers/jobs-run-to-completion/#job-termination-and-cleanup" rel="noreferrer">Job Termination and Cleanup</a>:</p>
<blockquote>
<p>By default, a Job will run uninterrupted unless a Pod fails, at which
point the Job defers to the <code>.spec.backoffLimit</code> described above. Another way to terminate a Job is by setting an active deadline. Do this by setting the <code>.spec.activeDeadlineSeconds</code> field of the Job to a number of seconds. </p>
</blockquote>
<p>That's your case: <strong>If your containers fail to pull the image six consecutive times, your Job will be considered as failed.</strong></p>
<hr>
<h2>Cronjobs</h2>
<p>As per <a href="https://kubernetes.io/docs/concepts/workloads/controllers/cron-jobs/#cron-job-limitations" rel="noreferrer">Cron Job Limitations</a>:</p>
<blockquote>
<p>A cron job creates a job object about once per execution time of its schedule [...]. The Cronjob is
only responsible for creating Jobs that match its schedule, and the
Job in turn is responsible for the management of the Pods it
represents.</p>
</blockquote>
<p>This means that all pod/container failures should be handled by the Job Controller (i.e., adjusting the <code>jobTemplate</code>).</p>
<p><strong>"Retrying" a Job:</strong></p>
<p>You do not need to recreate a Cronjob in case its Job of fails. You only need to wait for the next schedule.</p>
<p>If you want to run a new Job before the next schedule, you can use the Cronjob template to create a Job manually with:</p>
<pre><code>kubectl create job --from=cronjob/my-cronjob-name my-manually-job-name
</code></pre>
<hr>
<h2>What you should do:</h2>
<p>If your containers are unable to download the images constantly, you have the following options:</p>
<ul>
<li>Explicit set and tune <code>backoffLimit</code> to a higher value.</li>
<li>Use <code>restartPolicy: OnFailure</code> for your containers, so the Pod will stay on the node, and only the container will be re-run.</li>
<li><em>Consider using <a href="https://kubernetes.io/docs/concepts/containers/images/#updating-images" rel="noreferrer"><code>imagePullPolicy: IfNotPresent</code></a>. If you are not retagging your images, there is no need to force a re-pull for every job start.</em></li>
</ul>
|
<p>I am using <code>EKS</code> (<code>K8s</code> service natively provided by <code>AWS</code>).</p>
<p>My questions are:</p>
<ol>
<li>Is it possible to expose <code>NodePort</code> service through port 80 and 443 (default <code>NodePort</code> range is <code>30000 - 32767</code>).</li>
<li>If it is, how to do that with <code>EKS</code>.</li>
</ol>
<p><strong>Note</strong> I know the consequences of using <code>NodePort</code> services and have researched alternatives like <code>LoadBalancer</code> and <code>Ingress</code>. I am going ahead with NodePort because I have to.</p>
| <ol>
<li><p>No. According to the <a href="https://github.com/awslabs/amazon-eks-ami" rel="nofollow noreferrer">EKS AMI Source</a>, the worker nodes' kubelets use the default configuration for <code>--service-node-port-range</code>. You will be assigned an external port number between <code>30000-32767</code>.</p>
</li>
<li><p>You have the alternative of using the node's <strong>hostNetwork</strong> to expose port 80 and 443 as <strong>hostPort</strong>. A description of the setup can be found <a href="http://alesnosek.com/blog/2017/02/14/accessing-kubernetes-pods-from-outside-of-the-cluster/" rel="nofollow noreferrer">here</a>. Just keep in mind the networking constraints and caveats of using a hostNetwork!</p>
</li>
</ol>
|
<p>I'm using Ansible and the <code>k8s</code> module for deploying applications to an OpenShift cluster. In general this is working really well.</p>
<p>However, when I try to set the port value, in a deployment config, using a value from a variable, things are not so happy.</p>
<p>I have the following ansible task as an example:</p>
<pre><code>- name: Create app service
k8s:
name: "{{ name | lower }}"
state: present
definition:
apiVersion: v1
kind: Service
metadata:
annotations:
labels:
app: "{{ name | lower }}"
name: "{{ name | lower }}"
namespace: "{{ name | lower }}"
spec:
ports:
- name: "{{ port }}-tcp"
port: "{{ port }}"
protocol: TCP
targetPort: "{{ port | int }}" <--- the problem!
selector:
deploymentconfig: "{{ name | lower }}"
sessionAffinity: None
type: ClusterIP
status:
loadBalancer: {}
</code></pre>
<p>The variable is set in a yaml file, which is read into the playbook, and the variable is set like <code>port: "5000"</code>.</p>
<p>If I change this to <code>port: 5000</code> then it solves the problem, but I use this variable in several other places and other playbooks, so I would prefer to keep the variable as is.</p>
<p>I have tried using the approaches to solve this:
<code>"{{ port | int }}"</code></p>
<p>An example of the error I get is:</p>
<pre><code>fatal: [localhost]: FAILED! => {"changed": false, "error": 422, "msg": "Failed to patch object: {\"kind\":\"Status\",\"apiVersion\":\"v1\",\"metadata\":{},\"status\":\"Failure\",\"message\":\"Service \\\"myapp\\\" is invalid: spec.ports[0].targetPort: Invalid value: \\\"7001\\\": must contain at least one letter or number (a-z, 0-9)\",\"reason\":\"Invalid\",\"details\":{\"name\":\"usdt-wallet\",\"kind\":\"Service\",\"causes\":[{\"reason\":\"FieldValueInvalid\",\"message\":\"Invalid value: \\\"5000\\\": must contain at least one letter or number (a-z, 0-9)\",\"field\":\"spec.ports[0].targetPort\"}]},\"code\":422}\n", "reason": "Unprocessable Entity", "status": 422}
</code></pre>
| <p>According to the posted error message, your problem isn't <code>|int</code> or <code>|string</code> -- although I agree the error message is misleading:</p>
<blockquote>
<p>"message": "Service \"usdt-wallet\" is invalid: spec.ports[0].targetPort: Invalid value: \"70001\": must contain at least one letter or number (a-z, 0-9)",</p>
</blockquote>
<p>but it is caused by trying to use 70001 as a target port but TCP ports must be in the range 1 to 65535 inclusive, as stated by <a href="https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.14/#serviceport-v1-core" rel="nofollow noreferrer">the fine manual</a></p>
|
<p>I have some problems with MongoDB.</p>
<p>I have 2 replicas of NodeJS and 1 MongoDB. Default data is loaded always twice in the database. How to fix this?</p>
<p>I have <code>databaseLoader.js</code> function which is load data in DB:</p>
<pre><code>mongoose.promise = Promise;
mongoose.set('useCreateIndex', true);
mongoose.set('useFindAndModify', false);
mongoose.connect(MONGODB_URI, {useNewUrlParser: true})
.then(
() => {
logger.info('Successfully connected to mongoDB');
loader.loadDefaultData()
.then(response => {
});
},
)
.catch(err => {
logger.error('Connection to MongoDB could not be established');
});
</code></pre>
| <p>I don't know for what purpose you run 2 replicas to load demo data and connect to db but if you have 2 replicas in your deployment, then each replica will run independently, so it means it will load demo data twice.</p>
<p>If you have some application and you want to check if there is db connectivity, before starting the application, you can use <a href="https://kubernetes.io/docs/concepts/workloads/pods/init-containers/#understanding-init-containers" rel="nofollow noreferrer">initContainer</a></p>
<blockquote>
<p>Init Containers are exactly like regular Containers, except:</p>
<ul>
<li><p>They always run to completion.</p>
</li>
<li><p>Each one must complete successfully
before the next one is started.</p>
</li>
</ul>
</blockquote>
|
<p>I am trying to install Kubernetes Helm and Tiller for my Kubernetes cluster. Currently I installed Helm client by following command,</p>
<pre><code>sudo snap install helm --classic
</code></pre>
<p>And now I am trying to run '<strong>helm init</strong>' command to install Tiller in my cluster. I have my configuration file in <strong>.kube/config</strong> path. And I am running the helm init command. But When I am running this, I am getting the following error:</p>
<p><strong>Updated Error</strong></p>
<pre><code>$HELM_HOME has been configured at /home/docker/.helm.
Error: error installing: deployments.extensions is forbidden: User "system:node:mildevkub020" cannot create resource "deployments" in API group "extensions" in the namespace "kube-system"
</code></pre>
<p>Do I need to change any cluster information in kubelet.conf? How I can resolve this error?</p>
| <p>You are getting this error because you have not initialized helm with a service account.</p>
<p>In rbac-config.yaml:</p>
<pre><code>apiVersion: v1
kind: ServiceAccount
metadata:
name: tiller
namespace: kube-system
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: tiller
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: cluster-admin
subjects:
- kind: ServiceAccount
name: tiller
namespace: kube-system
</code></pre>
<p><strong>Step 1</strong>: kubectl apply -f rbac-config.yaml</p>
<p><strong>Step 2</strong>: helm init --service-account tiller --history-max 200</p>
<p><strong>Step 3</strong>: Test the setup with <code>heml ls</code>. There would not be any output from running this command and that is expected. Now, you can run <code>helm create myfirstchart</code></p>
|
<p>On Macbook Pro, tried installing from binary with curl and then with brew.</p>
<p>Both installs generate an error at the end of output:</p>
<pre><code>~ via 🐘 v7.1.23
➜ kubectl version --output=yaml
clientVersion:
buildDate: "2019-04-19T22:12:47Z"
compiler: gc
gitCommit: b7394102d6ef778017f2ca4046abbaa23b88c290
gitTreeState: clean
gitVersion: v1.14.1
goVersion: go1.12.4
major: "1"
minor: "14"
platform: darwin/amd64
error: unable to parse the server version: invalid character '<' looking for beginning of value
</code></pre>
<p>Is there a way to fix this?</p>
| <p>I think there is another application listening on 8080 port. By default, <code>kubectl</code> will try to connect on localhost:8080 if no <code>server</code> is passed.</p>
<p>If you have deployed kubernetes <code>apiserver</code> on some other machine or port, pass <code>--server=IP:PORT</code> to <code>kubectl</code>. </p>
|
<p>I have an image from base os centos/systemd.when i give "exec /usr/sbin/init" in the laucher file of the container and creating the container using docker systemd services are up.
But when i create a container using the same image in kubernetes with the same launcher file systemd services are not comming up.How to run the /usr/sbin/init in the kubernetes so the systemd services comes up during the container creation</p>
| <p>To solve this issue you can use kubernetes init container which run first before the main container creation and start the necessary services.</p>
<pre><code>apiVersion: v1
kind: Pod
metadata:
name: myapp-pod
labels:
app: myapp
spec:
initContainers:
- name: check-system-ready
image: busybox
command: ['sh', '-c', 'Your sysntax for systemd']
containers:
- your container spec
</code></pre>
<p>Sharing here official kubernetes init container doc : <a href="https://kubernetes.io/docs/concepts/workloads/pods/init-containers/" rel="nofollow noreferrer">https://kubernetes.io/docs/concepts/workloads/pods/init-containers/</a></p>
<blockquote>
<p><a href="https://kubernetes.io/docs/tasks/configure-pod-container/configure-pod-initialization/" rel="nofollow noreferrer">https://kubernetes.io/docs/tasks/configure-pod-container/configure-pod-initialization/</a></p>
</blockquote>
|
<p>I am trying to track down some bottlenecks in a GKE kubernetes cluster. I am trying to rule out resource (cpu and memory) limits. However, I am having trouble because there are resource limits set on the containers in the deployment yaml files, but there are also resource quotas set as defaults in the cluster that presumably don't apply when they are specified in the container definitions. But then I have also read that you can have pod resource limits and even limits on specific namespaces.</p>
<p>Where is the authoritative listing of what limits are being applied to a container? If I kubectl Describe the Node that has the pods, should the limits in the details be the actual limits?</p>
| <p>I see you confusion, but reality is more simple.
First of all - resource requests and limits are applied on container level, not pod. Pod resources are defined as simple sum of its container resources.</p>
<ol>
<li><a href="https://kubernetes.io/docs/concepts/policy/resource-quotas/" rel="nofollow noreferrer">Namespace quotas</a>. They influence the namespace as a whole and do not influence pods themselves. The only thing namespace quota does is ensuring that sum of all pod resources in given namespace does not exceed the configured limits. If you have reasonably high namespace quota - you may forget that it even exists. But you should remember that once you define namespace quota - any single container in namespace must have resources specified. </li>
<li><a href="https://kubernetes.io/docs/tasks/administer-cluster/manage-resources/memory-default-namespace/#create-a-limitrange-and-a-pod" rel="nofollow noreferrer">LimitRange</a>. LimitRange works on namespace level. You can configure default resource requests and limits both for pods and containers. Another thing it does is specifying minimum and maximum resources for pods and containers in namespace.</li>
<li>The last but the most important is the actual pod resources. I guess this thing is more or less self-explanatory in this context.</li>
</ol>
<p>Now, when you hit "kubectl describe" on node or pod - then the <strong>actual</strong> pod requests and limits are displayed. Actual means those resources that matter. It does not matter where those resources came from - from deployment/pod spec or from LimitRange. What you see is what you get here, regardless of have you specified some quotas or LimitRange or not.</p>
<p>Does that answer your question?</p>
|
<p>I'm trying to deploy mongodb on Kubernetes but I'm getting the error: </p>
<blockquote>
<p>error parsing stateful.yaml: error converting YAML to JSON: yaml: line
35: mapping values are not allowed in this context</p>
</blockquote>
<p>the line 35 is the container name: - name: <strong>uat-mongo-primary</strong></p>
<p>I get this error when i try to create the pods but if i comment the lines :</p>
<blockquote>
<p>mongo --eval rs.initiate({_id: "rs0", version: 1, members: [{ _id: 0,
host : "uat-mongo-primary-rc-0:27017" }]}); 53 mongo
--eval "db.getSiblingDB('admin').createUser({user : \"$MONGO_USER\", pwd : \"$MONGO_PASSWORD\", roles: [ { role: 'root', db: 'admin' } ]
})";</p>
</blockquote>
<p>the pods being create normally but i need to initiate the cluster also create an user and password.</p>
<p>this is the full yaml file I'm using, i will appreciate any help:</p>
<pre><code>apiVersion: v1
kind: Service
metadata:
name: uat-mongo-primary
labels:
name: uat-mongo-primary
spec:
type: NodePort
ports:
- port: 27017
targetPort: 27017
protocol: TCP
name: uat-mongo-primary
selector:
name: uat-mongo-primary
---
apiVersion: apps/v1beta1
kind: StatefulSet
metadata:
name: uat-mongo-primary-rc
labels:
name: uat-mongo-primary-rc
spec:
serviceName: uat-mongo-primary
replicas: 1
template:
metadata:
labels:
role: mongo
environment: test
spec:
containers:
- name: uat-mongo-primary
image: mongo
env:
- name: "MONGO_DATA_DIR"
value: "/data/db"
- name: "MONGO_LOG_DIR"
value: "/data/logs"
- name: MONGO_USER
value: "admin"
- name: MONGO_PASSWORD
value: "password"
command: ["/bin/sh", "-c"]
args:
- echo starting;
ulimit -a;
mongod --replSet rs0 --bind_ip_all;
mongo --eval rs.initiate({_id: "rs0", version: 1, members: [{ _id: 0, host : "uat-mongo-primary-rc-0:27017" }]});
mongo --eval "db.getSiblingDB('admin').createUser({user : \"$MONGO_USER\", pwd : \"$MONGO_PASSWORD\", roles: [ { role: 'root', db: 'admin' } ] })";
ports:
- containerPort: 27017
volumes:
- name: uat-mongo-primary-db
persistentVolumeClaim:
claimName: uat-mongo-primary-pvc
</code></pre>
| <p>It is not possible to use YAML strings containing colons (at least with kubectl). You should convert your YAML to JSON (using <a href="https://codebeautify.org/yaml-to-json-xml-csv" rel="nofollow noreferrer">this</a> tool for example) and apply that JSON with kubectl.</p>
|
<p>I created a service and each service is creating a new load balancer, I don't want to create a new load balancer for each service. For that, I found solution ingress controller but it's not happening.</p>
| <p>I will try to describe the objects you need in just words.</p>
<p>You don't need to create a load balancer for each service. When you're using an ingress controller (like nginx), the ingress controller itself will be the type load balancer. All your other services need to be something like ClusterIP type.</p>
<p>Afterwards you can decide how to link your ClusterIP services with the Nginx LoadBalancer: create an ingress for each service or one ingress that exposes each service based on some rule (like paths as @harsh-manvar shows in the post above).</p>
<p>When you say "it's not happening", it would be good if you could provide details on your setup.</p>
<p>In order for Nginx ingress controller to work, it needs to be defined either as a NodePort or LoadBalancer service type. The examples provided in the nginx documentation are using LoadBalancer. However, LoadBalancer only works when your cluster supports this object (that means running in most cloud providers like AWS/GCP/Azure/DigitalOcean or newer versions of minikube). On the other hand, NodePort will expose the ingress controller on the Kubernetes node where it runs (when using minikube, that usually means a VM of sorts which then needs to be port forwarded to be accessible).</p>
<p>To use ingress in a local environment, you can look into minikube. All you need is to run <code>minikube addons enable ingress</code> and it will deploy an nginx controller for you. Afterwards, all you need to do is define an ingress and depending on your setup you may need to use <code>kubectl port-forward</code> to port forward port 80 on an nginx controller pod to a local port on your machine.</p>
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.