How to step-into kubernetes source code using IDE? - kubernetes

Is it possible to run kubectl commands and see the run-time execution using an IDE like GoLand for example?
I would like to open 'apply.go' source code and see how the code is executed when I type: kubectl apply -f/hit Enter step-by-step.

Go does offer a debugger, Delve. But I don’t think this will be very helpful. Kubectl code is kind of hard to understand even if you already know it and kubectl apply is the single most complex thing in all of kubectl. So complex that the logic is being moved to the server side, in newer versions.

Lens is the best IDE for kubernetes that I have used upto now.
It serves everything in a plate , as there is no need to mug up the commands of kubectl,
you can make changes in any of kubernetes yaml file from lens and it will apply changes in to your cluster.
install lens for your OS: https://github.com/lensapp/lens/releases/
you can know more about lens from this link : https://github.com/lensapp/lens/

Related

Skaffold and mutiple Sub Charts

lately I was experimenting with Skaffold with our Helm Charts and I am in little bit in a dilemma that our Helm Chart \ Sub Charts are compatible with Skaffold or not.
Our helm Charts are looking like the following
my-helm-charts
+-charts
+-project1
+-project2
+-project3
+-project4
+-infrastructure_kafka
+-charts
+-kafka
+-zookeeper
+-infrastructure_cassandra
+-infrastructure_elasticsearch
+-Charts.yaml
+-Values.yaml
The reason we choosed to structure the Helm Charts this way, is that if necessary to spin up extra stages for our project.
Now when I want to develop project2 with Google Cloud Code / Skaffold (which I configured correctly and I can start without problem in IntelliJ) I have to start whole my-helm-charts.
That is actually Ok but the problem is, if I use Debug in Kubernetes, I have a feeling Google Cloud Code/Skaffold can really locate the project2 and no debugging occurs.
My feeling is Google Cloud/Skaffold is more oriented to work with following contruct...
project2-helm
+-templates
+-Charts.yaml
+-Values.yaml
My Subcharts contructs starts in Google Cloud Code/Skaffold without any exception but I can't debug, is it possible to achieve want I want with my structure and if yes, how?
Or is it not possible at all...
Thx for answers...
We recently added a feature called config dependencies which might help here. It allows you to create more specific skaffold.yamls and then map them together with a "requires" field:
https://skaffold.dev/docs/design/config/#configuration-dependencies
Once you have the skaffold.yamls created and the right dependency mapping you can run skaffold with the -m flag to choose once slice of your services:
skaffold dev -m project3
Cloud Code support for modules is incoming.
Cloud Code IntelliJ and Cloud Code VS Code recently added preview level support for deploying and debugging modules of a larger application which uses Skaffold. See more here https://cloud.google.com/code/docs/intellij/skaffold-modules

How to synchronize Custom resource when its specification is updated

In a Kubernetes operator based on operator-sdk, do you know how to write code to synchronize CR resource when CR specification is updated with kubectl apply? Could you please provide some code samples?
It is mostly up to how you deploy things. The default skeleton gives you a Kustomize-based deployment structure so kustomize build config/default | kubectl apply -f. This is also wrapped up for you behind make deploy. There is also make install for just installing the generated CRD files.
Implementing it a go-lang based operator is pretty complex, and I would recommand studying the kubebuilder documentation and example in order to achieve that: https://book.kubebuilder.io/cronjob-tutorial/controller-implementation.html#implementing-a-controller

Development lifecycle for fast starting pods (with dependency on slow starting pods)

I have an app with several pods. The foundational pod takes about 2 minutes to start fully but I basically never need to change it. I'm working on other pods and they start in few seconds if the foundational pod is already running. I'm trying to optimize my development lifecycle when I change the code in fast-starting pod and debugging it.
The "Run on Kubernetes" would be great as it watched the changes and re-deploys that fast-starting pod only. However, I can't debug it.
"Debug on Kubernetes" is what I would like to use but it doesn't watch the changes and re-deploy automatically and stopping and starting the whole app (all pods) is pain because it takes 2-3 minutes (due to slow starting but never changing pods).
I was thinking of have "Run on Kubernetes" and then use Attach to debug individual pods but it would require pre-configuring the pods/containers for debug in Dockerfile. I assume if I do that, I could detach debugger and let it re-deploy watching changes and re-attach again.
I was playing with multiple skaffold yaml files - one that includes foundation only (slow starting pod) and another one just for fast-starting pod where I need to do changes but then I have to disable clean up so it's manual pod stopping for me. Also, it seems to keep stopping/starting minikube when I stop/start "Debug on Kubernetes".
I wish I could just use "Debug on Kubernetes" that watches changes and re-deploys. But watch is not supported for Debug runs.
Am I missing anything? Any good ideas?
#Alex - thanks for filing the issue. Will followup further discussion on it. Glad to hear you like using cloud shell we provide same experience there that is available in VSCode. Regarding minikube stop it is intended behavior for local debugging but we can discuss more on the ticket. Sorry it doesn't let me comment inline for now.

Does anyone have tried the HLF 2.0 feature "External Builders and Launchers" and wants to get in touch?

I'm getting my way through the HLF 2.0 docs and would love to discuss and try out the new features "External Builders and Launchers" and "Chaincode as an external service".
My goal is to run HLF2.0 on an K8s cluster (OpenShift). Does anyone wants to get in touch or has anyone already figured his way through?
Cheers from Germany
Also trying to use the ExternalBuilder. Setup core.yaml, rebuilt the containers to use it. I get an error that on "peer lifecycle chaincode install .tgz...", that the path to the scripts in core.yaml can not be found.
I've added volume bind commands in the peer-base.yaml, and in docker-compose-cli.yaml, and am using the first-network setup. Dropped out the part of the byfn.sh that would connect to the cli container, so that I do that part manually, do the create, join, update anchors successfully, and then try to do the install and fail. However, on the install, I'm failing on the /bin/detect, because it can't find that file to fork/exec it. To get that far, peer was able to read my external configuration, and read the core.yaml file. At the moment, trying the "mode: dev" in the core.yaml which seems to indicate that the scripts and the chaincode will be run "locally", which I think means it should run in the cli container. Otherwise, tried to walk the code to see how the docker containers are being created dynamically, and from what image, but haven't been able to nail that down yet.

Is there a way to validate CloudFormation templates before running them?

I would like to validate my CloudFormation templates before running them. I know about the aws cloudformation validate-template ... cli command, but that ignores incorrect property names. I don't know what the point of that cli command is if it won't catch these kind of mistakes.
I want something that will catch those kind of mistakes before running the templates. An IDE or external service that does this would be fine.
We had a quite similar issue with erroneous Cloud-Formation templates and created (I’m a co-author) a command-line tool, that validates them - besides the standard AWS validation it also has many custom checks, that were essential for us:
https://github.com/Appliscale/perun
I believe it doesn't support property names validation yet, but any feature requests (or pull request even better), are welcome. We will do our best to address them as soon as we can.
After installing Perun, to validate the template you can use the command validate:
~ $ perun validate <PATH TO THE TEMPLATE>
Moreover, it also allows managing (creation, updates etc.) CF stacks and monitoring the status updates.
The cfn-lint tool was built for this exact purpose. It is actively maintained by the AWS team and it has a couple of IDE integrations.
Same issue with me. There is no way to validate the property name. But you can reduce the mistake using Atom IDE with plugins cloudformation, it helps me to create a resources property so I can reduce my typo mistakes.