513 k8s Custom Resources and Operators [0.5 PT]

Posted . Visible to the public.

Ziele

  • Du verstehst was eine Custom Resource ist und warum das nützlich sein kann.
  • Du weißt, was ein Operator ist und wie dieser funktioniert.

Inhalte

Aufgaben

  1. Sprich mit deinem Mentor über Anhang A
  2. Sprich mit deinem Mentor über die labels aus Anhang B.

Anhang A

apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
  name: samples.bookofkubernetes.com
spec:
  group: bookofkubernetes.com
  versions:
    - name: v1
      served: true
      storage: true
      schema:
        openAPIV3Schema:
          type: object
          properties:
            spec:
              type: object
              properties:
                value:
                  type: integer
  scope: Namespaced
  names:
    plural: samples
    singular: sample
    kind: Sample
    shortNames:
      - sam

Anhang B

----
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
  name: monitoring
aggregationRule:
  clusterRoleSelectors:
  - matchLabels:
  	rbac.example.com/aggregate-to-monitoring: "true"
rules: [] # The control plane automatically fills in the rules

---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
  name: monitoring-endpoints
  labels:
	rbac.example.com/aggregate-to-monitoring: "true"
# When you create the "monitoring-endpoints" ClusterRole,
# the rules below will be added to the "monitoring" ClusterRole.
rules:
- apiGroups: [""]
  resources: ["services", "endpointslices", "pods"]
  verbs: ["get", "list", "watch"]
Claus-Theodor Riegg
Last edit
Claus-Theodor Riegg
License
Source code in this card is licensed under the MIT License.
Posted by Claus-Theodor Riegg to DevOps Curriculum (2023-02-06 13:38)