Last active
September 3, 2021 13:11
-
-
Save kanedafromparis/69244e4e6a70143ee60a2eb1b6be452e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## | |
# kubectl apply -f all-in-one.yaml | |
# # might need to be apply twice | |
# kubectl apply -f all-in-one.yaml | |
### | |
# # you can check with the following commandes | |
### | |
# kubectl --as=system:serviceaccount:shyrka-erebus-operators:shyrka-erebus get ns | |
# kubectl --as=system:serviceaccount:shyrka-erebus-operators:shyrka-erebus get hypnos | |
###-- | |
# HYPNOS_TARGET_NS=$(kubectl --as=system:serviceaccount:shyrka-erebus-operators:shyrka-erebus get ns -l io.shyrka.erebus/hypnos=sample010 -o name| cut -d '/' -f 2 |head -n 1) | |
# HYPNOS_TARGET_DEPLOY=$(kubectl --as=system:serviceaccount:shyrka-erebus-operators:shyrka-erebus get deploy -l io.shyrka.erebus/hypnos=sample -n $HYPNOS_TARGET_NS -o name |head -n 1) | |
# kubectl -n $HYPNOS_TARGET_NS get deploy | |
# kubectl --as=system:serviceaccount:shyrka-erebus-operators:shyrka-erebus scale --replicas=2 $HYPNOS_TARGET_DEPLOY -n $HYPNOS_TARGET_NS | |
# kubectl -n $HYPNOS_TARGET_NS get deploy | |
# | |
##### | |
apiVersion: v1 | |
kind: Namespace | |
metadata: | |
name: shyrka-erebus-operators | |
labels: | |
io.shyrka: "" | |
io.shyrka.erebus/hypnos: "v1alpha1" | |
app: shyrka-erebus | |
--- | |
apiVersion: apiextensions.k8s.io/v1 | |
kind: CustomResourceDefinition | |
metadata: | |
labels: | |
io.shyrka: "" | |
io.shyrka.erebus/hypnos: "v1alpha1" | |
app: shyrka-erebus | |
name: hypnox.shyrkaio.github.io | |
namespace: shyrka-erebus-operators | |
spec: | |
group: shyrkaio.github.io | |
names: | |
kind: Hypnos | |
listKind: HypnosList | |
plural: hypnox | |
singular: hypnos | |
scope: Cluster | |
versions: | |
- name: v1alpha1 | |
# 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 | |
schema: | |
openAPIV3Schema: | |
#https://swagger.io/docs/specification/data-models/data-types/ | |
type: object | |
properties: | |
spec: | |
type: object | |
properties: | |
namespaceTargetedLabel: | |
type: string | |
nullable: false | |
#@TODO pattern: ... or switch to a match selector | |
targetedLabel: | |
type: string | |
nullable: true | |
#@TODO pattern: ... or switch to a match selector | |
resourceType: | |
type: array | |
nullable: false | |
items: | |
type: string | |
enum: [Deployment, StatefulSet] | |
cron-type: | |
type: string | |
enum: [unix, quartz] | |
default: quartz | |
wakeup-cron: | |
nullable: false | |
type: string | |
pattern: '(((\d+,)+\d+|(\d+(\/|-)\d+)|\d+|\*) ?){5,7}' | |
# I wonder if a default is a good idea | |
#default: "5 0 * * *" | |
sleep-cron: | |
type: string | |
nullable: false | |
pattern: '(((\d+,)+\d+|(\d+(\/|-)\d+)|\d+|\*) ?){5,7}' | |
# I wonder if a default is is a good idea | |
#default: "5 0 * * *" | |
load-policy: # not-implemented-yet | |
type: string | |
enum: [run-sleep-on-change, run-wake-up-on-change, no-action] | |
default: no-action | |
dry-run: # not-implemented-yet | |
type: boolean | |
default: false | |
pause: # not-implemented-yet | |
type: boolean #pause: not-implemented-yet | |
default: false | |
comments: | |
type: string | |
maxLength: 256 | |
status: | |
type: object | |
properties: | |
lastRun: | |
type: string | |
format: date-time | |
nbtarget: | |
type: integer | |
additionalPrinterColumns: | |
- name: NameSpace Targeted Label | |
type: string | |
description: The label used to select targeted namespace | |
jsonPath: .spec.namespaceTargetedLabel | |
- name: Targeted Label | |
type: string | |
description: The label used to select resource to touch | |
jsonPath: .spec.targetedLabel | |
- name: Resource | |
type: string | |
description: The resource type to be scale up / scale down | |
jsonPath: .spec.resourceType | |
- name: WakeUp | |
type: string | |
description: The Cron Definition for the wake-up call | |
jsonPath: .spec.wakeup-cron | |
- name: Sleep | |
type: string | |
description: The Cron Definition for the sleep call | |
jsonPath: .spec.sleep-cron | |
- name: comments | |
type: string | |
description: some comments on this hypnos definition | |
jsonPath: .spec.comments | |
--- | |
apiVersion: rbac.authorization.k8s.io/v1 | |
kind: ClusterRole | |
metadata: | |
name: erebus | |
labels: | |
io.shyrka: "" | |
io.shyrka.erebus/hypnos: "v1alpha1" | |
app: shyrka-erebus | |
rules: | |
- apiGroups: [""] | |
resources: ["namespaces"] | |
verbs: ["list"] | |
- apiGroups: ["extensions","apps"] | |
resources: ["deployments"] | |
verbs: ["list", "get", "update"] | |
- apiGroups: ["extensions","apps"] | |
resources: ["statefulsets"] | |
verbs: ["list", "get", "update"] | |
- apiGroups: [""] | |
resources: ["events"] | |
verbs: ["create"] | |
- apiGroups: ["shyrkaio.github.io"] | |
resources: ["hypnox"] | |
verbs: ["watch","list", "update"] | |
--- | |
apiVersion: v1 | |
kind: ServiceAccount | |
metadata: | |
annotations: | |
app.quarkus.io/vcs-url: https://github.com/shyrkaio/erebus.git | |
app.quarkus.io/build-timestamp: 2020-10-19 - 16:03:56 +0000 | |
app.quarkus.io/commit-id: 4a2ef82de2b7bdfa7a40468b0acc1d56e98a56dd | |
labels: | |
app.kubernetes.io/name: erebus-operator | |
app.kubernetes.io/version: 1.0.0-SNAPSHOT | |
name: shyrka-erebus | |
namespace: shyrka-erebus-operators | |
--- | |
apiVersion: v1 | |
kind: Service | |
metadata: | |
annotations: | |
app.quarkus.io/vcs-url: https://github.com/shyrkaio/erebus.git | |
app.quarkus.io/build-timestamp: 2020-10-19 - 16:03:56 +0000 | |
app.quarkus.io/commit-id: 4a2ef82de2b7bdfa7a40468b0acc1d56e98a56dd | |
labels: | |
app.kubernetes.io/name: erebus-operator | |
app.kubernetes.io/version: 1.0.0-SNAPSHOT | |
name: erebus-operator | |
namespace: shyrka-erebus-operators | |
spec: | |
ports: | |
- name: http | |
port: 8080 | |
targetPort: 8080 | |
selector: | |
app.kubernetes.io/name: erebus-operator | |
app.kubernetes.io/version: 1.0.0-SNAPSHOT | |
type: ClusterIP | |
--- | |
apiVersion: rbac.authorization.k8s.io/v1 | |
kind: ClusterRoleBinding | |
metadata: | |
name: erebus | |
labels: | |
io.shyrka: "" | |
io.shyrka.erebus/hypnos: "v1alpha1" | |
app: shyrka-erebus | |
roleRef: | |
apiGroup: rbac.authorization.k8s.io | |
kind: ClusterRole | |
name: erebus | |
subjects: | |
- kind: ServiceAccount | |
name: shyrka-erebus | |
namespace: shyrka-erebus-operators | |
--- | |
apiVersion: apps/v1 | |
kind: Deployment | |
metadata: | |
annotations: | |
app.quarkus.io/vcs-url: https://github.com/shyrkaio/erebus.git | |
app.quarkus.io/build-timestamp: 2020-10-19 - 16:03:56 +0000 | |
app.quarkus.io/commit-id: 4a2ef82de2b7bdfa7a40468b0acc1d56e98a56dd | |
labels: | |
app.kubernetes.io/name: erebus-operator | |
app.kubernetes.io/version: 1.0.0-SNAPSHOT | |
name: erebus-operator | |
namespace: shyrka-erebus-operators | |
spec: | |
replicas: 1 | |
selector: | |
matchLabels: | |
app.kubernetes.io/name: erebus-operator | |
app.kubernetes.io/version: 1.0.0-SNAPSHOT | |
template: | |
metadata: | |
annotations: | |
app.quarkus.io/vcs-url: https://github.com/shyrkaio/erebus.git | |
app.quarkus.io/build-timestamp: 2020-10-19 - 16:03:56 +0000 | |
app.quarkus.io/commit-id: 4a2ef82de2b7bdfa7a40468b0acc1d56e98a56dd | |
labels: | |
app: erebus-operator | |
app.kubernetes.io/name: erebus-operator | |
app.kubernetes.io/version: 1.0.0-SNAPSHOT | |
spec: | |
containers: | |
- env: | |
- name: JAVA_ENABLE_DEBUG | |
value: "true" | |
- name: KUBERNETES_NAMESPACE | |
valueFrom: | |
fieldRef: | |
fieldPath: metadata.namespace | |
- name: HOSTNAME | |
valueFrom: | |
fieldRef: | |
apiVersion: v1 | |
fieldPath: metadata.name | |
image: quay.io/shyrkaio/erebus-operator:20201019163022 | |
imagePullPolicy: Always | |
name: quarkus | |
ports: | |
- containerPort: 8080 | |
name: http | |
protocol: TCP | |
serviceAccount: shyrka-erebus | |
--- | |
apiVersion: v1 | |
kind: Namespace | |
metadata: | |
name: hypnos-smp-010 | |
labels: | |
app: hypnos-010 | |
io.shyrka.erebus/hypnos: "sample010" | |
io.shyrka.erebus/role: "test" | |
spec: | |
finalizers: | |
- kubernetes | |
status: | |
phase: Active | |
--- | |
apiVersion: apps/v1 | |
kind: Deployment | |
metadata: | |
annotations: | |
deployment.kubernetes.io/revision: "1" | |
#io.shyrka.erebus.hypnos/skipCron: "true" | |
generation: 1 | |
labels: | |
io.shyrka.erebus/hypnos: "sample" | |
io.shyrka.erebus/role: "test" | |
app: hypnos-010 | |
name: hypnos-010 | |
namespace: hypnos-smp-010 | |
spec: | |
progressDeadlineSeconds: 100 | |
replicas: 3 | |
revisionHistoryLimit: 10 | |
selector: | |
matchLabels: | |
app: hypnos-010 | |
strategy: | |
rollingUpdate: | |
maxSurge: 25% | |
maxUnavailable: 25% | |
type: RollingUpdate | |
template: | |
metadata: | |
creationTimestamp: null | |
labels: | |
app: hypnos-010 | |
spec: | |
containers: | |
- image: quay.io/kanedafromparis/nginx:ocp-0.3 | |
imagePullPolicy: IfNotPresent | |
name: nginx | |
resources: | |
requests: | |
cpu: 200m | |
memory: 16M | |
limits: | |
cpu: 250m | |
memory: 24M | |
terminationMessagePath: /dev/termination-log | |
terminationMessagePolicy: File | |
ports: | |
- containerPort: 8080 | |
protocol: TCP | |
dnsPolicy: ClusterFirst | |
restartPolicy: Always | |
schedulerName: default-scheduler | |
securityContext: {} | |
terminationGracePeriodSeconds: 5 | |
--- | |
apiVersion: shyrkaio.github.io/v1alpha1 | |
kind: Hypnos | |
metadata: | |
name: test-011 | |
labels: | |
io.shyrka.erebus/hypnos: "sample010" | |
io.shyrka.erebus/role: "test" | |
annotations: | |
io.shyrkaio.github.erebus/hypnos: "{}" | |
spec: | |
namespaceTargetedLabel: "io.shyrka.erebus/hypnos=sample010" | |
targetedLabel: "io.shyrka.erebus/hypnos=sample" | |
resourceType: | |
- "Deployment" | |
# this is for testing regular cron should be | |
wakeup-cron: "0/5 * * * *" | |
sleep-cron: "0/2 * * * *" | |
#not-implemented-yet | |
load-policy: no-action #not-implemented-yet | |
dry-run: false | |
pause: false #not-implemented-yet | |
comments: "just a simple comments" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
you can also do :