eBPF, OPA, Blackbox exporter, ffwd, Heroic


eBPF can be used for 

1. Map application and HA architecture
2. Detect network issues
3. Identify misbehaving svc

https://www.youtube.com/watch?v=thBCB7YeZ2g&list=PLj6h78yzYM2NDs-iu8WU5fMxINxHXlien&index=3

Open Policy Agent https://github.com/open-policy-agent/opa can be used to validate CRD
https://www.youtube.com/watch?v=DUe_8nf42Ik&list=PLj6h78yzYM2NDs-iu8WU5fMxINxHXlien&index=5

The blackbox exporter allows blackbox probing of endpoints over HTTP, HTTPS, DNS, TCP and ICMP. https://github.com/prometheus/blackbox_exporter

ffwd is a flexible metric forwarding agent. It is intended to run locally on the system and receive metrics through a wide set of protocols and then forward them to your TSDB.  https://github.com/spotify/ffwd 

Heroic A scalable time series database based on Bigtable, Cassandra, and Elasticsearch. https://github.com/spotify/heroic

https://www.youtube.com/watch?v=AA8e5v43AcU&list=PLj6h78yzYM2NDs-iu8WU5fMxINxHXlien&index=6

Easily Observing Operators


kube-state-metrics you can gather the following state about your cluster:
  • Counts of each object type
  • All of the Kubernetes labels and their values attached to each object
  • The creation time (as an epoch) of each object
  • Some generic, object specific “info”
  • Other states specific to the object in question

kube-state-metrics can be deployed like a classic Kubernetes service with only one replica.


List of metrics


Metrics about your CRD


Kustomize plugins


This is the third article out of three articles on Kubernetes tool : Kustomize. This article covers the plugins. 

kustomize plugins

Kustomize offers a plugin framework allowing people to write their own resource generators and transformers.

kustomization.yaml

generators:
- gen_file.yaml
transformers:
- trans_file.yaml

Let's focus on gen_file. Trans_file will be similar. 

gen_file.yaml

apiVersion: "apiVersion"
kind: Gen_File
metadata:
  name: "some name"

Now the file name "Gen_File" will be searched at path  
XDG_CONFIG_HOME = $HOME/.config = /home/manish.config
/home/manish/.config/kustomize/plugin/${apiVersion}/LOWERCASE(${kind})
Possible value for apiVersion = someteam.example.com/v1

If failed then "Gen_File.so" will be searched at same path

This file will be invoked with gen_file.yaml

Reference : https://github.com/kubernetes-sigs/kustomize/tree/master/docs/plugins

Built-in plugins : https://github.com/kubernetes-sigs/kustomize/tree/master/plugin/builtin
https://github.com/kubernetes-sigs/kustomize/blob/master/examples/chart.md
https://github.com/kubernetes-sigs/kustomize/blob/master/examples/secretGeneratorPlugin.md
https://github.com/kubernetes-sigs/kustomize/blob/master/examples/goGetterGeneratorPlugin.md
https://github.com/kubernetes-sigs/kustomize/blob/master/examples/validationTransformer/README.md
https://github.com/kubernetes-sigs/kustomize/blob/master/examples/transformerconfigs/README.md

Plugin Development
https://github.com/kubernetes-sigs/kustomize/blob/master/docs/plugins/execPluginGuidedExample.md
https://github.com/kubernetes-sigs/kustomize/blob/master/docs/plugins/goPluginGuidedExample.md

UseCases of Kustomize


This is the second article out of three articles on Kubernetes tool : Kustomize. This article covers the usecases. 

==============================
UseCase 1 : Config map generation and secreat generation 
secretGenerator:
- name: myregistrykey
 type: docker-registry
 literals:
 - docker-server=DOCKER_REGISTRY_SERVER
 - docker-username=DOCKER_USER
 - docker-password=DOCKER_PASSWORD
 - docker-email=DOCKER_EMAIL


This is same as: 

kubectl create secret docker-registry myregistrykey --docker-server=DOCKER_REGISTRY_SERVER --docker-username=DOCKER_USER --docker-password=DOCKER_PASSWORD --docker-email=DOCKER_EMAIL

Same as above configMapGenerator

configMapGenerator
- name: profile
  files: 
  - hello.config
  
  
We can also merge two configmaps

configMapGenerator:
- name: my-configmap
  behavior: merge
  files:
  - plumbing.properties
  - secret.properties


Configmap from literals

configMapGenerator:
- name: my-configmap
  literals:
  - foo=bar
  - baz=qux
  
==============================
UseCase 2 : Creating multiple variants using overlays. 
Edit attributes  as per specific file. Here localserv.yaml . Keyword is patchesStrategicMerge

kustomize edit add patch ocalserv.yaml

bases:
- ../../base
patchesStrategicMerge:
- localserv.yaml

Multi Variant Examples: 
https://github.com/kubernetes-sigs/kustomize/blob/master/examples/helloWorld/README.md
https://github.com/kubernetes-sigs/kustomize/blob/master/examples/breakfast.md

we can use "kustomize diff base/variant1/variant2" command to see the difference. 

==============================
UseCase 3 : edit container image and tag

kustomize edit set image busybox=alpine:3.6


images:
- name: busybox
  newName: alpine
  newTag: 3.6
==============================
UseCase 4 : Remote Target
kustomize build can be run on a URL.

The effect is the same as cloning the repo, checking out a particular ref (commit hash, branch name, release tag, etc.), then running kustomize build against the desired directory in the local copy.
==============================
UseCase 5 : applying a JSON patch. Replace and add

cat <$DEMO_HOME/ingress_patch.json
[
  {"op": "replace", "path": "/spec/rules/0/host", "value": "foo.bar.io"},
  {"op": "replace", "path": "/spec/rules/0/http/paths/0/backend/servicePort", "value": 8080}
]
EOF
You can also write the patch in YAML format. This example also shows the "add" operation:

cat <$DEMO_HOME/ingress_patch.yaml
- op: replace
  path: /spec/rules/0/host
  value: foo.bar.io

- op: add
  path: /spec/rules/0/http/paths/-
  value:
    path: '/test'
    backend:
      serviceName: my-test
      servicePort: 8081
EOF


patchesJson6902:
- target:
    group: apps
    version: v1
    kind: Deployment
    name: my-nginx
  path: patch.yaml
==============================
UseCase 6 : Patch on multiple objects
JSON patch and strategic merge patch can be applied to selected resources

patches:
- path: "PatchFile"
  target:
    group: "Group"
    version: "Version"
    kind: "Kind"
    name: "Name"
    namespace: "Namespace"
    labelSelector: "LabelSelector"
    annotationSelector: "AnnotationSelector"
==============================
UseCase 7 : Injecting k8s runtime data into containers

https://github.com/kubernetes-sigs/kustomize/blob/master/examples/wordpress/README.md

Kustomize


This is the first article out of three articles on Kubernetes tool : Kustomize. This article covers the basics. 

Kustomize

Kustomize is a CLI for managing K8s style objects with declarative ways

==============================
Edit name attribute by adding prefix/suffix  to it

namePrefix: prod-
nameSuffix: "-001"

Edit labels (k,v)  

commonLabels:
  app: my-wordpress

Edit annotations (k,v)  

commonAnnotations:
  description: this is test
  
Edit namespace

namespace: my-namespace
============================== 
Edit attribute to Multiple Files. 
kustomize edit add resource deployment.yaml
kustomize edit add resource service.yaml


commonLabels:
  app: my-wordpress
resources:
- deployment.yaml
- service.yaml
==============================
Edit attribute to Multiple directory. 

commonLabels:
  app: my-wordpress
bases:
- ./wordpress
- ./mysql
==============================

$ kustomize build $DEV_HOME
Its output is concatenated YAML documents. They can be directed to file or to kubectl 


kubectl apply -k $DEV_HOME
kustomize build $DEV_HOME | kubectl apply -f -
kubectl kustomize $DEV_HOME
==============================

Useful Terms

base: A combination of a kustomization and resource(s). Bases can be referred to by other kustomizations.

kustomization: Refers to a kustomization.yaml file, or more generally to a directory containing the kustomization.yaml file and all the relative file paths that the YAML file references.

overlay: A combination of a kustomization that refers to a base, and a patch. An overlay may have multiple bases.

patch: General instructions to modify a resource.

resource: Any valid YAML file that defines an object with a kind and a metadata/name field.

target: The argument to kustomize build. For example, kustomize build $TARGET. A target must be a path or a URL to a kustomization. A target can be a base or an overlay.

variant: The outcome of applying an overlay to a base.

Read More: https://github.com/kubernetes-sigs/kustomize/blob/master/docs/glossary.md

Reference: 
https://www.mirantis.com/blog/introduction-to-kustomize-part-1-creating-a-kubernetes-app-out-of-multiple-pieces/
https://www.mirantis.com/blog/introduction-to-kustomize-part-2-overriding-values-with-overlays/
https://github.com/kubernetes-sigs/kustomize
https://kustomize.io/

Other similar tools
https://github.com/kubernetes/community/blob/master/contributors/design-proposals/architecture/declarative-application-management.md
https://docs.google.com/spreadsheets/d/1FCgqz1Ci7_VCz_wdh8vBitZ3giBtac_H8SBw4uxnrsE/edit#gid=0