Skip to content

Instantly share code, notes, and snippets.

@just1689
Last active February 5, 2020 08:39
Show Gist options
  • Save just1689/6810ed50c084a073638c21379ca27529 to your computer and use it in GitHub Desktop.
Save just1689/6810ed50c084a073638c21379ca27529 to your computer and use it in GitHub Desktop.
CRD example
apiVersion: apiextensions.k8s.io/v1beta1
kind: CustomResourceDefinition
metadata:
# name must match the spec fields below, and be in the form: <plural>.<group>
name: cronscales.captainjustin.space
spec:
# group name to use for REST API: /apis/<group>/<version>
group: stable.captainjustin.space
# list of versions supported by this CustomResourceDefinition
versions:
- name: v1
# Each version can be enabled/disabled by Served flag.
served: true
# One and only one version must be marked as the storage version.
storage: true
# either Namespaced or Cluster
scope: Namespaced
names:
# plural name to be used in the URL: /apis/<group>/<version>/<plural>
plural: cronscales
# singular name to be used as an alias on the CLI and for display
singular: cronscale
# kind is normally the CamelCased singular type. Your resource manifests use this.
kind: CronScale
# shortNames allow shorter string to match your resource on the CLI
shortNames:
- cs
preserveUnknownFields: false
validation:
openAPIV3Schema:
type: object
properties:
spec:
type: object
properties:
cronSpec:
type: string
scaleTargetRef:
type: object
properties:
apiVersion:
type: string
kind:
type: string
name:
type: string
minReplicas:
type: integer
maxReplicas:
type: integer
targetCPUUtilizationPercentage:
type: integer
apiVersion: "captainjustins.space/v1"
kind: CronScale
metadata:
name: scale-down-at-9pm
spec:
cronSpec: "0 21 * * *"
scaleTargetRef:
apiVersion: "extensions/v1beta1"
kind: "deployment"
name: "nginx"
minReplicas: 2
maxReplicas: 4
targetCPUUtilizationPercentage: 60
---
apiVersion: "captainjustin.space/v1"
kind: CronScale
metadata:
name: scale-up-at-6am
spec:
cronSpec: "0 6 * * *"
scaleTargetRef:
apiVersion: "extensions/v1beta1"
kind: "deployment"
name: "nginx"
minReplicas: 4
maxReplicas: 8
targetCPUUtilizationPercentage: 40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment