Here (click the triangle to expand) is an example JSON for
426 | Kubernetes health checks.
427 |
428 | ```json
429 | {
430 | "healthchecks": {
431 | "web": {
432 | "readiness": {
433 | "httpGet": {
434 | "path": "/{{ $APP }}/readiness_check",
435 | "port": 5000
436 | },
437 | "initialDelaySeconds": 5,
438 | "periodSeconds": 5
439 | }
440 | },
441 | "*": {
442 | "liveness": {
443 | "exec": {
444 | "command": ["/bin/pidof", "/start"]
445 | },
446 | "initialDelaySeconds": 5,
447 | "periodSeconds": 5
448 | },
449 | "readiness": {
450 | "httpGet": {
451 | "path": "web processes override this.",
452 | "port": 5000
453 | },
454 | "initialDelaySeconds": 5,
455 | "periodSeconds": 5
456 | }
457 | }
458 | }
459 | }
460 | ```
461 |
462 |
463 | ## Plugin Triggers
464 |
465 | The following custom triggers are exposed by the plugin:
466 |
467 | ### `post-deploy-kubernetes-apply`
468 |
469 | - Description: Allows a user to interact with the `deployment` manifest after it has been submitted.
470 | - Invoked by:
471 | - Arguments: `$APP` `$PROC_TYPE` `$MANIFEST_FILE` `$MANIFEST_TYPE`
472 | - Example:
473 |
474 | ```shell
475 | #!/usr/bin/env bash
476 |
477 | set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
478 |
479 | # TODO
480 | ```
481 |
482 | ### `pre-ingress-kubernetes-apply`
483 |
484 | - Description: Allows a user to interact with the `ingress` manifest before it has been submitted.
485 | - Invoked by: `core-post-deploy`, `post-domains-update`, `post-proxy-ports-update`, and `proxy-build-config` triggers
486 | - Arguments: `$APP` `$MANIFEST_FILE`
487 | - Example:
488 |
489 | ```shell
490 | #!/usr/bin/env bash
491 |
492 | set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
493 |
494 | # TODO
495 | ```
496 |
497 | ### `pre-deploy-kubernetes-apply`
498 |
499 | - Description: Allows a user to interact with the `deployment|service` manifest before it has been submitted.
500 | - Invoked by: `scheduler-deploy` trigger and `:show-manifest`
501 | - Arguments: `$APP` `$PROC_TYPE` `$MANIFEST_FILE` `$MANIFEST_TYPE`
502 | - Example:
503 |
504 | ```shell
505 | #!/usr/bin/env bash
506 |
507 | set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
508 |
509 | # TODO
510 | ```
511 |
--------------------------------------------------------------------------------
/internal-functions:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
3 | source "$PLUGIN_CORE_AVAILABLE_PATH/common/property-functions"
4 | source "$PLUGIN_AVAILABLE_PATH/config/functions"
5 | source "$PLUGIN_AVAILABLE_PATH/domains/functions"
6 | set -eo pipefail
7 | [[ $DOKKU_TRACE ]] && set -x
8 |
9 | cmd-scheduler-kubernetes-rolling-update() {
10 | declare desc="force a rolling update"
11 | declare cmd="scheduler-kubernetes:rolling-update" argv=("$@")
12 | [[ ${argv[0]} == "$cmd" ]] && shift 1
13 | declare APP="$1"
14 |
15 | verify_app_name "$APP"
16 | local DOKKU_SCHEDULER=$(get_app_scheduler "$APP")
17 | if [[ "$DOKKU_SCHEDULER" != "kubernetes" ]]; then
18 | dokku_log_fail "Scheduler for $APP is set to $DOKKU_SCHEDULER"
19 | return 1
20 | fi
21 |
22 | export KUBECONFIG="${DOKKU_ROOT}/.kube/config"
23 | export KUBEDOG_KUBE_CONFIG="${DOKKU_ROOT}/.kube/config"
24 | KUBE_ARGS=()
25 | NAMESPACE="$(fn-plugin-property-get "scheduler-kubernetes" "$APP" "namespace" "default")"
26 | KUBE_ARGS+=("--namespace=$NAMESPACE")
27 | fn-scheduler-kubernetes-ensure-namespace "$NAMESPACE" >/dev/null
28 |
29 | dokku_log_info1 "Triggering rolling-update for $APP"
30 | while read -r line || [[ -n "$line" ]]; do
31 | [[ "$line" =~ ^#.* ]] && continue
32 | line="$(strip_inline_comments "$line")"
33 | PROC_TYPE=${line%%=*}
34 |
35 | "${DOKKU_LIB_ROOT}/data/scheduler-kubernetes/kubectl" "${KUBE_ARGS[@]}" patch deployment "${APP}-${PROC_TYPE}" --patch "{\"spec\":{\"template\":{\"metadata\":{\"labels\":{\"dokku.com/rolling-update-time\":\"$(date -u "+%Y-%m-%d-%H-%M-%S")\"}}}}}" | sed "s/^/ /"
36 | done < <(plugin trigger ps-current-scale "$APP")
37 | }
38 |
39 | cmd-scheduler-kubernetes-report() {
40 | declare desc="displays a scheduler-kubernetes report for one or more apps"
41 | declare cmd="scheduler-kubernetes:report"
42 | local INSTALLED_APPS=$(dokku_apps)
43 | local APP="$2" INFO_FLAG="$3"
44 |
45 | if [[ -n "$APP" ]] && [[ "$APP" == --* ]]; then
46 | INFO_FLAG="$APP"
47 | APP=""
48 | fi
49 |
50 | if [[ -z "$APP" ]] && [[ -z "$INFO_FLAG" ]]; then
51 | INFO_FLAG="true"
52 | fi
53 |
54 | if [[ -z "$APP" ]]; then
55 | for app in $INSTALLED_APPS; do
56 | cmd-scheduler-kubernetes-report-single "$app" "$INFO_FLAG" | tee || true
57 | done
58 | else
59 | cmd-scheduler-kubernetes-report-single "$APP" "$INFO_FLAG"
60 | fi
61 | }
62 |
63 | cmd-scheduler-kubernetes-report-single() {
64 | declare APP="$1" INFO_FLAG="$2"
65 | if [[ "$INFO_FLAG" == "true" ]]; then
66 | INFO_FLAG=""
67 | fi
68 | verify_app_name "$APP"
69 | local flag_map=(
70 | "--scheduler-kubernetes-cert-manager-enabled: $(fn-plugin-property-get "scheduler-kubernetes" "$APP" "cert-manager-enabled" "")"
71 | "--scheduler-kubernetes-imagePullSecrets: $(fn-plugin-property-get "scheduler-kubernetes" "$APP" "imagePullSecrets" "")"
72 | "--scheduler-kubernetes-ingress-enabled: $(fn-plugin-property-get "scheduler-kubernetes" "$APP" "ingress-enabled" "false")"
73 | "--scheduler-kubernetes-namespace: $(fn-plugin-property-get "scheduler-kubernetes" "$APP" "namespace" "")"
74 | "--scheduler-kubernetes-pod-max-unavailable: $(fn-plugin-property-get "scheduler-kubernetes" "$APP" "pod-max-unavailable" "")"
75 | "--scheduler-kubernetes-pod-min-available: $(fn-plugin-property-get "scheduler-kubernetes" "$APP" "pod-min-available" "")"
76 | "--scheduler-kubernetes-service-process-types: $(fn-plugin-property-get "scheduler-kubernetes" "$APP" "service-process-types" "")"
77 | )
78 |
79 | if [[ -z "$INFO_FLAG" ]]; then
80 | dokku_log_info2_quiet "${APP} scheduler-kubernetes information"
81 | for flag in "${flag_map[@]}"; do
82 | key="$(echo "${flag#--}" | cut -f1 -d' ' | tr - ' ')"
83 | dokku_log_verbose "$(printf "%-30s %-25s" "${key^}" "${flag#*: }")"
84 | done
85 | else
86 | local match=false
87 | local value_exists=false
88 | for flag in "${flag_map[@]}"; do
89 | valid_flags="${valid_flags} $(echo "$flag" | cut -d':' -f1)"
90 | if [[ "$flag" == "${INFO_FLAG}:"* ]]; then
91 | value=${flag#*: }
92 | size="${#value}"
93 | if [[ "$size" -ne 0 ]]; then
94 | echo "$value" && match=true && value_exists=true
95 | else
96 | match=true
97 | fi
98 | fi
99 | done
100 | [[ "$match" == "true" ]] || dokku_log_fail "Invalid flag passed, valid flags:${valid_flags}"
101 | [[ "$value_exists" == "true" ]] || echo ""
102 | fi
103 | }
104 |
105 | scheduler_docker_local_help_content_func() {
106 | declare desc="return scheduler-kubernetes plugin help content"
107 | cat <