All Projects → banzaicloud → K8s Objectmatcher

banzaicloud / K8s Objectmatcher

Licence: apache-2.0
A Kubernetes object matcher library to avoid unnecessary K8s object updates

Programming Languages

go
31211 projects - #10 most used programming language
operators
16 projects

Projects that are alternatives of or similar to K8s Objectmatcher

Gettext Go
🆎 GNU gettext for Go (Imported By Kubernetes)
Stars: ✭ 66 (-29.03%)
Mutual labels:  k8s
K8s Docker Desktop For Mac
Docker Desktop for Mac 开启并使用 Kubernetes
Stars: ✭ 1,246 (+1239.78%)
Mutual labels:  k8s
Workflow
The open source PaaS for Kubernetes.
Stars: ✭ 1,291 (+1288.17%)
Mutual labels:  k8s
K8s Offline
Offline installation package for kubernetes.
Stars: ✭ 72 (-22.58%)
Mutual labels:  k8s
Kubernetes Deployment Restart Controller
Kubernetes controller that restarts Deployments when referenced ConfigMaps or Secrets change.
Stars: ✭ 80 (-13.98%)
Mutual labels:  k8s
Cloudprober
An active monitoring software to detect failures before your customers do.
Stars: ✭ 1,269 (+1264.52%)
Mutual labels:  k8s
Helm Secrets
DEPRECATED A helm plugin that help manage secrets with Git workflow and store them anywhere
Stars: ✭ 1,129 (+1113.98%)
Mutual labels:  k8s
Lotus
Kubernetes controller for running load testing
Stars: ✭ 92 (-1.08%)
Mutual labels:  k8s
K8s Mediaserver Operator
Repository for k8s Mediaserver Operator project
Stars: ✭ 81 (-12.9%)
Mutual labels:  k8s
Tower Operator
DEPRECATED: This project was moved and renamed to: https://github.com/ansible/awx-operator
Stars: ✭ 87 (-6.45%)
Mutual labels:  k8s
Deploy
Deploy Development Builds of Open Cluster Management (OCM) on RedHat Openshift Container Platform
Stars: ✭ 78 (-16.13%)
Mutual labels:  k8s
Router
Edge router for Deis Workflow
Stars: ✭ 78 (-16.13%)
Mutual labels:  k8s
Cdk
CDK is an open-sourced container penetration toolkit, offering stable exploitation in different slimmed containers without any OS dependency. It comes with penetration tools and many powerful PoCs/EXPs helps you to escape container and takeover K8s cluster easily.
Stars: ✭ 1,264 (+1259.14%)
Mutual labels:  k8s
Kcd
Continuous Delivery for Kubernetes
Stars: ✭ 69 (-25.81%)
Mutual labels:  k8s
Kuboard Press
Kuboard 是基于 Kubernetes 的微服务管理界面。同时提供 Kubernetes 免费中文教程,入门教程,最新版本的 Kubernetes v1.20 安装手册,(k8s install) 在线答疑,持续更新。
Stars: ✭ 12,701 (+13556.99%)
Mutual labels:  k8s
Container Service Extension
Container Service for VMware vCloud Director
Stars: ✭ 66 (-29.03%)
Mutual labels:  k8s
Advent 2017
[article] GopherAcademy 2017: Write a Kubernetes-ready service from scratch step-by-step
Stars: ✭ 85 (-8.6%)
Mutual labels:  k8s
Dregsy
Keep Docker registries in sync
Stars: ✭ 92 (-1.08%)
Mutual labels:  k8s
Kubernetes Up And Running Notes
Notes from the book Kubernetes Up and Running
Stars: ✭ 91 (-2.15%)
Mutual labels:  k8s
Docker Cloud Platform
使用Docker构建云平台,Docker云平台系列共三讲,Docker基础、Docker进阶、基于Docker的云平台方案。OpenStack+Docker+RestAPI+OAuth/HMAC+RabbitMQ/ZMQ+OpenResty/HAProxy/Nginx/APIGateway+Bootstrap/AngularJS+Ansible+K8S/Mesos/Marathon构建/探索微服务最佳实践。
Stars: ✭ 86 (-7.53%)
Mutual labels:  k8s

license

Kubernetes object matcher

K8S-ObjectMatcher is a Golang library which helps to match Kubernetes objects.

Motivation

Here at Banzai Cloud we love and write lots of Kubernetes operators. While writing some complex operators as the Istio , Vault or Kafka operator, we encountered a huge amount of unnecessary Kubernetes object updates. Most of the operators out there are using reflect.DeepEquals to match the given object's Spec. Unfortunately, this solution is not perfect because every Kubernetes object is amended with different default values while submitted. This library aims to provide finer object matching capabilities to avoid unnecessary updates and more observability on the client side.

Legacy version deprecation notice

There is a legacy version of the lib, that is now deprecated and documented here: docs/legacy.md

How does it work?

The library uses the same method that kubectl apply does under the hood to calculate a patch using the three way merge method. However for this to work properly we need to keep track of the last applied version of our object, let's call it the original. Unfortunately Kubernetes does not keep track of our previously submitted object versions, but we can put it into an annotation like kubectl apply does. Next time we query the current state of the object from the API Server we can extract the original version from the annotation.

Once we have the the original, the current and our new modified object in place the library will take care of the rest.

Example steps demonstrated on a v1.Service object

Create a new object, annotate it, then submit normally

original := &v1.Service{
  ...
}

if err := patch.DefaultAnnotator.SetLastAppliedAnnotation(original); err != nil {
  ...
}

client.CoreV1().Services(original.GetNamespace()).Create(original)

Next time we check the diff and set the last applied annotation in case we have to update

modified := &v1.Service{
  ...
}

current, err := client.CoreV1().Services(modified.GetNamespace()).Get(modified.GetName(), metav1.Getoptions{})

patchResult, err := patch.DefaultPatchMaker.Calculate(current, modified)
if err != nil {
  return err
}

if !patchResult.IsEmpty() {
  if err := patch.DefaultAnnotator.SetLastAppliedAnnotation(modified); err != nil {
  	...
  }
  client.CoreV1().Services(modified.GetNamespace()).Update(modified)
}

Contributing

If you find this project useful here's how you can help:

  • Send a pull request with your new features and bug fixes
  • Help new users with issues they may encounter
  • Support the development of this project and star this repo!

License

Copyright (c) 2017-2019 Banzai Cloud, Inc.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].