question
stringlengths
11
28.2k
answer
stringlengths
26
27.7k
tag
stringclasses
130 values
question_id
int64
935
78.4M
score
int64
10
5.49k
I have a project that was started in Objective-C, and I am trying to import some Swift code into the same class files that I have previously written Objective-C in. I have consulted the Apple docs on using Swift and Objective-C in the same project, as well as SO question like this, but still no avail: I continue to get...
I was running into the same issue and couldn't get my project to import Swift into Objective-C classes. Using Xcode 6, (should work for Xcode 6+) and was able to do it in this way: Any class that you need to access in the .h file needs to be a forward declaration like this: @class MySwiftClass; In the .m file ONLY...
Swift
26,328,034
177
I have been trying to initialise a string from NSData in Swift. In the NSString Cocoa Documentation Apple is saying you have to use this: init(data data: NSData!, encoding encoding: UInt) However Apple did not include any example for usage or where to put the init. I am trying to convert the following code from Objec...
This is the implemented code needed: in Swift 3.0: var dataString = String(data: fooData, encoding: String.Encoding.utf8) or just var dataString = String(data: fooData, encoding: .utf8) Older swift version: in Swift 2.0: import Foundation var dataString = String(data: fooData, encoding: NSUTF8StringEncoding) in Swi...
Swift
24,023,253
177
Is there such thing as a startsWith() method or something similar in Swift? I'm basically trying to check if a certain string starts with another string. I also want it to be case insensitive. As you might be able to tell, I'm just trying to do a simple search feature but I seem to be failing miserably at this. This i...
use hasPrefix instead of startsWith. Example: "hello dolly".hasPrefix("hello") // This will return true "hello dolly".hasPrefix("abc") // This will return false
Swift
32,664,543
176
How can I deal with this error without creating additional variable? func reduceToZero(x:Int) -> Int { while (x != 0) { x = x-1 // ERROR: cannot assign to 'let' value 'x' } return x } I don't want to create additional variable just to store the value of x. Is it even possible to do what...
As stated in other answers, as of Swift 3 placing var before a variable has been deprecated. Though not stated in other answers is the ability to declare an inout parameter. Think: passing in a pointer. func reduceToZero(_ x: inout Int) { while (x != 0) { x = x-1 } } var a = 3 reduceToZero(&a) pri...
Swift
24,077,880
176
I would like to keep the border at the bottom part only in UITextField. But I don't know how we can keep it on the bottom side. Can you please advise me?
I am creating custom textField to make it reusable component for SwiftUI SwiftUI struct CustomTextField: View { var placeHolder: String @Binding var value: String var lineColor: Color var width: CGFloat var body: some View { VStack { TextField(self.placeHolder, text: $v...
Swift
26,800,963
175
I am trying to implement a CollectionView. When I am using Autolayout, my cells won't change the size, but their alignment. Now I would rather want to change their sizes to e.g. var size = CGSize(width: self.view.frame.width/10, height: self.view.frame.width/10) I tried setting in my CellForItemAtIndexPath collectionC...
Use this method to set custom cell height width. Make sure to add this protocols UICollectionViewDelegate UICollectionViewDataSource UICollectionViewDelegateFlowLayout If you are using swift 5 or xcode 11 and later you need to set Estimate Size to none using storyboard in order to make it work properly. If you will ...
Swift
38,028,013
174
I am using Swift and I want to be able to load a UIViewController when I rotate to landscape, can anyone point me in the right direction? I Can't find anything online and a little bit confused by the documentation.
Here's how I got it working: In AppDelegate.swift inside the didFinishLaunchingWithOptions function I put: NotificationCenter.default.addObserver(self, selector: #selector(AppDelegate.rotated), name: UIDevice.orientationDidChangeNotification, object: nil) and then inside the AppDelegate class I put the following func...
Swift
25,666,269
174
Here's my SwiftUI code: struct ContentView : View { @State var showingTextField = false @State var text = "" var body: some View { return VStack { if showingTextField { TextField($text) } Button(action: { self.showingTextField.toggle() }) { ...
Using SwiftUI-Introspect, you can do: TextField("", text: $value) .introspectTextField { textField in textField.becomeFirstResponder() }
Swift
56,507,839
173
I have done some research, but I couldn't find any code example on how to center cells in a UICollectionView horizontally. instead of the first cell being like this X00, I want it to be like this 0X0. is there any way to accomplish this? EDIT: to visualize what I want: I need it to look like version B when there is on...
Its not a good idea to use a library, if your purpose is only this i.e to centre align. Better you can do this simple calculation in your collectionViewLayout function. func collectionView(collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, insetForSectionAtIndex section: Int) -> UIEd...
Swift
34,267,662
173
I would like to make a UILabel clickable. I have tried this, but it doesn't work: class DetailViewController: UIViewController { @IBOutlet weak var tripDetails: UILabel! override func viewDidLoad() { super.viewDidLoad() ... let tap = UITapGestureRecognizer(target: self, action: Selecto...
Have you tried to set isUserInteractionEnabled to true on the tripDetails label? This should work.
Swift
33,658,521
173
I am trying to build an input screen for the iPhone. The screen has a number of input fields. Most of them on the top of the screen, but two fields are at the bottom. When the user tries to edit the text on the bottom of the screen, the keyboard will pop up and it will cover the screen. I found a simple solution to m...
Your problem is well explained in this document by Apple. Example code on this page (at Listing 4-1) does exactly what you need, it will scroll your view only when the current editing should be under the keyboard. You only need to put your needed controls in a scrollViiew. The only problem is that this is Objective-C a...
Swift
28,813,339
173
I have a short mp4 video file that I've added to my current Xcode6 Beta project. I want to play the video in my app. After hours searching, I can't find anything remotely helpful. Is there a way to accomplish this with Swift or do you have to use Objective-C? Can I get pointed in the right direction? I can't be the on...
Sure you can use Swift! 1. Adding the video file Add the video (lets call it video.m4v) to your Xcode project 2. Checking your video is into the Bundle Open the Project Navigator cmd + 1 Then select your project root > your Target > Build Phases > Copy Bundle Resources. Your video MUST be here. If it's not, then you sh...
Swift
25,348,877
173
I'm using Xcode 6 Beta 4. I have this weird situation where I cannot figure out how to appropriately test for optionals. If I have an optional xyz, is the correct way to test: if (xyz) // Do something or if (xyz != nil) // Do something The documents say to do it the first way, but I've found that sometimes, the secon...
In Xcode Beta 5, they no longer let you do: var xyz : NSString? if xyz { // Do something using `xyz`. } This produces an error: does not conform to protocol 'BooleanType.Protocol' You have to use one of these forms: if xyz != nil { // Do something using `xyz`. } if let xy = xyz { // Do something using `xy...
Swift
25,097,727
173
While using Swift4 and Codable protocols I got the following problem - it looks like there is no way to allow JSONDecoder to skip elements in an array. For example, I have the following JSON: [ { "name": "Banana", "points": 200, "description": "A banana grown in Ecuador." }, { ...
One option is to use a wrapper type that attempts to decode a given value; storing nil if unsuccessful: struct FailableDecodable<Base : Decodable> : Decodable { let base: Base? init(from decoder: Decoder) throws { let container = try decoder.singleValueContainer() self.base = try? container.de...
Swift
46,344,963
172
I have a struct that implements Swift 4’s Codable. Is there a simple built-in way to encode that struct into a dictionary? let struct = Foo(a: 1, b: 2) let dict = something(struct) // now dict is ["a": 1, "b": 2]
If you don't mind a bit of shifting of data around you could use something like this: extension Encodable { func asDictionary() throws -> [String: Any] { let data = try JSONEncoder().encode(self) guard let dictionary = try JSONSerialization.jsonObject(with: data, options: .allowFragments) as? [String: Any] el...
Swift
45,209,743
172
I am doing a proof of concept to demonstrate how we might implement 3scale in our stack. In one example I want to do some POST request body manipulation to create an API façade that maps what might be a legacy API format to a new internal one. Eg. change something like { "foo" : "bar" , "deprecated" : true } into { "...
I will suggest you to use access_by_lua in nginx.conf location / { #host and port to fastcgi server default_type text/html; set $URL "http://$http_host$request_uri"; access_by_lua_file /home/lua/cache.lua; proxy_pass http://$target; ...
3Scale
22,788,236
19
Edit: The answer is so clear. One may use the flag --user root when entering the container. docker exec -it --user root mycontainername bash or sh I just downloaded this official docker hub's 1.5.0-alpine image for a service (Kong API Gateway) and now I can not run apk commands to install nano, for in...
You can run a command within the container as root using --user root. To get a shell: docker exec -it --user root kong sh
Kong
61,683,448
35
I have a Kong API Gateway container and a postgres container and I need to check whether postgres has started up and ready from the Kong container before running the migrations. I was thinking of installing the postgres client utilities into a custom image based on the official Kong image using RUN yum install postgres...
Here is a shell one liner using pg_isready tool provided by PostgreSQL. To call outside docker: DOCKER_CONTAINER_NAME="mypgcontainer" timeout 90s bash -c "until docker exec $DOCKER_CONTAINER_NAME pg_isready ; do sleep 5 ; done" Based on a post from Jeroma Belleman.
Kong
46,516,584
34
Afternoon y'all, Just looking for someone to double check my work. Is the below an effective way to secure microservices? Premise Breaking up our monolithic application and monolithic Partner API into microservices oriented around specific business functions. They'll most likely be small expressjs applications running ...
I recently worked on a solution to this very question and premise, refactoring a large monolith into multiple services in an AWS architecture. There is no right, wrong or definitive how to this question. However, we did implement a solution very similar to the one described in the question above. I hope this answer can...
Kong
34,640,611
23
I have been developing microservices (Spring Cloud) for a while (~2 years) and heavily used Netflix Zuul. While it offers a lot of functionalities and great features, my developer mind wandered towards knowing about the alternatives and came to know about Tyk and Kong. Reading from the individual documentation and blog...
According to CI/CD both can comply with Infrastructure-as-Code approach, so i do not see difference in terms on Deployment Pipeline practices. tyk API function-set is more compared to Kong, which may make sense if you rely your business on API(need to integrate with some Billing, ...) https://tyk.io/docs/tyk-rest-api/...
Kong
46,769,814
18
I am stuck in choosing One API gateway from the three API gateways mentioned below: KrakenD (https://www.krakend.io/) Kong (https://konghq.com/kong/) Spring Cloud Gateway (https://cloud.spring.io/spring-cloud-gateway/reference/html/) My requirements are: Good performance and must have majority of the API gateway fea...
API Gateway is a concept that is used in all kind of products, I really think the industry should start sub-categorizing these products as most of them are completely different from each other. I'll try to summarize here the main highlights according to your requirements. Both Kong and KrakenD offer the "majority" of A...
Kong
60,050,154
15
I am currently playing around with the Kong API Gateway and I would like to use it to validate the authentication of users at the gateway and restrict access to services if the user is not logged in properly. I have an authentication service which issues JWTs whenever a user logs in. I would now like to share the JWT ...
The answer given by Riley is sort of correct in implementation but that is not the intended use of a consumer in the Kong. A consumer in kong is the application that is is using the API. So, unless you have multiple vendors using your app/web service, I suggest you create a single consumer. You can create multiple key...
Kong
36,060,029
10
I have an a service that accepts POSTs with base64 encoded files in the body. I'm currently getting Error: 413 Request Entity Too Large when I POST anything larger than 1MB, otherwise it works fine. My setup has kong proxying to the service. I have the following annotation for the proxy's ingress installed via the sta...
the annotation seemed to work fine. The limitation I was running into was because the code I was testing was in a kubeless. The kubeless functions use bottle and the ingress limit was on bottle. I increased that in a custom python3.7 image for kubeless and all worked fine.
Kong
57,329,247
10
Which is the difference between a Role or a ClusterRole? When should I create one or the other one? I don't quite figure out which is the difference between them.
From the documentation: A Role can only be used to grant access to resources within a single namespace. Example: List all pods in a namespace A ClusterRole can be used to grant the same permissions as a Role, but because they are cluster-scoped, they can also be used to grant access to: cluster-scoped resources ...
Kubernetes
51,647,643
56
Say I have a service that isn't hosted on Kubernetes. I also have an ingress controller and cert-manager set up on my kubernetes cluster. Because it's so much simpler and easy to use kubernetes ingress to control access to services, I wanted to have a kubernetes ingress that points to a non-kubernetes service. For...
You can do it by manual creation of Service and Endpoint objects for your external server. Objects will looks like that: apiVersion: v1 kind: Service metadata: name: external-ip spec: ports: - name: app port: 80 protocol: TCP targetPort: 5678 clusterIP: None type: ClusterIP --- apiVersion: v1 kind...
Kubernetes
57,764,237
55
I’ve created a Cronjob in kubernetes with schedule(8 * * * *), with job’s backoffLimit defaulting to 6 and pod’s RestartPolicy to Never, the pods are deliberately configured to FAIL. As I understand, (for podSpec with restartPolicy : Never) Job controller will try to create backoffLimit number of pods and then it marks...
In short: You might not be seeing all created pods because period of schedule in the cronjob is too short. As described in documentation: Failed Pods associated with the Job are recreated by the Job controller with an exponential back-off delay (10s, 20s, 40s …) capped at six minutes. The back-off count is reset if no...
Kubernetes
54,825,671
55
How can I access environment variables in Vue, that are passed to the container at runtime and not during the build? Stack is as follows: VueCLI 3.0.5 Docker Kubernetes There are suggested solutions on stackoverflow and elsewhere to use .env file to pass variables (and using mode) but that's at build-time and gets ba...
Create a file config.js with your desired configuration. We will use that later to create a config map that we deploy to Kubernetes. Put it into your your Vue.js project where your other JavaScript files are. Although we will exclude it later from minification, it is useful to have it there so that IDE tooling works wi...
Kubernetes
53,010,064
55
I am trying to run Kubernetes and trying to use sudo kubeadm init. Swap is off as recommended by official doc. The issue is it displays the warning: [kubelet-check] It seems like the kubelet isn't running or healthy. [kubelet-check] The HTTP call equal to 'curl -sSL http://localhost:10248/healthz' failed with error: Ge...
I faced similar issue recently. The problem was cgroup driver. Kubernetes cgroup driver was set to systems but docker was set to systemd. So I created /etc/docker/daemon.json: vim /etc/docker/daemon.json and added below: { "exec-opts": ["native.cgroupdriver=systemd"] } Then sudo systemctl daemon-reload sudo systemc...
Kubernetes
52,119,985
55
I am looking for a way to rollback a helm release to its previous release without specifying the target release version as a number. Something like helm rollback <RELEASE> ~1 (like git reset HEAD~1) would be nice.
As it turns out, there is an undocumented option to rollback to the previous release by defining the target release version as 0. like: helm rollback <RELEASE> 0 Source: https://github.com/helm/helm/issues/1796
Kubernetes
51,894,307
55
From what I can tell in the documentation, a ReplicaSet is created when running a Deployment. It seems to support some of the same features of a ReplicationController - scale up/down and auto restart, but it's not clear if it supports rolling upgrades or autoscale. The v1.1.8 user guide shows how to create a deployment...
Replica Set is the next generation of Replication Controller. Replication controller is kinda imperative, but replica sets try to be as declarative as possible. 1.The main difference between a Replica Set and a Replication Controller right now is the selector support. +--------------------------------------------------...
Kubernetes
36,220,388
55
Below is the describe output for both my clusterissuer and certificate reource. I am brand new to cert-manager so not 100% sure this is set up properly - we need to use http01 validation however we are not using an nginx controller. Right now we only have 2 microservices so the public-facing IP address simply belongs t...
I had the same issue and I followed the advice given in the comments by @Popopame suggesting to check out the troubleshooting guide of cert-manager to find out how to troubleshoot cert-manager. or [cert-managers troubleshooting guide for acme issues] to find out which part of the acme process breaks the setup. It seems...
Kubernetes
63,346,728
54
I am running selenium hubs and my pods are getting terminated frequently. I would like to look at the logs of the pods which are terminated. How to do it? NAME READY STATUS RESTARTS AGE chrome-75-0-0e5d3b3d-3580-49d1-bc25-3296fdb52666 0/2 Terminat...
Running kubectl logs -p will fetch logs from existing resources at API level. This means that terminated pods' logs will be unavailable using this command. As mentioned in other answers, the best way is to have your logs centralized via logging agents or directly pushing these logs into an external service. Alternative...
Kubernetes
57,007,134
54
I am been struggling to get my simple 3 node Kubernetes cluster running. $ kubectl get nodes NAME STATUS ROLES AGE VERSION ubu1 Ready master 31d v1.13.4 ubu2 Ready master,node 31d v1.13.4 ubu3 Read...
kubectl edit pv (pv name) Find the following in the manifest file finalizers: - kubernetes.io/pv-protection ... and delete it. Then exit, and run this command to delete the pv kubectl delete pv (pv name) --grace-period=0 --force
Kubernetes
55,672,498
54
I've searched online and most links seem to mention manifests without actually explaining what they are. What are Manifests?
It's basically a Kubernetes "API object description". A config file can include one or more of these. (i.e. Deployment, ConfigMap, Secret, DaemonSet, etc) As per this: Specification of a Kubernetes API object in JSON or YAML format. A manifest specifies the desired state of an object that Kubernetes will maintain when...
Kubernetes
55,130,795
54
I'm trying to create a local Kubernetes deployment using Minikube, Docker Registry, and a demo node project. The first thing I did was install Docker v1.12.3, then Minikube v0.12.2. Then I created a Docker Registry container by running this command (via this tutorial, only running the first command below) docker run -d...
It looks like you're running the registry on the host. In fact, you need to run the registry inside the VM. You can point your docker client to the docker daemon inside the minikube VM by running this command first eval $(minikube docker-env) in your shell. Then, you can run the docker build command on your host, b...
Kubernetes
40,600,419
54
I'm trying to use minikube and kitematic for testing kubernetes on my local machine. However, kubernetes fail to pull image in my local repository (ImagePullBackOff). I tried to solve it with this : Can not pull docker image from private repo when using Minikube But I have no /etc/init.d/docker, I think it's because of...
Use the minikube docker registry instead of your local docker https://kubernetes.io/docs/tutorials/stateless-application/hello-minikube/#create-a-docker-container-image Set docker to point to minikube eval $(minikube docker-env) Push to minikube docker docker build -t hello-node:v1 . Set your deployment to not pull IfN...
Kubernetes
38,979,231
54
I'm looking for a pattern that allows to share volumes between two containers running on the same pod in Kubernetes. My use case is: I have a Ruby on Rails application running inside a docker container. The docker image contains static assets in /app/<app-name>/public directory, and I need to access those assets from t...
[update-2016-8] In latest Kubernetes release, you can use a very nice feature named init-container to replace the postStart part in my answer below, which will make sure the container order. apiVersion: v1 kind: Pod metadata: name: javaweb-2 spec: initContainers: - name: war image: resouer/sample:v2 comma...
Kubernetes
30,538,210
54
I need to monitor my container memory usage running on kubernetes cluster. After read some articles there're two recommendations: container_memory_rss, container_memory_working_set_bytes The definitions of both metrics are said (from the cAdvisor code) container_memory_rss : The amount of anonymous and swap cache mem...
You are right. I will try to address your questions in more detail. What is the difference between two metrics? container_memory_rss equals to the value of total_rss from /sys/fs/cgroups/memory/memory.status file: // The amount of anonymous and swap cache memory (includes transparent // hugepages). // Units: Bytes. R...
Kubernetes
65,428,558
53
I am trying to check the status of a pod using kubectl wait command through this documentation. Following is the command that i am trying kubectl wait --for=condition=complete --timeout=30s -n d1 job/test-job1-oo-9j9kj Following is the error that i am getting Kubectl error: status.conditions accessor error: Failure is...
To wait until your pod is running, check for "condition=ready". In addition, prefer to filter by label, rather than specifying pod id. For example: $ kubectl wait --for=condition=ready pod -l app=netshoot pod/netshoot-58785d5fc7-xt6fg condition met Another option is rollout status - To wait until the deployment is do...
Kubernetes
53,536,907
53
I understand that you can create a pod with Deployment/Job using kubectl run. But is it possible to create one with a volume attached to it? I tried running this command: kubectl run -i --rm --tty ubuntu --overrides='{ "apiVersion":"batch/v1", "spec": {"containers": {"image": "ubuntu:14.04", "volumeMounts": {"mountPa...
Your JSON override is specified incorrectly. Unfortunately kubectl run just ignores fields it doesn't understand. kubectl run -i --rm --tty ubuntu --overrides=' { "apiVersion": "batch/v1", "spec": { "template": { "spec": { "containers": [ { "name": "ubuntu", "imag...
Kubernetes
37,555,281
53
I've multiple secrets created from different files. I'd like to store all of them in common directory /var/secrets/. Unfortunately, I'm unable to do that because kubernetes throws 'Invalid value: "/var/secret": must be unique error during pod validation step. Below is an example of my pod definition. apiVersion: v1 ...
Projected Volume You can use a projected volume to have two secrets in the same directory Example apiVersion: v1 kind: Pod metadata: labels: run: alpine-secret name: alpine-secret spec: containers: - command: - sleep - "3600" image: alpine name: alpine-secret volumeMounts: - name: xy...
Kubernetes
59,079,318
52
I have kubernetes cluster and every thing work fine. after some times I drain my worker node and reset it and join it again to master but #kubectl get nodes NAME STATUS ROLES AGE VERSION ubuntu Ready master 159m v1.14.0 ubuntu1 Ready,SchedulingDisabled <non...
To prevent a node from scheduling new pods use: kubectl cordon <node-name> Which will cause the node to be in the status: Ready,SchedulingDisabled. To tell is to resume scheduling use: kubectl uncordon <node-name> More information about draining a node can be found here. And manual node administration here
Kubernetes
55,432,764
52
Most tutorials I've seen for developing with Kubernetes locally use Minikube. In the latest Edge release of Docker for Windows, you can also enable Kubernetes. I'm trying to understand the differences between the two and which I should use. Minikube lets you choose the version of Kubernetes you want, can Docker for Wi...
I feel like you largely understand the space, and mostly have answers to your questions already. You might find Docker for Mac vs. Docker Toolbox an informative read, even if it's about the Mac equivalent rather than Windows and about Docker packaged as a VM rather than Kubernetes specifically. In fact you are stuck ...
Kubernetes
51,209,870
52
By default docker uses a shm size of 64m if not specified, but that can be increased in docker using --shm-size=256m How should I increase shm size of a kuberenetes container or use --shm-size of docker in kuberenetes.
I originally bumped into this post coming from google and went through the whole kubernetes issue and openshift workaround. Only to find the much simpler solution listed on another stackoverflow answer later.
Kubernetes
43,373,463
52
I am becoming more familiar with Kubernetes by the day, but am still at a basic level. I am also not a networking guy. I am staring at the following snippet of a Service definition, and I can't form the right picture in my mind of what is being declared: spec: type: NodePort ports: - port: 27018 targetPort: ...
nodePort is the port that a client outside of the cluster will "see". nodePort is opened on every node in your cluster via kube-proxy. With iptables magic Kubernetes (k8s) then routes traffic from that port to a matching service pod (even if that pod is running on a completely different node). port is the port your ser...
Kubernetes
41,963,433
52
In kubernetes I can expose services with service. This is fine. Lets say I have 1 web instance and 10 java server instances. I have a windows gateway I'm used to access those 10 java servers instances via the jconsole installed on it. Obviously I do not expose all apps jmx port via kubernetes service. What are my op...
Another option is to forward JMX port from K8 pod to your local PC with kubectl port-forward. I do it like this: 1). Add following JVM options to your app: -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.local.only...
Kubernetes
35,184,558
52
How does Kubernetes' scheduler work? What I mean is that Kubernetes' scheduler appears to be very simple? My initial thought is that this scheduler is just a simple admission control system, not a real scheduler. Is it that correct? I found a short description, but it is not terribly informative: The kubernetes schedu...
The paragraph you quoted describes where we hope to be in the future (where the future is defined in units of months, not years). We're not there yet, but the scheduler does have a number of useful features already, enough for a simple deployment. In the rest of this reply, I'll explain how the scheduler works today. T...
Kubernetes
28,857,993
52
I have added mysql in requirements.yaml. Helm dependency downloads the mysql chart helm dependency update Hang tight while we grab the latest from your chart repositories... ...Successfully got an update from the "nginx" chart repository ...Successfully got an update from the "stable" chart repository Update Complete....
You don't have to add it to the control version system, you just download them again if for some reason you have lost them (for example when you clone the repository). To do this, execute the command: helm dependency update The above command will download the dependencies you've defined in the requirements.yaml file or...
Kubernetes
59,210,148
51
I want to use the postgresql chart as a requirements for my Helm chart. My requirements.yaml file hence looks like this: dependencies: - name: "postgresql" version: "3.10.0" repository: "@stable" In the postgreSQL Helm chart I now want to set the username with the property postgresqlUsername (see https://git...
As described in https://v2.helm.sh/docs/chart_template_guide/#subcharts-and-global-values, in your parent (i.e. not the dependency) chart's values.yaml file, have a section that contains postgresql: postgresUsername: .... postgresPassword: .... ... That is, all values under the postgresql key will override the c...
Kubernetes
55,748,639
51
What is the best way to wait for kubernetes job to be complete? I noticed a lot of suggestions to use: kubectl wait --for=condition=complete job/myjob but i think that only works if the job is successful. if it fails, i have to do something like: kubectl wait --for=condition=failed job/myjob is there a way to wait f...
Run the first wait condition as a subprocess and capture its PID. If the condition is met, this process will exit with an exit code of 0. kubectl wait --for=condition=complete job/myjob & completion_pid=$! Do the same for the failure wait condition. The trick here is to add && exit 1 so that the subprocess returns a n...
Kubernetes
55,073,453
51
There is a default ClusterRoleBinding named cluster-admin. When I run kubectl get clusterrolebindings cluster-admin -o yaml I get: apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRoleBinding metadata: annotations: rbac.authorization.kubernetes.io/autoupdate: "true" creationTimestamp: 2018-06-13T12:19:26...
Answer updated: It seems that there is no way to do it using kubectl. There is no object like Group that you can "get" inside the Kubernetes configuration. Group information in Kubernetes is currently provided by the Authenticator modules and usually it's just string in the user property. Perhaps you can get the list...
Kubernetes
51,612,976
51
I have a test executor Pod in K8s cluster created through helm, which asks for a dynamically created PersistentVolume where it stores the test results. Now I would like to get the contents of this volume. It seems quite natural thing to do. I would expect some kubectl download pv <id>. But I can't google up anything. H...
I can think about two options to fulfill your needs: Create a pod with the PV attached to it and use kubectl cp to copy the contents wherever you need. You could for example use a PodSpec similar to the following: apiVersion: v1 kind: Pod metadata: name: dataaccess spec: containers: - name: alpine image: al...
Kubernetes
50,375,826
51
In Kubernetes, it is possible to make a service running in cluster externally accessible by running kubectl expose deployment. Why deployment as opposed to service is beyond my simpleton's comprehension. That aside, I would like to also be able to undo this operation afterwards. Think of a scenario, where I need to ...
Assuming you have a deployment called hello-world, and do a kubectl expose as follows: kubectl expose deployment hello-world --type=ClusterIP --name=my-service this will create a service called my-service, which makes your deployment accessible for debugging, as you described. To display information about the Service: ...
Kubernetes
48,639,273
51
I have a kubernetes cluster on Azure and I created 2 namespaces and 2 service accounts because I have two teams deploying on the cluster. I want to give each team their own kubeconfig file for the serviceaccount I created. I am pretty new to Kubernetes and haven't been able to find a clear instruction on the kubernete...
# your server name goes here server=https://localhost:8443 # the name of the secret containing the service account token goes here name=default-token-sg96k ca=$(kubectl get secret/$name -o jsonpath='{.data.ca\.crt}') token=$(kubectl get secret/$name -o jsonpath='{.data.token}' | base64 --decode) namespace=$(kubectl ge...
Kubernetes
47,770,676
51
In several places on the Kubernetes documentation site they recommend that you store your configuration YAML files inside source control for easy version-tracking, rollback, and deployment. My colleagues and I are currently in the process of trying to decide on the structure of our git repository. We have decided th...
There is no established standard yet, I believe. I find helm's charts too complicated to start with, especially having another unmanaged component running on the k8s cluster. This is a workflow that we follow that works quite well for a setup of 15ish microservices, and 5 different environments (devx2, staging, qa, pro...
Kubernetes
47,168,381
51
Use case: I have a NFS directory available and I want to use it to persist data for multiple deployments & pods. I have created a PersistentVolume: apiVersion: v1 kind: PersistentVolume metadata: name: nfs-pv spec: capacity: storage: 10Gi accessModes: - ReadWriteMany nfs: server: http://mynfs.com ...
Basically you can't do what you want, as the relationship PVC <--> PV is one-on-one. If NFS is the only storage you have available and would like multiple PV/PVC on one nfs export, use Dynamic Provisioning and a default storage class. It's not in official K8s yet, but this one is in the incubator and I've tried it an...
Kubernetes
44,204,223
51
I have a problem with Kubernetes that run in a CentOS virtual machine in CloudStack. My pods remain in pending state. I got the following error message when I print the log for a pod: [root@kubernetes-master ~]# kubectl logs wildfly-rc-6a0fr Error from server: Internal error occurred: Pod "wildfly-rc-6a0fr" in ...
Run below command to get the events. This will show the issue ( and all other events) why pod has not be scheduled. kubectl get events
Kubernetes
36,377,784
51
I have just started with Kubernetes and I am confused about the difference between NodePort and LoadBalancer type of service. The difference I understand is that LoadBalancer does not support UDP but apart from that whenever we create a service either Nodeport or Loadbalancer we get a service IP and port, a NodePort, a...
Nothing prevents you from placing an external load balancer in front of your nodes and use the NodePort option. The LoadBalancer option is only used to additionally ask your cloud provider for a new software LB instance, automatically in the background. I'm not up to date which cloud providers are supported yet, but i ...
Kubernetes
34,443,138
51
I have a Kubernetes cluster running on Google Compute Engine and I would like to assign static IP addresses to my external services (type: LoadBalancer). I am unsure about whether this is possible at the moment or not. I found the following sources on that topic: Kubernetes Service Documentation lets you define an ext...
TL;DR Google Container Engine running Kubernetes v1.1 supports loadBalancerIP just mark the auto-assigned IP as static first. Kubernetes v1.1 supports externalIPs: apiVersion: v1 kind: Service spec: type: LoadBalancer loadBalancerIP: 10.10.10.10 ... So far there isn't a really good consistent documentation on ho...
Kubernetes
32,266,053
51
I’m a mobile developer and recently adept at using containers with docker. I’m developing a container architecture for my graduate project. One of the modules of this architecture would need to be run on an android device. But I could not find information on how to run a container on an android device. It could be some...
In 2021, the answer is definitely yes. Here is a tutorial on that topic, which shows you how to run docker directly on Android, without VMs nor chroot. Note that you do need to root your phone and build a custom kernel though. If you only want a quick look of docker running on android without getting your hands dirty, ...
Kubernetes
53,527,277
50
Is there a way to use kubectl to list only the pods belonging to a deployment? Currently, I do this to get pods: kubectl get pods| grep hello But it seems an overkill to get ALL the pods when I am interested to know only the pods for a given deployment. I use the output of this command to see the status of all pods, an...
There's a label in the pod for the selector in the deployment. That's how a deployment manages its pods. For example for the label or selector app=http-svc you can do something like that this and avoid using grep and listing all the pods (this becomes useful as your number of pods becomes very large) here are some exam...
Kubernetes
52,957,227
50
I create a deployment which results in 4 pods existing across 2 nodes. I then expose these pods via a service which results in the following cluster IP and pod endpoints: Name: s-flask ...... IP: 10.110.201.8 Port: <unset> 9080/TCP TargetPort: ...
Everything you need is explained in second paragraph "Virtual IPs and service proxies" of this documentation: https://kubernetes.io/docs/concepts/services-networking/service/#defining-a-service In nutshell: currently, depending on the proxy mode, for ClusterIP it's just round robin/random. It's done by kube-proxy, whic...
Kubernetes
49,888,133
50
Our Kubernetes 1.6 cluster had certificates generated when the cluster was built on April 13th, 2017. On December 13th, 2017, our cluster was upgraded to version 1.8, and new certificates were generated [apparently, an incomplete set of certificates]. On April 13th, 2018, we started seeing this message within our Kuber...
I think you need re-generate the apiserver certificate /etc/kubernetes/pki/apiserver.crt you can view current expire date like this. openssl x509 -in /etc/kubernetes/pki/apiserver.crt -noout -text |grep ' Not ' Not Before: Dec 20 14:32:00 2017 GMT Not After : Dec 20 14:32:00 2018 GMT Here is th...
Kubernetes
49,885,636
50
Forbidden!Configured service account doesn't have access. Service account may have been revoked. User "system:serviceaccount:default:default" cannot get services in the namespace "mycomp-services-process" For the above issue I have created "mycomp-service-process" namespace and checked the issue. But it shows again mes...
Creating a namespace won't, of course, solve the issue, as that is not the problem at all. In the first error the issue is that serviceaccount default in default namespace can not get services because it does not have access to list/get services. So what you need to do is assign a role to that user using clusterrolebin...
Kubernetes
47,973,570
50
I am setting up Github Actions for a project repository. The workflow consists of the following steps: Building a docker image Pushing the image to a container registry Rollout a Kubernetes deployment. However, I have two different Kubernetes deployments: one for development, and one for production. Hence, I have...
Is there a way to trigger a workflow manually in Github Actions? You might consider, from July2020: GitHub Actions: Manual triggers with workflow_dispatch (Note: or multiple workflows, through the new Composite Run Steps, August 2020) You can now create workflows that are manually triggered with the new workflow_d...
Kubernetes
58,933,155
49
Is there a different way than kubectl edit to delete an annotation in Kubernetes? I do not like the interactivity of kubectl edit. I prefer something usable in a script.
Use minus - sign at the end of the annotation in kubectl annotate. Example: kubectl annotate service shopping-cart prometheus.io/scrape- Removes annotation prometheus.io/scrape from shopping-cart service.
Kubernetes
54,973,593
49
I've a Deployment object where I expose the POD ID using the Downward API. That works fine. However, I want to set up another env variable, log path, with reference to the POD ID. But, setting that variable value to /var/log/mycompany/${POD_ID}/logs isn't working, no logs are created in the container. I can make the en...
The correct syntax is to use $(FOO), as is described in the the documentation; the syntax you have used is "shell" syntax, which isn't the way kubernetes interpolates variables. So: containers: - env: - name: POD_ID valueFrom: # etc etc - name: LOG_PATH value: /var/log/mycompany/$(POD_ID)/logs Also please ...
Kubernetes
49,582,349
49
I have a pod that responds to requests to /api/ I want to do a rewrite where requests to /auth/api/ go to /api/. Using an Ingress (nginx), I thought that with the ingress.kubernetes.io/rewrite-target: annotation I could do it something like this: apiVersion: extensions/v1beta1 kind: Ingress metadata: name: myapi-ing ...
I don't know if this is still an issue, but since version 0.22 it seems you need to use capture groups to pass values to the rewrite-target value From the nginx example available here Starting in Version 0.22.0, ingress definitions using the annotation nginx.ingress.kubernetes.io/rewrite-target are not backwards compa...
Kubernetes
47,837,087
49
I have a service exposed of type=LoadBalancer and when I do a kubectl describe services servicename, I get this output : Name: ser1 Namespace: default Labels: app=online1 Selector: app=online1 Type: LoadBalancer IP: 10.0.0.32 External IPs: 192.168.99.100 Port: ...
Port unset means: You didn't specify a name in service creation. Service Yaml excerpt (note name: grpc): spec: ports: - port: 26257 targetPort: 26257 name: grpc type: NodePort kubectl describe services servicename output excerpt: Type: NodePort IP: 10.101.87.248 Port...
Kubernetes
42,528,409
49
I confused between Multi-Container Pod Design patterns. (sidecar, adapter, ambassador) What I understand is : Sidecar : container + container(share same resource and do other functions) Adapter : container + adapter(for checking other container's status. e.g. monitoring) Ambassador : container + proxy(to networking o...
First, you are right, the term sidecar container has now became a word for describing an extra container in your pod. Originally(?) it was a specific multi-container design pattern. Multi-container design patterns Sidecar pattern An extra container in your pod to enhance or extend the functionality of the main containe...
Kubernetes
59,451,056
48
Is it possible to generate yaml with kubernetes kubectl command ? to clarify - I'm not talking about generating yaml from existing deployments like kubectl get XXXX -o yaml, but merely about generating yamls for the very first time for pod, service, ingress, etc. PS There is a way to get yaml files from kubernetes.io ...
There's the command create in kubectl that does the trick and replaced the run used in the past: let's image you want to create a Deployment running a nginx:latest Docker image. # kubectl create deployment my_deployment --image=busybox --dry-run=client --output=yaml apiVersion: apps/v1 kind: Deployment metadata: cre...
Kubernetes
57,696,087
48
I've recently learned about kubectl --field-selector flag, but ran into errors when trying to use it with various objects. For example : $ 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 ...
The issue in your case is that you mistakenly use status.succeeded instead of status.successful, so right command is kubectl delete jobs.batch --field-selector status.successful==1 No resources found Regarding your question about all the fields: my suggestion is to deep into the code and search for proper resources ty...
Kubernetes
55,762,084
48
I want to upgrade the kubectl client version to 1.11.3. I executed brew install kubernetes-cli but the version doesnt seem to be updating. Client Version: version.Info{Major:"1", Minor:"10", GitVersion:"v1.10.7", GitCommit:"0c38c362511b20a098d7cd855f1314dad92c2780", GitTreeState:"clean", BuildDate:"2018-08-20T10:09:03...
Install specific version of kubectl curl -LO https://storage.googleapis.com/kubernetes-release/release/<specific-kubectl-version>/bin/darwin/amd64/kubectl For your case if you want to install version v1.11.3 then replace specific-kubectl-version with v1.11.3 Then make this binary executable chmod +x ./kubectl Then mo...
Kubernetes
53,701,151
48
I'm not sure what the difference is between the CNI plugin and the Kube-proxy in Kubernetes. From what I get out of the documentation I conclude the following: Kube-proxy is responsible for communicating with the master node and routing. CNI provides connectivity by assigning IP addresses to pods and services, and reac...
OVERLAY NETWORK Kubernetes assumes that every pod has an IP address and that you can communicate with services inside that pod by using that IP address. When I say “overlay network” this is what I mean (“the system that lets you refer to a pod by its IP address”). All other Kubernetes networking stuff relies on the ove...
Kubernetes
53,534,553
48
I'm just getting started with kubernetes and setting up a cluster on AWS using kops. In many of the examples I read (and try), there will be commands like: kubectl run my-app --image=mycompany/myapp:latest --replicas=1 --port=8080 kubectl expose deployment my=app --port=80 --type=LoadBalancer This seems to do severa...
The fundamental question is how to apply all of the K8s objects into the k8s cluster. There are several ways to do this job. Using Generators (Run, Expose) Using Imperative way (Create) Using Declarative way (Apply) All of the above ways have a different purpose and simplicity. For instance, If you want to check qui...
Kubernetes
48,015,637
48
How do I get a pod's name from its IP address? What's the magic incantation of kubectl + sed/awk/grep/etc regardless of where kubectl is invoked?
Example: kubectl get pods -o wide NAME READY STATUS RESTARTS AGE IP NODE alpine-3835730047-ggn2v 1/1 Running 0 5d 10.22.19.69 ip-10-35-80-221.ec2.internal get pod name by IP kubectl get --all-namespaces --output json pods |...
Kubernetes
41,563,021
48
in a kubernetes Deployment yaml file is there a simple way to run multiple commands in the postStart hook of a container? I'm trying to do something like this: lifecycle: postStart: exec: command: ["/bin/cp", "/webapps/myapp.war", "/apps/"] command: ["/bin/mkdir", "-p", "/conf/myapp"] command: [...
Only one command allowed, but you can use sh -c like this lifecycle: postStart: exec: command: - "sh" - "-c" - > if [ -s /var/www/mybb/inc/config.php ]; then rm -rf /var/www/mybb/install; fi; if [ ! -f /var/www/mybb/index....
Kubernetes
39,436,845
48
I have known clearly about the usage of the docker option --net=container:NAME_or_ID, I also have read the source code of kubernetes about how to configure the container to use the network of InfraContainer, so I think the only work the process in container gcr.io/google_containers/pause:0.8.0 does is "pause", it will ...
In Kubernetes, each pod has an IP and within a pod there exists a so called infrastructure container, which is the first container that the Kubelet instantiates and it acquires the pod’s IP and sets up the network namespace. All the other containers in the pod then join the infra container’s network and IPC namespace. ...
Kubernetes
33,472,741
48
I have built a 4 node kubernetes cluster running multi-container pods all running on CoreOS. The images come from public and private repositories. Right now I have to log into each node and manually pull down the images each time I update them. I would like be able to pull them automatically. I have tried running doc...
To add to what @rob said, as of docker 1.7, the use of .dockercfg has been deprecated and they now use a ~/.docker/config.json file. There is support for this type of secret in kube 1.1, but you must create it using different keys/type configuration in the yaml: First, base64 encode your ~/.docker/config.json: cat ~/....
Kubernetes
32,726,923
48
Based on the docs that I've read, there are 3 methods of patching: patches patchesStrategicMerge patchesJson6902. The difference between patchesStrategicMerge and patchesJson6902 is obvious. patchesStrategicMerge requires a duplicate structure of the kubernetes resource to identify the base resource that is being pat...
The explanation for this is here. To summarize, patchJson6902 is an older keyword which can only match one resource via target (no wildcards), and accepts only Group-version-kind (GVK), namespace, and name. The patches directive is newer and accepts more elements (annotation selector and label selector as well). In add...
Kubernetes
63,604,579
47
What's the best way to list out the environment variables in a kubernetes pod? (Similar to this, but for Kube, not Docker.)
kubectl exec -it <pod_name> -- env
Kubernetes
59,198,188
47
I am new to DevOps. I wrote a deployment.yaml file for a Kubernetes cluster I just created on Digital Oceans. Creating the deployment keeps bringing up errors that I can't decode for now. This is just a test deployment in preparation for the migration of my company's web apps to kubernetes. I tried editing the content...
Since this is the top result of the search, I thought I should add another case when this can occur. In my case, it was coming because there was no double quote on numeric env. var. Log did provide a subtle hint, but it was not very helpful. Log ..., bigger context ...|c-server-service"},{"name":"SERVER_PORT","value":8...
Kubernetes
57,233,686
47
How do I force delete Namespaces stuck in Terminating? Steps to recreate: Apply this YAML apiVersion: v1 kind: Namespace metadata: name: delete-me spec: finalizers: - foregroundDeletion kubectl delete ns delete-me It is not possible to delete delete-me. The only workaround I've found is to destroy and recr...
The kubectl proxy try is almost correct, but not quite. It's possible using JSON instead of YAML does the trick, but I'm not certain. The JSON with an empty finalizers list: ~$ cat ns.json { "kind": "Namespace", "apiVersion": "v1", "metadata": { "name": "delete-me" }, "spec": { "finalizers": [] } }...
Kubernetes
55,853,312
47
I have couple of namespaces - assume NS1 and NS2. I have serviceaccounts created in those - sa1 in NS1 and sa2 in NS2. I have created roles and rolebindings for sa1 to do stuff within NS1 and sa2 within NS2. What I want is give sa1 certain access within NS2 (say only Pod Reader role). I am wondering if that's possible ...
You can simply reference a ServiceAccount from another namespace in the RoleBinding: apiVersion: rbac.authorization.k8s.io/v1beta1 kind: Role metadata: name: pod-reader namespace: ns2 rules: - apiGroups: [""] resources: ["pods"] verbs: ["get", "list", "watch"] --- apiVersion: rbac.authorization.k8s.io/v1 kind: ...
Kubernetes
53,960,516
47
In Kubernetes cronjobs, It is stated in the limitations section that Jobs may fail to run if the CronJob controller is not running or broken for a span of time from before the start time of the CronJob to start time plus startingDeadlineSeconds, or if the span covers multiple start times and concurrencyPolicy does no...
After investigating the code base of the Kubernetes repo, so this is how the CronJob controller works: The CronJob controller will check the every 10 seconds the list of cronjobs in the given Kubernetes Client. For every CronJob, it checks how many schedules it missed in the duration from the lastScheduleTime till no...
Kubernetes
51,065,538
47
When processing a rolling update with database migrations, how does kubernetes handle this? For an instance - I have an app that gets updated from app-v1 to app-v2, which includes a migration step to alter an existing table. So this would mean it requires me to run something like db:migrate for a rails app once deploy...
One way to prevent an old version from breaking is to split a migration into multiple steps. E.g. you want to rename a column in the database. Renaming the column directly would break old versions of the app. This can be split into multiple steps: Add a db migration that inserts the new column Change the app so that ...
Kubernetes
48,877,182
47
How do you find the cluster/service CIDR for a Kubernetes cluster, once it is already running? I know for Minikube, it is 10.0.0.1/24. For GKE, you can find out via gcloud container clusters describe XXXXXXX --zone=XXXXXX | grep -e clusterIpv4Cidr -e servicesIpv4Cidr But how do you find out on a generic Kubernetes c...
I spent hours searching for a generic way to do this. I gave up searching and wrote my own. As of Kubernetes 1.18, this method works across cloud providers, beyond just GKE. SVCRANGE=$(echo '{"apiVersion":"v1","kind":"Service","metadata":{"name":"tst"},"spec":{"clusterIP":"1.1.1.1","ports":[{"port":443}]}}' | kubectl a...
Kubernetes
44,190,607
47
I'm writing a shell script which needs to login into the pod and execute a series of commands in a kubernetes pod. Below is my sample_script.sh: kubectl exec octavia-api-worker-pod-test -c octavia-api bash unset http_proxy https_proxy mv /usr/local/etc/octavia/octavia.conf /usr/local/etc/octavia/octavia.conf-orig /usr/...
Are you running all these commands as a single line command? First of all, there's no ; or && between those commands. So if you paste it as a multi-line script to your terminal, likely it will get executed locally. Second, to tell bash to execute something, you need: bash -c "command". Try running this: $ kubectl exec ...
Kubernetes
43,499,313
47
I've created the persistent volume (EBS 10G) and corresponding persistent volume claim first. But when I try to deploy the postgresql pods as below (yaml file) : Receive the errors from pod: initdb: directory "/var/lib/postgresql/data" exists but is not empty It contains a lost+found directory, perhaps due to it bei...
So what's the way to correctly mount a postgresql volume using Aws EBS You are on a right path... Error you get is because you want to use root folder of mounted volume / as postgresql Data dir and postgresql complains that it is not best practice to do so since it is not empty and contains already some data inside (...
Kubernetes
51,168,558
46
I install the latest version of Kubernetes with the following command on Raspberry PI 3 running Raspbian Stretch. $ curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add - && \ echo "deb http://apt.kubernetes.io/ kubernetes-xenial main" | sudo tee /etc/apt/sources.list.d/kubernetes.list && ...
To install specific version of the package it is enough to define it during the apt-get install command: apt-get install -qy kubeadm=<version> But in the current case kubectl and kubelet packages are installed by dependencies when we install kubeadm, so all these three packages should be installed with a specific vers...
Kubernetes
49,721,708
46
I am trying reach my k8s master from my workstation. I can access the master from the LAN fine but not from my workstation. The error message is: % kubectl --context=employee-context get pods Unable to connect to the server: x509: certificate is valid for 10.96.0.1, 10.161.233.80, not 114.215.201.87 How can I do to ad...
One option is to tell kubectl that you don't want the certificate to be validated. Obviously this brings up security issues but I guess you are only testing so here you go: kubectl --insecure-skip-tls-verify --context=employee-context get pods The better option is to fix the certificate. Easiest if you reinitialize th...
Kubernetes
46,360,361
46
I have a running pod and I want to change one of it's container's environment variable and made it work immediately. Can I achieve that? If I can, how to do that?
Simply put and in kube terms, you can not. Environment for linux process is established on process startup, and there are certainly no kube tools that can achieve such goal. For example, if you make a change to your Deployment (I assume you use it to create pods) it will roll the underlying pods. Now, that said, there ...
Kubernetes
45,050,050
46
Can one store a binary file in a Kubernetes ConfigMap and then later read the same content from a volume that mounts this ConfigMap? For example, if directory /etc/mycompany/myapp/config contains binary file keystore.jks, will kubectl create configmap myapp-config --from-file=/etc/mycompany/myapp/config include file ...
Binary ConfigMaps are now supported since Kubernetes version 1.10.0. From the readme notes: ConfigMap objects now support binary data via a new binaryData field. When using kubectl create configmap --from-file, files containing non-UTF8 data will be placed in this new field in order to preserve the non-UTF8 data. Note...
Kubernetes
39,420,102
46
I have tried to run Helm for the first time. I am having deployment.yaml, service.yaml and ingress.yaml files alongwith values.yaml and chart.yaml. deployment.yaml apiVersion: apps/v1 kind: Deployment metadata: name: abc namespace: xyz labels: app: abc app.kubernetes.io/managed-by: {{ .Release.Service }} ...
The error below is quiet common: label validation error: missing key "app.kubernetes.io/managed-by": must be set to "Helm"; annotation validation error: missing key "meta.helm.sh/release-name": must be set to .. So I'll provide a bit longer explanation and also a context to the topic. What happend? It seems that y...
Kubernetes
62,964,532
45
I need to loop through a list of instances and create 1 stateful set for every instance. However, inside range I then limit myself to the scope of that loop. I need to access some global values in my statefulset. I've solved it by just putting all global objects I need in an env variable but... this very seems hacky. W...
When entering a loop block you lose your global context when using .. You can access the global context by using $. instead. As written in the Helm docs - there is one variable that is always global - $ - this variable will always point to the root context. This can be very useful when you are looping in a range and n...
Kubernetes
55,213,545
45
At present I am creating a configmap from the file config.json by executing: kubectl create configmap jksconfig --from-file=config.json I would want the ConfigMap to be created as part of the deployment and tried to do this: apiVersion: v1 kind: ConfigMap metadata: name: jksconfig data: config.json: |- {{ .Fil...
Your config.json file should be inside your mychart/ directory, not inside mychart/templates Chart Template Guide configmap.yaml apiVersion: v1 kind: ConfigMap metadata: name: {{ .Release.Name }}-configmap data: config.json: |- {{ .Files.Get "config.json" | indent 4}} config.json { "val": "key" } helm instal...
Kubernetes
53,429,486
45
I am using kubectl with bash completion , but I prefer to use a shorter alias for kubectl such as ks , what changes I need to make to get the bash completion work with alias ks
from the official docs # after installing bash completion alias k=kubectl complete -F __start_kubectl k https://kubernetes.io/docs/reference/kubectl/cheatsheet/#bash
Kubernetes
52,905,811
45
When I try any kubectl command, it always returns: Unable to connect to the server: EOF I followed these tutorials: https://kubernetes.io/docs/tasks/tools/install-kubectl/ https://kubernetes.io/docs/tasks/access-application-cluster/configure-access-multiple-clusters/ But they have not helped me. According to the fir...
After Minikube is started, kubectl is configured automatically. minikube start Starting local Kubernetes cluster... Kubernetes is available at https://192.168.99.100:8443. Kubectl is now configured to use the cluster. You can verify and validate the cluster and context with following commands. kubectl config view
Kubernetes
48,928,330
45
I'm using kubectl cp to copy a jar file from my local file system into a the home directory of a POD in my minikube environment. However, the only way I can confirm that the copy succeeded is to issue a new kubectl cp command to copy the file back to a temp directory and compare the checksums. Is there a way to view th...
You can execute commands in a container using kubectl exec command. For example: to check files in any folder: kubectl exec <pod_name> -- ls -la / or to calculate md5sum of any file: kubectl exec <pod_name> -- md5sum /some_file
Kubernetes
48,084,476
45
Say I have, my-namespace -> my-pod -> my-container and I have a file located at my-container:/opt/tomcat/logs/catalina.2017-05-02.log. I have applied the below command to copy the file which isn't working, kubectl cp my-namepace/my-pod:/opt/tomcat/logs/catalina.2017-05-02.log -c my-container . Note: I have the tar bin...
What you are asking kubectl to do is copy the file catalina.2017-05-02.log to the current context, but the current context is a directory. The error is stating that you can not copy a file to have the name of a directory. Try giving the copied version of the file a name: kubectl cp my-namepace/my-pod:/opt/tomcat/logs/c...
Kubernetes
43,732,342
45