Posts

Showing posts with the label kubernetes

Kubernetes tries to start Rails twice on the same pod

Kubernetes tries to start Rails twice on the same pod I'm trying to get my dokerized Rails app to run on Kubernetes hosted at GCP. kubectl apply -f k8s/webshop.yml kubectl get pods NAME READY STATUS RESTARTS AGE shop-lcvxc 2/3 CrashLoopBackOff 23 1h So far so good, but the app will not start. Investigating further reveals that it has tried to start Rails (Puma) twice. Any idea why this happens? Logs $ kubectl logs shop-lcvxc -c webshop => Booting Puma => Rails 5.2.0 application starting in development => Run `rails server -h` for more startup options initialize PushNotifications Puma starting in single mode... * Version 3.11.4 (ruby 2.4.4-p296), codename: Love Song * Min threads: 5, max threads: 5 * Environment: development * Listening on tcp://0.0.0.0:3001 Exiting /usr/local/bundle/gems/puma-3.11.4/lib/puma/binder.rb:270:in `initialize': Address already in use - bind(2) for "0.0.0.0" port 3001 (Errno:...

kubernetes mountPath vs hostPath

kubernetes mountPath vs hostPath I am trying to deploy an app to kubernetes cluster and I want to store data in Persistent Volume . However, I am very confused about two parameters in the setup. Can someone explains what is the different between volumes.hostPath and volumeMounts.mountPath ? I read some documentations online but it does not help me to understand. volumeMounts: - mountPath: /var/lib/mysql volumes: hostPath: path: /k8s If my setup is as above, is the volume going to be mounted at /k8s/var/lib/mysql ? /k8s/var/lib/mysql 1 Answer 1 The mount path is always the destination inside the Pod a volume gets mounted to. I think the documentation is pretty clear on what hostPath does: A hostPath volume mounts a file or directory from the host node’s filesystem into your Pod. This is not something that most Pods will need, but it offers a powerful escape hatch for some applications. F...

Share data between pods in ReadMany mode and allow to write only for one host(WriteOnce)

Share data between pods in ReadMany mode and allow to write only for one host(WriteOnce) We've got to write files from one host in a shared storage and share these files between many pods in read only state . Like this: writer -> shared storage <- pod_reader_nth I tried to use Google Persistent Storage , but k8s doesn't allow to mix ReadMany and WriteOnce. Is there any way to solve this issue simple, like use some SaaS solution and don't use CephFS/GlusterFS/NFS? inb4: Tried Google Cloud Storage buckets, but got degraded performance when wrote a lot of files. All volume types are listed at this link. When using ReadWriteMany to Persistent Volumes, you are limited to these options at this link. According to the same document “ a volume can only be mounted using one access mode at a time, even if it supports many.” This is true for all volume plugins listed, and not only GCEPersistentDisk. Unfortunately I can not think of an alternative easi...

Unable to serve Angular application through minikube (Kubenetes) on Windows

Unable to serve Angular application through minikube (Kubenetes) on Windows I am running Docker for Windows and Minikube (Kubernetes) to serve an Angular application. The angular application is served using ng serve and is working properly on windows. I created the below Dockerfile: ng serve # Use an official Nodejs runtime as a parent image FROM node:6.10.3 #Create an unprivileged user 'app' #Install dependencies RUN useradd --user-group --create-home --shell /bin/false app && npm install -g grunt-cli && npm install -g @angular/cli # Define environment variable ENV ENVIRONMENT="dev" HOME=/home/app #Copy the code to the image COPY . $HOME/frontend/ #Chmod the files to allow unprivileged user 'app' to read/write RUN chown -R app:app $HOME/* #Use unprivileged user 'app' to run the app inside the container USER app #Set Current Working Directory of the runtime WORKDIR $HOME/frontend #Install NPM dependencies RUN npm install # Make p...

Why running Kubeadm cluster on AWS is failing very often?

Why running Kubeadm cluster on AWS is failing very often? I have created a Kubeadm cluster on AWS(Ubuntu) instance. I have deployed my application on it. My cluster has been failing and returning errors very often. I have attached screenshot. Please check it. This is the third time which happened to me. I have to reset my cluster every time. Can you please suggest any method or solution to overcome this problem? This is the error message Posting a screenshot is astronomically unhelpful; what are the apiserver's container logs? How many apiservers do you have in your cluster? What is in the kubelet 's logs? What is in journalctl ? Do you have a load balancer in front of your apiserver? – Matthew L Daniel 2 days ago kubelet journalctl By clicking "Post Your Answe...

How can I write a minimal NetworkPolicy to firewall a Kubernetes application with a Service of type LoadBalancer using Calico?

How can I write a minimal NetworkPolicy to firewall a Kubernetes application with a Service of type LoadBalancer using Calico? I have a Kubernetes cluster running Calico as the overlay and NetworkPolicy implementation configured for IP-in-IP encapsulation and I am trying to expose a simple nginx application using the following Service: apiVersion: v1 kind: Service metadata: name: nginx namespace: default spec: type: LoadBalancer ports: - port: 80 targetPort: 80 selector: app: nginx I am trying to write a NetworkPolicy that only allows connections via the load balancer. On a cluster without an overlay, this can be achieved by allowing connections from the CIDR used to allocate IPs to the worker instances themselves - this allows a connection to hit the Service's NodePort on a particular worker and be forwarded to one of the containers behind the Service via IPTables rules. However, when using Calico configured for IP-in-IP, connections made via the NodePort use C...