operator-sdk | Provides high level APIs | SDK library

 by   operator-framework Go Version: v1.29.0 License: Apache-2.0

kandi X-RAY | operator-sdk Summary

kandi X-RAY | operator-sdk Summary

operator-sdk is a Go library typically used in Utilities, SDK applications. operator-sdk has no bugs, it has no vulnerabilities, it has a Permissive License and it has medium support. You can download it from GitHub.

This project is a component of the Operator Framework, an open source toolkit to manage Kubernetes native applications, called Operators, in an effective, automated, and scalable way. Read more in the introduction blog post. Operators make it easy to manage complex stateful applications on top of Kubernetes. However writing an Operator today can be difficult because of challenges such as using low level APIs, writing boilerplate, and a lack of modularity which leads to duplication.

            kandi-support Support

              operator-sdk has a medium active ecosystem.
              It has 6546 star(s) with 1677 fork(s). There are 125 watchers for this library.
              There were 7 major release(s) in the last 12 months.
              There are 100 open issues and 2408 have been closed. On average issues are closed in 104 days. There are 48 open pull requests and 0 closed requests.
              It has a neutral sentiment in the developer community.
              The latest version of operator-sdk is v1.29.0

            kandi-Quality Quality

              operator-sdk has no bugs reported.

            kandi-Security Security

              operator-sdk has no vulnerabilities reported, and its dependent libraries have no vulnerabilities reported.

            kandi-License License

              operator-sdk is licensed under the Apache-2.0 License. This license is Permissive.
              Permissive licenses have the least restrictions, and you can use them in most projects.

            kandi-Reuse Reuse

              operator-sdk releases are available to install and integrate.

            Top functions reviewed by kandi - BETA

            kandi's functional review helps you automatically verify the functionalities of the libraries and avoid rework.
            Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of operator-sdk
            Get all kandi verified functions for this library.

            operator-sdk Key Features

            No Key Features are available at this moment for operator-sdk.

            operator-sdk Examples and Code Snippets

            No Code Snippets are available at this moment for operator-sdk.

            Community Discussions


            What is the use for CRD status?
            Asked 2021-Apr-21 at 15:38

            I'm currently writing a kubernetes operator in go using the operator-sdk. This operator creates two StatefulSet and two Service, with some business logic around it.

            I'm wondering what CRD status is about ? In my reconcile method I use the default client (i.e. r.List(ctx, &setList, opts...)) to fetch data from the cluster, shall I instead store data in the status to use it later ? If so how reliable this status is ? I mean is it persisted ? If the control plane dies is it still available ? What about disaster recovery, what if the persisted data disappear ? Doesn't that case invalidate the use of the CRD status ?



            Answered 2021-Apr-21 at 15:38

            The status subresource of a CRD can be considered to have the same objective of non-custom resources. While the spec defines the desired state of that particular resource, basically I declare what I want, the status instead explains the current situation of the resource I declared on the cluster and should help in understanding what is different between the desired state and the actual state.

            Like a StatefulSet spec could say I want 3 replicas and its status say that right now only 1 of those replicas is ready and the next one is still starting, a custom resource status may tell me what is the current situation of whatever I declared in the specs.

            For example, using the Rook Operator, I could declare I want a CephCluster made in a certain way. Since a CephCluster is a pretty complex thing (made of several StatefulSets, Daemons and more), the status of the custom resource definition will tell me the current situation of the whole ceph cluster, if it's health is ok or if something requires my attention and so on.

            From my understandings of the Kubernetes API, you shouldn't rely on status subresource to decide what your operator should do regarding a CRD as it is way better and less prone to errors to always check the current situation of the cluster (at operator start or when a resource is defined, updated or deleted)

            Last, let me quote from Kubernetes API conventions as it exaplins the convention pretty well ( https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md#spec-and-status )

            By convention, the Kubernetes API makes a distinction between the specification of the desired state of an object (a nested object field called "spec") and the status of the object at the current time (a nested object field called "status").

            The specification is a complete description of the desired state, including configuration settings provided by the user, default values expanded by the system, and properties initialized or otherwise changed after creation by other ecosystem components (e.g., schedulers, auto-scalers), and is persisted in stable storage with the API object. If the specification is deleted, the object will be purged from the system.

            The status summarizes the current state of the object in the system, and is usually persisted with the object by automated processes but may be generated on the fly. At some cost and perhaps some temporary degradation in behavior, the status could be reconstructed by observation if it were lost.

            When a new version of an object is POSTed or PUT, the "spec" is updated and available immediately. Over time the system will work to bring the "status" into line with the "spec". The system will drive toward the most recent "spec" regardless of previous versions of that stanza. In other words, if a value is changed from 2 to 5 in one PUT and then back down to 3 in another PUT the system is not required to 'touch base' at 5 before changing the "status" to 3. In other words, the system's behavior is level-based rather than edge-based. This enables robust behavior in the presence of missed intermediate state changes.

            Source https://stackoverflow.com/questions/67074291


            How to synchronize Custom resource when its specification is updated
            Asked 2021-Mar-23 at 18:57

            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?



            Answered 2021-Mar-19 at 20:30

            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.

            Source https://stackoverflow.com/questions/66715107


            Operator-SDK Error, "CRD is present in bundle but not defined in CSV"
            Asked 2021-Mar-19 at 07:10

            I get the error "CRD is present in bundle but not defined in CSV" when I run make bundle.

            The full output is



            Answered 2021-Mar-19 at 07:10

            The error on the bottom is a red herring. The actual error is further up and uncolored when you experience it in person. Specifically, a Kustomize yaml is expecting an myapplicationui.yaml but can't find it.

            This can easily happen when someone in your team attempts to rename files (e.g. to myapplicationui_sample.yaml) without checking all of the references.

            Source https://stackoverflow.com/questions/66703883


            Running Kubernetes locally on M1 Mac
            Asked 2021-Feb-15 at 21:35

            I'm looking to see if it's currently possible to run Kubernetes locally on a 2020 M1 MacBook air.

            The environment I need is relatively simple, just for going through some tutorials. As an example, this operator-sdk guide.

            So far I've tried microk8s and minikube, as they're tools I've used before on other machines.

            For both of these, I've installed them using brew after opening the terminal app "with Rosetta 2" (i.e like this). My progress is then:


            When I run minikube start --driver=docker (having installed the tech preview of Docker Desktop for M1), an initialization error occurs. It seems to me that this is being tracked here https://github.com/kubernetes/minikube/issues/9224.


            microk8s install asks to install multipass, which then errors with An error occurred with the instance when trying to start with 'multipass': returned exit code 2. Ensure that 'multipass' is setup correctly and try again.. Multipass shows a microk8s-vm stuck in starting. I think this may relate to this issue https://github.com/canonical/multipass/issues/1857.

            I'm aware I'd probably be better chasing up those issues for help on these particular errors. What would be great is any general advice on if it's currently possible/advisable to setup a basic Kubernetes env for playing with on an M1 mac. I'm not experienced with the underlying technologies here, so any additional context is welcome. :)

            If anyone has suggestions for practising Kubernetes, alternative to setting up a local cluster, I'd also appreciate them. Thanks!



            Answered 2021-Jan-23 at 20:35

            First, it is usually good to have Docker when working with containers. Docker now has a Tech Preview of Docker for Apple M1 based macs.

            When you have a workin Docker on your machine, it should also work to use Kind - a way to run Kubernetes on Docker containers.

            Source https://stackoverflow.com/questions/65864009


            Operator controller could not delete correlated resources
            Asked 2020-Nov-14 at 06:48

            In Kubernetes and Operator-sdk, we can define CRD (Custom Resource Definition) and CR (Custom Resource). In my operator controller, when a CR is initialized, then I create a new Deployment and service.

            When we delete a CR object, then the correlated resources (such as Deployment or service) will be deleted as well at the same time. I understand it should be done by CR or CRD finalizer, this is just my guess.

            Now I hit an issue, during Operator testing, under envTest environment, when I delete a CR, its correlated resources (Deployment or service) have not been deleted.

            I am confused. In real k8s cluster, the correlated resources (Deployment or service) can be deleted automatically when I delete a CR, under envTest environment, why it doesn't delete correlated resources?

            Could anybody point out the reason.



            Answered 2020-Nov-13 at 18:02

            Deletion of orphaned resources is done by Kubernetes's garbage collector, which is implemented in kubelet. When you test operator in envTest environment, garbage collection doesn't work because kubelet is missing in that environment(it only deploys API server and etcd).

            Source https://stackoverflow.com/questions/64821970


            How Finalizer work for CustomResouce object?
            Asked 2020-Nov-13 at 18:11

            In Kubernetes and Operator-sdk, we can define CRD (Custom Resource Definition) and CR (Custom Resource). In my operator controller, when a CR is initialized, then the controller reconcillation create a new Deployment and service.

            When we delete a CR object, then the associated resources (such as Deployment or service) will be deleted as well at the same time. I understand it should be done by CR Finalizer. But, in Operator-SDK and my controller code, I never see any code to register or add Finalizer for CR, is there any default behavior for Operator-Sdk?

            Could anybody point how it work for the case - "while deleting CR, the associated Deployment and Service have deleted as well"? Which part in controller is responsible for that?



            Answered 2020-Nov-13 at 18:11

            Deletion of associated resources is not part of a controller. It's done by Kubernetes's garbage collector.

            Basically, garbage collector using OwnerReference objects to find orphaned resources and delete them. Most likely, you set OwnerReference by calling controllerutil.SetControllerReference method somewhere in your code.

            Source https://stackoverflow.com/questions/64823584


            kubernetes Operator-sdk test with envTest
            Asked 2020-Nov-10 at 16:53

            I am a newbie for operator-sdk. Now I am writing test for operator with envtest framework, so I had a fake control-plane for environments.

            Inside controller reconcile loop, once I initialize a CR, then controller will pull down an image for pod and deploy that Pod.

            All behaviour in the above happens in the real k8s cluster. My question is, under envtest environemnts, does controller really pull down image for deploying Pods?



            Answered 2020-Nov-10 at 16:53

            That depends on envtest configuration. Here is quotes from kubebuilder book:

            [envtest] setting up and starting an instance of etcd and the Kubernetes API server, without kubelet, controller-manager or other components

            Unless you’re using an existing cluster, keep in mind that no built-in controllers are running in the test context

            So, if you don't set USE_EXISTING_CLUSTER env var to true, envtest will set control plane with only API server and etcd. For example, if your controller should create Deployment at some event, there's no deployment controller in test environment that gonna create ReplicaSet and Pods. Basically, all it does is stores state of test environment in etcd.

            Source https://stackoverflow.com/questions/64772721


            Fail to upgrade operator in K8s
            Asked 2020-Oct-02 at 12:01

            I'm writing an operator by operator-sdk and I have created statefulset pod in operator by using k8s api like : r.client.Create(context.TODO(), statefulset)

            It's works correctly and the statefulset pod is crated. But now I want to upgrade the operator already run in k8s so that I can add some command for pod like



            Answered 2020-Oct-02 at 12:01

            You should delete statefulset itself instead of statefulset pod. The problem is when you delete statefulset pod - new pod automatically creates from old statefulset spec.

            Once you delete/recreate statefulset - as expected you schedule proper updated pods.

            Probably you can add additional logic to operator that will patch already existed statefulset - that can be resolution for avoiding redeploy statefulset each time.

            Source https://stackoverflow.com/questions/64061565


            Best Practice for Operators for how to get Deployment's configuration
            Asked 2020-Sep-04 at 07:17

            I am working on operator-sdk, in the controller, we often need to create a Deployment object, and Deployment resource has a lot of configuration items, such as environment variables or ports definition or others as following. I am wondering what is best way to get these values, I don't want to hard code them, for example, variable_a or variable_b.

            Probably, you can put them in the CRD as spec, then pass them to Operator Controller; Or maybe you can put them in the configmap, then pass configmap name to Operator Controller, Operator Controller can access configmap to get them; Or maybe you can put in the template file, then in the Operator Controller, controller has to read that template file.

            What is best way or best practice to deal with this situation? Thanks for sharing your ideas or points.



            Answered 2020-Sep-04 at 07:17
            Using enviroment variables

            It can be convenient that your app gets your data as environment variables.

            Environment variables from ConfigMap

            For non-sensitive data, you can store your variables in a ConfigMap and then define container environment variables using the ConfigMap data.

            Example from Kubernetes docs:

            Create the ConfigMap first. File configmaps.yaml:

            Source https://stackoverflow.com/questions/63715042


            Kubernetes controller update CR status field with values from pod output in GO
            Asked 2020-Jul-14 at 00:39

            Using the Operator-sdk I deploy a CR that has a Job with a pod. CR has a Status struct something like below



            Answered 2020-Jul-13 at 22:31

            You can start by creating a controller (you might have already):

            Source https://stackoverflow.com/questions/62883727

            Community Discussions, Code Snippets contain sources that include Stack Exchange Network


            No vulnerabilities reported

            Install operator-sdk

            You can download it from GitHub.


            Docs can be found on the Operator SDK website.
            Find more information at:

            Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items

            Find more libraries
          • HTTPS


          • CLI

            gh repo clone operator-framework/operator-sdk

          • sshUrl


          • Stay Updated

            Subscribe to our newsletter for trending solutions and developer bootcamps

            Agree to Sign up and Terms & Conditions

            Share this Page

            share link

            Explore Related Topics

            Consider Popular SDK Libraries


            by JeffreySu


            by operator-framework


            by golang

            Try Top Libraries by operator-framework


            by operator-frameworkGo


            by operator-frameworkShell


            by operator-frameworkGo


            by operator-frameworkShell


            by operator-frameworkGo