Commit 6ac10350 authored by psaromanola1's avatar psaromanola1
Browse files

Initial helm package files for ocm-scheduler

parent bea60662
Loading
Loading
Loading
Loading
+6 −0
Changes for ocm-scheduler-chart/Chart.yaml: 6 added lines, 0 removed lines.
Original line number Diff line number Diff line
apiVersion: v2
name: ocm-scheduler
description: Hypo OCM Scheduler
type: application
version: 0.1.0
appVersion: "v1"
+179 −0
Changes for ocm-scheduler-chart/crds/hyposchedulingmanifests.scheduling.hypo.eu.yaml: 179 added lines, 0 removed lines.
Original line number Diff line number Diff line
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
  annotations:
    controller-gen.kubebuilder.io/version: v0.16.1
  name: hyposchedulingmanifests.scheduling.hypo.eu
spec:
  group: scheduling.hypo.eu
  names:
    kind: HypoSchedulingManifest
    listKind: HypoSchedulingManifestList
    plural: hyposchedulingmanifests
    singular: hyposchedulingmanifest
  scope: Namespaced
  versions:
  - additionalPrinterColumns:
    - jsonPath: .status.state
      name: State
      type: string
    name: v1alpha1
    schema:
      openAPIV3Schema:
        description: HypoSchedulingManifest is the Schema for the hyposchedulingmanifests
          API
        properties:
          apiVersion:
            description: |-
              APIVersion defines the versioned schema of this representation of an object.
              Servers should convert recognized schemas to the latest internal value, and
              may reject unrecognized values.
              More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources
            type: string
          kind:
            description: |-
              Kind is a string value representing the REST resource this object represents.
              Servers may infer this from the endpoint the client submits requests to.
              Cannot be updated.
              In CamelCase.
              More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds
            type: string
          metadata:
            type: object
          spec:
            description: HypoSchedulingManifestSpec defines the desired state of
              HypoSchedulingManifest
            properties:
              globalAnnotations:
                description: |-
                  Optional list of annotations applied to all manifests under Spec.Manifests
                  Annotations must be of the form hypo.xx.yy=zz
                  Filter annotations may be used to schedule to a clusters with a given feature
                  Clusters can be filtered based on:
                  - physical location (Europe, Greece, Italy)
                  - Kubernetes distribution installed on the cluster (Kubernetes, OpenShift)
                  - resource availability (GPUs, presence of edge devices)
                items:
                  type: string
                type: array
              manifests:
                description: Required list of related manifests, much like a Helm
                  Chart
                items:
                  type: object
                  x-kubernetes-preserve-unknown-fields: true
                type: array
              workloadAnnotations:
                description: |-
                  Optional list of more granular annotations
                  If a particular workload requires a specific annotation it should be specified here
                  WorkloadAnnotations must follow the same format as GlobalAnnotations
                items:
                  properties:
                    annotations:
                      description: List of annotations to associate with the named
                        workload
                      items:
                        type: string
                      type: array
                    name:
                      description: Name of Kubernetes workload to schedule according
                        to Annotations
                      type: string
                  type: object
                type: array
            required:
            - manifests
            type: object
          status:
            description: HypoSchedulingManifestStatus defines the observed state
              of HypoSchedulingManifest
            properties:
              conditions:
                description: List of conditions for HypoSchedulingManifest
                items:
                  description: Condition contains details for one aspect of the current
                    state of this API Resource.
                  properties:
                    lastTransitionTime:
                      description: |-
                        lastTransitionTime is the last time the condition transitioned from one status to another.
                        This should be when the underlying condition changed.  If that is not known, then using the time when the API field changed is acceptable.
                      format: date-time
                      type: string
                    message:
                      description: |-
                        message is a human readable message indicating details about the transition.
                        This may be an empty string.
                      maxLength: 32768
                      type: string
                    observedGeneration:
                      description: |-
                        observedGeneration represents the .metadata.generation that the condition was set based upon.
                        For instance, if .metadata.generation is currently 12, but the .status.conditions[x].observedGeneration is 9, the condition is out of date
                        with respect to the current state of the instance.
                      format: int64
                      minimum: 0
                      type: integer
                    reason:
                      description: |-
                        reason contains a programmatic identifier indicating the reason for the condition's last transition.
                        Producers of specific condition types may define expected values and meanings for this field,
                        and whether the values are considered a guaranteed API.
                        The value should be a CamelCase string.
                        This field may not be empty.
                      maxLength: 1024
                      minLength: 1
                      pattern: ^[A-Za-z]([A-Za-z0-9_,:]*[A-Za-z0-9_])?$
                      type: string
                    status:
                      description: status of the condition, one of True, False, Unknown.
                      enum:
                      - "True"
                      - "False"
                      - Unknown
                      type: string
                    type:
                      description: type of condition in CamelCase or in foo.example.com/CamelCase.
                      maxLength: 316
                      pattern: ^([a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*/)?(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])$
                      type: string
                  required:
                  - lastTransitionTime
                  - message
                  - reason
                  - status
                  - type
                  type: object
                type: array
              decisions:
                description: List with scheduling decision made for each manifest
                  taking into account the annotations specified
                items:
                  properties:
                    clusterSelected:
                      description: Name of managed cluster where the workload and
                        its ancillary resource have been scheduled
                      type: string
                    workloadName:
                      description: Name of workload scheduled
                      type: string
                  required:
                  - clusterSelected
                  - workloadName
                  type: object
                type: array
              state:
                description: State of the HypoSchedulingManifest indicating if scheduling
                  is in progress, failed or successful
                type: string
            required:
            - conditions
            - decisions
            - state
            type: object
        type: object
    served: true
    storage: true
    subresources:
      status: {}
+114 −0
Changes for ocm-scheduler-chart/templates/cleanup-job.yaml: 114 added lines, 0 removed lines.
Original line number Diff line number Diff line
apiVersion: v1
kind: ServiceAccount
metadata:
  name: {{ .Release.Name }}-cleanup
  namespace: {{ .Release.Namespace }}
  annotations:
    "helm.sh/hook": pre-delete
    "helm.sh/hook-weight": "-10"
    "helm.sh/hook-delete-policy": before-hook-creation,hook-succeeded
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
  name: {{ .Release.Name }}-cleanup
  annotations:
    "helm.sh/hook": pre-delete
    "helm.sh/hook-weight": "-10"
    "helm.sh/hook-delete-policy": before-hook-creation,hook-succeeded
rules:
  - apiGroups: ["scheduling.hypo.eu"]
    resources: ["hyposchedulingmanifests"]
    verbs: ["get", "list", "delete", "deletecollection"]
  - apiGroups: ["work.open-cluster-management.io"]
    resources: ["manifestworks"]
    verbs: ["get", "list", "delete", "deletecollection"]
  - apiGroups: ["cluster.open-cluster-management.io"]
    resources: ["managedclusters"]
    verbs: ["get", "patch"]
  - apiGroups: ["apiextensions.k8s.io"]
    resources: ["customresourcedefinitions"]
    verbs: ["get", "list", "watch"]
  - apiGroups: ["apiextensions.k8s.io"]
    resources: ["customresourcedefinitions"]
    resourceNames: ["hyposchedulingmanifests.scheduling.hypo.eu"]
    verbs: ["delete"]
  - apiGroups: ["cluster.open-cluster-management.io"]
    resources: ["managedclustersets/join"]
    resourceNames:
      - {{ .Values.clusterSet.name | quote }}
    verbs: ["create"]

---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
  name: {{ .Release.Name }}-cleanup
  annotations:
    "helm.sh/hook": pre-delete
    "helm.sh/hook-weight": "-10"
    "helm.sh/hook-delete-policy": before-hook-creation,hook-succeeded
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: ClusterRole
  name: {{ .Release.Name }}-cleanup
subjects:
  - kind: ServiceAccount
    name: {{ .Release.Name }}-cleanup
    namespace: {{ .Release.Namespace }}
---
apiVersion: batch/v1
kind: Job
metadata:
  name: {{ .Release.Name }}-cleanup
  namespace: {{ .Release.Namespace }}
  annotations:
    "helm.sh/hook": pre-delete
    "helm.sh/hook-weight": "0"
    "helm.sh/hook-delete-policy": before-hook-creation,hook-succeeded
spec:
  backoffLimit: 2
  template:
    spec:
      serviceAccountName: {{ .Release.Name }}-cleanup
      restartPolicy: Never
      containers:
        - name: kubectl
          image: alpine/k8s:1.31.1
          command: ["/bin/sh", "-ec"]
          args:
            - |
              # Let the running scheduler finalize its own resources first.
              kubectl delete hyposchedulingmanifests --all -A --ignore-not-found --wait=true --timeout=180s
              # Delete any remaining scheduler-owned ManifestWorks, never unrelated works.
              kubectl delete manifestworks -A -l scheduling.hypo.eu/owner --ignore-not-found --wait=true --timeout=180s
              {{- range $i, $cluster := .Values.managedClusters }}
              kubectl --kubeconfig=/kubeconfigs/{{ $i }}/kubeconfig delete clusterclaim hypo.filter.location --ignore-not-found --wait=true
              # Remove only the membership assigned by this release.
              {{- if $.Values.clusterSet.enabled }}
              current=$(kubectl get managedcluster {{ $cluster.name | quote }} -o jsonpath='{.metadata.labels.cluster\.open-cluster-management\.io/clusterset}')
              if [ "$current" = {{ $.Values.clusterSet.name | quote }} ]; then
                kubectl label managedcluster {{ $cluster.name | quote }} cluster.open-cluster-management.io/clusterset- 
              fi
              {{- end }}
              {{- end }}
              kubectl delete crd hyposchedulingmanifests.scheduling.hypo.eu --ignore-not-found --wait=false
          {{- if .Values.managedClusters }}
          volumeMounts:
            {{- range $i, $cluster := .Values.managedClusters }}
            - name: kubeconfig-{{ $i }}
              mountPath: /kubeconfigs/{{ $i }}
              readOnly: true
            {{- end }}
          {{- end }}
      {{- if .Values.managedClusters }}
      volumes:
        {{- range $i, $cluster := .Values.managedClusters }}
        - name: kubeconfig-{{ $i }}
          secret:
            secretName: {{ $cluster.kubeconfigSecretName | quote }}
            items:
              - key: kubeconfig
                path: kubeconfig
        {{- end }}
      {{- end }}
+88 −0
Changes for ocm-scheduler-chart/templates/managed-clusters-job.yaml: 88 added lines, 0 removed lines.
Original line number Diff line number Diff line
{{- if .Values.clusterSet.enabled }}
apiVersion: v1
kind: ServiceAccount
metadata:
  name: hypo-scheduler-setup
  namespace: {{ .Release.Namespace }}
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
  name: {{ .Release.Name }}-managedcluster-setup
rules:
  - apiGroups: ["cluster.open-cluster-management.io"]
    resources: ["managedclusters"]
    verbs: ["get", "patch"]
  - apiGroups: ["cluster.open-cluster-management.io"]
    resources: ["managedclustersets/join"]
    resourceNames:
      - {{ .Values.clusterSet.name | quote }}
    verbs: ["create"]
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
  name: {{ .Release.Name }}-managedcluster-setup
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: ClusterRole
  name: {{ .Release.Name }}-managedcluster-setup
subjects:
  - kind: ServiceAccount
    name: hypo-scheduler-setup
    namespace: {{ .Release.Namespace }}
---
apiVersion: batch/v1
kind: Job
metadata:
  name: {{ .Release.Name }}-configure-clusters
  namespace: {{ .Release.Namespace }}
  annotations:
    helm.sh/hook: post-install,post-upgrade
    helm.sh/hook-weight: "5"
    helm.sh/hook-delete-policy: before-hook-creation,hook-succeeded
spec:
  backoffLimit: 2
  template:
    spec:
      restartPolicy: Never
      serviceAccountName: hypo-scheduler-setup
      containers:
        - name: kubectl
          image: alpine/k8s:1.31.1
          command: ["/bin/sh", "-ec"]
          args:
            - |
              {{- range $i, $cluster := .Values.managedClusters }}
              kubectl get managedcluster {{ $cluster.name | quote }} >/dev/null
              kubectl label managedcluster {{ $cluster.name | quote }} 'cluster.open-cluster-management.io/clusterset={{ $.Values.clusterSet.name }}' --overwrite
              cat <<'CLAIM_{{ $i }}' | kubectl --kubeconfig=/kubeconfigs/{{ $i }}/kubeconfig apply -f -
              apiVersion: cluster.open-cluster-management.io/v1alpha1
              kind: ClusterClaim
              metadata:
                name: hypo.filter.location
              spec:
                value: {{ $cluster.location | quote }}
              CLAIM_{{ $i }}
              {{- end }}
          {{- if .Values.managedClusters }}
          volumeMounts:
            {{- range $i, $cluster := .Values.managedClusters }}
            - name: kubeconfig-{{ $i }}
              mountPath: /kubeconfigs/{{ $i }}
              readOnly: true
            {{- end }}
          {{- end }}
      {{- if .Values.managedClusters }}
      volumes:
        {{- range $i, $cluster := .Values.managedClusters }}
        - name: kubeconfig-{{ $i }}
          secret:
            secretName: {{ $cluster.kubeconfigSecretName | quote }}
            items:
              - key: kubeconfig
                path: kubeconfig
        {{- end }}
      {{- end }}
{{- end }}
+330 −0
Changes for ocm-scheduler-chart/templates/scheduler.yaml: 330 added lines, 0 removed lines.
Original line number Diff line number Diff line
apiVersion: v1
kind: ServiceAccount
metadata:
  name: hypo-scheduler-controller-manager
  namespace: {{ .Release.Namespace }}
---
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
  name: hypo-scheduler-leader-election-role
  namespace: {{ .Release.Namespace }}
rules:
- apiGroups:
  - ''
  resources:
  - configmaps
  verbs:
  - get
  - list
  - watch
  - create
  - update
  - patch
  - delete
- apiGroups:
  - coordination.k8s.io
  resources:
  - leases
  verbs:
  - get
  - list
  - watch
  - create
  - update
  - patch
  - delete
- apiGroups:
  - ''
  resources:
  - events
  verbs:
  - create
  - patch
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
  name: hypo-scheduler-hyposchedulingmanifest-editor-role
rules:
- apiGroups:
  - scheduling.hypo.eu
  resources:
  - hyposchedulingmanifests
  verbs:
  - create
  - delete
  - get
  - list
  - patch
  - update
  - watch
- apiGroups:
  - scheduling.hypo.eu
  resources:
  - hyposchedulingmanifests/status
  verbs:
  - get
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
  name: hypo-scheduler-hyposchedulingmanifest-viewer-role
rules:
- apiGroups:
  - scheduling.hypo.eu
  resources:
  - hyposchedulingmanifests
  verbs:
  - get
  - list
  - watch
- apiGroups:
  - scheduling.hypo.eu
  resources:
  - hyposchedulingmanifests/status
  verbs:
  - get
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
  name: hypo-scheduler-manager-role
rules:
- apiGroups:
  - ac3.redhat.com
  resources:
  - multiclusternetworks
  verbs:
  - create
  - delete
  - get
  - list
  - patch
  - update
  - watch
- apiGroups:
  - cluster.open-cluster-management.io
  resources:
  - managedclusters
  - managedclustersetbindings
  - managedclustersets
  verbs:
  - get
  - list
  - watch
- apiGroups:
  - cluster.open-cluster-management.io
  resources:
  - placementdecisions
  verbs:
  - delete
  - get
  - list
  - watch
- apiGroups:
  - cluster.open-cluster-management.io
  resources:
  - placements
  verbs:
  - create
  - delete
  - get
  - list
  - patch
  - update
  - watch
- apiGroups:
  - scheduling.hypo.eu
  resources:
  - hyposchedulingmanifests
  verbs:
  - create
  - delete
  - get
  - list
  - patch
  - update
  - watch
- apiGroups:
  - scheduling.hypo.eu
  resources:
  - hyposchedulingmanifests/finalizers
  verbs:
  - update
- apiGroups:
  - scheduling.hypo.eu
  resources:
  - hyposchedulingmanifests/status
  verbs:
  - get
  - patch
  - update
- apiGroups:
  - work.open-cluster-management.io
  resources:
  - manifestworks
  verbs:
  - create
  - delete
  - get
  - list
  - patch
  - update
  - watch
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
  name: hypo-scheduler-metrics-auth-role
rules:
- apiGroups:
  - authentication.k8s.io
  resources:
  - tokenreviews
  verbs:
  - create
- apiGroups:
  - authorization.k8s.io
  resources:
  - subjectaccessreviews
  verbs:
  - create
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
  name: hypo-scheduler-metrics-reader
rules:
- nonResourceURLs:
  - /metrics
  verbs:
  - get
---
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
  name: hypo-scheduler-leader-election-rolebinding
  namespace: {{ .Release.Namespace }}
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: Role
  name: hypo-scheduler-leader-election-role
subjects:
- kind: ServiceAccount
  name: hypo-scheduler-controller-manager
  namespace: {{ .Release.Namespace }}
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
  name: hypo-scheduler-manager-rolebinding
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: ClusterRole
  name: hypo-scheduler-manager-role
subjects:
- kind: ServiceAccount
  name: hypo-scheduler-controller-manager
  namespace: {{ .Release.Namespace }}
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
  name: hypo-scheduler-metrics-auth-rolebinding
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: ClusterRole
  name: hypo-scheduler-metrics-auth-role
subjects:
- kind: ServiceAccount
  name: hypo-scheduler-controller-manager
  namespace: {{ .Release.Namespace }}
---
apiVersion: v1
kind: Service
metadata:
  name: hypo-scheduler-controller-manager-metrics-service
  namespace: {{ .Release.Namespace }}
spec:
  ports:
  - name: https
    port: 8443
    protocol: TCP
    targetPort: 8443
  selector:
    control-plane: controller-manager
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: hypo-scheduler-controller-manager
  namespace: {{ .Release.Namespace }}
spec:
  replicas: {{ .Values.scheduler.replicaCount }}
  selector:
    matchLabels:
      control-plane: controller-manager
  template:
    metadata:
      annotations:
        kubectl.kubernetes.io/default-container: manager
      labels:
        control-plane: controller-manager
    spec:
      containers:
      - args:
        - --metrics-bind-address=:8443
        - --leader-elect
        - --health-probe-bind-address=:8081
        command:
        - /manager
        image: "{{ .Values.scheduler.image.repository }}:{{ .Values.scheduler.image.tag }}"
        imagePullPolicy: {{ .Values.scheduler.image.pullPolicy }}
        livenessProbe:
          httpGet:
            path: /healthz
            port: 8081
          initialDelaySeconds: 15
          periodSeconds: 20
        name: manager
        readinessProbe:
          httpGet:
            path: /readyz
            port: 8081
          initialDelaySeconds: 5
          periodSeconds: 10
        resources:
          limits:
            cpu: 500m
            memory: 128Mi
          requests:
            cpu: 10m
            memory: 64Mi
        securityContext:
          allowPrivilegeEscalation: false
          capabilities:
            drop:
            - ALL
      imagePullSecrets:
{{ toYaml .Values.scheduler.imagePullSecrets | indent 8 }}
      securityContext:
        runAsNonRoot: true
      serviceAccountName: hypo-scheduler-controller-manager
      terminationGracePeriodSeconds: 10
---
{{- if .Values.clusterSet.enabled }}
apiVersion: cluster.open-cluster-management.io/v1beta2
kind: ManagedClusterSet
metadata:
  name: {{ .Values.clusterSet.name | quote }}
---
apiVersion: cluster.open-cluster-management.io/v1beta2
kind: ManagedClusterSetBinding
metadata:
  name: {{ .Values.clusterSet.name | quote }}
  namespace: {{ .Release.Namespace }}
spec:
  clusterSet: {{ .Values.clusterSet.name | quote }}
{{- end }}
Loading