-
Notifications
You must be signed in to change notification settings - Fork 111
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[okmeter] pull and update image based on tag
- Loading branch information
Showing
17 changed files
with
198 additions
and
56 deletions.
There are no files selected for viewing
1 change: 1 addition & 0 deletions
1
deckhouse-controller/cmd/deckhouse-controller/register-go-hooks.go
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
/* | ||
Copyright 2021 Flant JSC | ||
Licensed under the Deckhouse Platform Enterprise Edition (EE) license. See https://github.com/deckhouse/deckhouse/blob/main/ee/LICENSE | ||
*/ | ||
|
||
package hooks | ||
|
||
import ( | ||
"testing" | ||
|
||
. "github.com/onsi/ginkgo" | ||
. "github.com/onsi/gomega" | ||
) | ||
|
||
func Test(t *testing.T) { | ||
RegisterFailHandler(Fail) | ||
RunSpecs(t, "") | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
/* | ||
Copyright 2021 Flant JSC | ||
Licensed under the Deckhouse Platform Enterprise Edition (EE) license. See https://github.com/deckhouse/deckhouse/blob/main/ee/LICENSE | ||
*/ | ||
|
||
package hooks | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/flant/addon-operator/pkg/module_manager/go_hook" | ||
"github.com/flant/addon-operator/sdk" | ||
|
||
"github.com/deckhouse/deckhouse/go_lib/dependency" | ||
"github.com/deckhouse/deckhouse/go_lib/dependency/cr" | ||
) | ||
|
||
var _ = sdk.RegisterFunc(&go_hook.HookConfig{ | ||
Queue: "/modules/okmeter/check_release", | ||
OnBeforeHelm: &go_hook.OrderedConfig{Order: 5}, | ||
Schedule: []go_hook.ScheduleConfig{ | ||
{ | ||
Name: "check_okmeter_release", | ||
Crontab: "* * * * *", // every minute | ||
}, | ||
}, | ||
}, dependency.WithExternalDependencies(checkRelease)) | ||
|
||
func checkRelease(input *go_hook.HookInput, dc dependency.Container) error { | ||
repo := input.ConfigValues.Get("okmeter.image.repository").String() | ||
if repo == "" { | ||
repo = "registry.okmeter.io/agent/okagent" | ||
} | ||
tag := input.ConfigValues.Get("okmeter.image.tag").String() | ||
if tag == "" { | ||
tag = "latest" | ||
} | ||
|
||
regCli, err := dc.GetRegistryClient(repo, cr.WithDisabledAuth()) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
imageHash, err := regCli.Digest(tag) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
previousHash := input.Values.Get("okmeter.internal.currentReleaseImageHash").String() | ||
|
||
if previousHash == imageHash { | ||
return nil | ||
} | ||
|
||
currentImage := fmt.Sprintf("%s@%s", repo, imageHash) | ||
|
||
input.Values.Set("okmeter.internal.currentReleaseImage", currentImage) | ||
input.Values.Set("okmeter.internal.currentReleaseImageHash", imageHash) | ||
|
||
return nil | ||
} |
This file was deleted.
Oops, something went wrong.
21 changes: 21 additions & 0 deletions
21
ee/fe/modules/500-okmeter/monitoring/prometheus-rules/alerting.yaml
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
- name: d8.okmeter.availability | ||
rules: | ||
- alert: D8OkmeterAgentPodIsNotReady | ||
expr: | | ||
min by (pod) ( | ||
kube_controller_pod{namespace="d8-okmeter", controller_type="DaemonSet", controller_name="okmeter"} | ||
* on (pod) group_right() kube_pod_status_ready{condition="true", namespace="d8-okmeter"} | ||
) != 1 | ||
for: 1m | ||
labels: | ||
severity_level: "6" | ||
tier: cluster | ||
d8_module: okmeter | ||
d8_component: agent | ||
annotations: | ||
plk_protocol_version: "1" | ||
plk_markup_format: "markdown" | ||
plk_pending_until_firing_for: "5m" | ||
plk_grouped_by__d8_okmeter_unavailable: "D8OkmeterUnavailable,tier=cluster,prometheus=deckhouse" | ||
plk_labels_as_annotations: "pod" | ||
summary: Okmeter agent is not Ready |
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
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
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
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
This file was deleted.
Oops, something went wrong.
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
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
Oops, something went wrong.