Skip to content

Commit

Permalink
Merge branch 'master' into configmaps-to-secrets
Browse files Browse the repository at this point in the history
  • Loading branch information
kahootali committed May 6, 2019
2 parents 17c92e4 + 8c9bca6 commit ab87dcb
Show file tree
Hide file tree
Showing 9 changed files with 78 additions and 39 deletions.
2 changes: 1 addition & 1 deletion .version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v1.0.69
v1.0.71
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
apiVersion: v1
name: ingressmonitorcontroller
description: IngressMonitorController chart that runs on kubernetes
version: v1.0.69
version: v1.0.71
keywords:
- IngressMonitorController
- kubernetes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,26 +13,26 @@ ingressMonitorController:
provider: stakater
deployment:
labels:
version: "v1.0.69"
version: "v1.0.71"
annotations:
configmap.reloader.stakater.com/reload: ingressmonitorcontroller
config:
labels:
version: "v1.0.69"
version: "v1.0.71"
rbac:
create: true
# Service account config for the agent pods
serviceAccount:
# Specifies whether a ServiceAccount should be created
create: true
labels:
version: "v1.0.69"
version: "v1.0.71"
# The name of the ServiceAccount to use.
# If not set and create is true, a name is generated using the fullname template
name: ingressmonitorcontroller
image:
name: stakater/ingressmonitorcontroller
tag: "v1.0.69"
tag: "v1.0.71"
pullPolicy: IfNotPresent
configFilePath: /etc/IngressMonitorController/config.yaml
data:
Expand Down
18 changes: 9 additions & 9 deletions deployments/kubernetes/ingressmonitorcontroller.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ metadata:

labels:
app: ingressmonitorcontroller
chart: "ingressmonitorcontroller-v1.0.69"
chart: "ingressmonitorcontroller-v1.0.71"
release: "RELEASE-NAME"
heritage: "Tiller"
version: v1.0.69
version: v1.0.71

group: com.stakater.platform
provider: stakater
Expand All @@ -34,10 +34,10 @@ spec:
metadata:
labels:
app: ingressmonitorcontroller
chart: "ingressmonitorcontroller-v1.0.69"
chart: "ingressmonitorcontroller-v1.0.71"
release: "RELEASE-NAME"
heritage: "Tiller"
version: v1.0.69
version: v1.0.71

group: com.stakater.platform
provider: stakater
Expand All @@ -47,7 +47,7 @@ spec:
- env:
- name: CONFIG_FILE_PATH
value: /etc/IngressMonitorController/config.yaml
image: "stakater/ingressmonitorcontroller:v1.0.69"
image: "stakater/ingressmonitorcontroller:v1.0.71"
imagePullPolicy: IfNotPresent
name: ingressmonitorcontroller
volumeMounts:
Expand Down Expand Up @@ -117,10 +117,10 @@ metadata:
annotations:
labels:
app: ingressmonitorcontroller
chart: "ingressmonitorcontroller-v1.0.69"
chart: "ingressmonitorcontroller-v1.0.71"
release: "RELEASE-NAME"
heritage: "Tiller"
version: v1.0.69
version: v1.0.71

group: com.stakater.platform
provider: stakater
Expand All @@ -146,10 +146,10 @@ kind: ServiceAccount
metadata:
labels:
app: ingressmonitorcontroller
chart: "ingressmonitorcontroller-v1.0.69"
chart: "ingressmonitorcontroller-v1.0.71"
release: "RELEASE-NAME"
heritage: "Tiller"
version: v1.0.69
version: v1.0.71

group: com.stakater.platform
provider: stakater
Expand Down
4 changes: 2 additions & 2 deletions deployments/kubernetes/manifests/configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ metadata:
annotations:
labels:
app: ingressmonitorcontroller
chart: "ingressmonitorcontroller-v1.0.69"
chart: "ingressmonitorcontroller-v1.0.71"
release: "RELEASE-NAME"
heritage: "Tiller"
version: v1.0.69
version: v1.0.71

group: com.stakater.platform
provider: stakater
Expand Down
10 changes: 5 additions & 5 deletions deployments/kubernetes/manifests/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ metadata:

labels:
app: ingressmonitorcontroller
chart: "ingressmonitorcontroller-v1.0.69"
chart: "ingressmonitorcontroller-v1.0.71"
release: "RELEASE-NAME"
heritage: "Tiller"
version: v1.0.69
version: v1.0.71

group: com.stakater.platform
provider: stakater
Expand All @@ -31,10 +31,10 @@ spec:
metadata:
labels:
app: ingressmonitorcontroller
chart: "ingressmonitorcontroller-v1.0.69"
chart: "ingressmonitorcontroller-v1.0.71"
release: "RELEASE-NAME"
heritage: "Tiller"
version: v1.0.69
version: v1.0.71

group: com.stakater.platform
provider: stakater
Expand All @@ -44,7 +44,7 @@ spec:
- env:
- name: CONFIG_FILE_PATH
value: /etc/IngressMonitorController/config.yaml
image: "stakater/ingressmonitorcontroller:v1.0.69"
image: "stakater/ingressmonitorcontroller:v1.0.71"
imagePullPolicy: IfNotPresent
name: ingressmonitorcontroller
volumeMounts:
Expand Down
4 changes: 2 additions & 2 deletions deployments/kubernetes/manifests/serviceaccount.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ kind: ServiceAccount
metadata:
labels:
app: ingressmonitorcontroller
chart: "ingressmonitorcontroller-v1.0.69"
chart: "ingressmonitorcontroller-v1.0.71"
release: "RELEASE-NAME"
heritage: "Tiller"
version: v1.0.69
version: v1.0.71

group: com.stakater.platform
provider: stakater
Expand Down
10 changes: 9 additions & 1 deletion docs/statuscake-configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,12 @@ Currently additional Statuscake configurations can be added through a set of ann
| statuscake.monitor.stakater.com/follow-redirect | Enable ingress redirects |
| statuscake.monitor.stakater.com/port | TCP Port |
| statuscake.monitor.stakater.com/trigger-rate | Minutes to wait before sending an alert |
| statuscake.monitor.stakater.com/contact-group | Contact Group to be alerted. |
| statuscake.monitor.stakater.com/contact-group | Contact Group to be alerted. |
| statuscake.monitor.stakater.com/basic-auth-user | Required for [basic-authenticationchecks](#basic-auth-checks) |


### Basic Auth checks

Statuscake supports checks completing basic auth requirements. The annotation `statuscake.monitor.stakater.com/basic-auth-user` can be used to trigger the Ingress Monitor attempting to configure this setting. The value of the annotation should be the *username* to be configured. The Ingress Monitor Controller will then attempt to access an OS env variable of the same name which will return the *password* that should be used. The env variable can be mounted within the Ingress Monitor Controller container via a secret.

For example; the annotation `statuscake.monitor.stakater.com/basic-auth-user: 'my-service-username'` will set the username field to the value `my-service-username` and will retrieve the password via `os.Getenv('my-service-username')` and set this appropriately. If the password is not found/set the annotation will be skipped.
59 changes: 45 additions & 14 deletions pkg/monitors/statuscake/statuscake-monitor.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,25 @@ import (
log "github.com/sirupsen/logrus"
"net/http"
"net/url"
"os"
"strings"

"github.com/stakater/IngressMonitorController/pkg/config"
"github.com/stakater/IngressMonitorController/pkg/models"
)

const (
StatuscakeCheckRateAnnotation = "statuscake.monitor.stakater.com/check-rate"
StatuscakeTestTypeAnnotation = "statuscake.monitor.stakater.com/test-type"
StatuscakePausedAnnotation = "statuscake.monitor.stakater.com/paused"
StatuscakePingURLAnnotation = "statuscake.monitor.stakater.com/ping-url"
StatuscakeFollowRedirectAnnotation = "statuscake.monitor.stakater.com/follow-redirect"
StatuscakePortAnnotation = "statuscake.monitor.stakater.com/port"
StatuscakeTriggerRateAnnotation = "statuscake.monitor.stakater.com/trigger-rate"
StatuscakeContactGroupAnnotation = "statuscake.monitor.stakater.com/contact-group"
StatuscakeBasicAuthUserAnnotation = "statuscake.monitor.stakater.com/basic-auth-user"
)

// StatusCakeMonitorService is the service structure for StatusCake
type StatusCakeMonitorService struct {
apiKey string
Expand All @@ -30,40 +43,58 @@ type AnnotationInfo struct {

// AnnotationMap holds all the enabled annotations for StatusCake
var AnnotationMap = map[string]AnnotationInfo{
"statuscake.monitor.stakater.com/check-rate": AnnotationInfo{"CheckRate", "int"}, // Int (0-24000)
"statuscake.monitor.stakater.com/test-type": AnnotationInfo{"TestType", "string"}, // String (HTTP, TCP, PING)
"statuscake.monitor.stakater.com/paused": AnnotationInfo{"Paused", "bool"}, // Int (0,1)
"statuscake.monitor.stakater.com/ping-url": AnnotationInfo{"PingURL", "string"}, // String (url)
"statuscake.monitor.stakater.com/follow-redirect": AnnotationInfo{"FollowRedirect", "bool"}, // Int (0,1)
"statuscake.monitor.stakater.com/port": AnnotationInfo{"Port", "int"}, // Int (TCP Port)
"statuscake.monitor.stakater.com/trigger-rate": AnnotationInfo{"TriggerRate", "int"}, // Int (0-60)
"statuscake.monitor.stakater.com/contact-group": AnnotationInfo{"ContactGroup", "string"}} // String (0-60)
StatuscakeCheckRateAnnotation: AnnotationInfo{"CheckRate", "int"}, // Int (0-24000)
StatuscakeTestTypeAnnotation: AnnotationInfo{"TestType", "string"}, // String (HTTP, TCP, PING)
StatuscakePausedAnnotation: AnnotationInfo{"Paused", "bool"}, // Int (0,1)
StatuscakePingURLAnnotation: AnnotationInfo{"PingURL", "string"}, // String (url)
StatuscakeFollowRedirectAnnotation: AnnotationInfo{"FollowRedirect", "bool"}, // Int (0,1)
StatuscakePortAnnotation: AnnotationInfo{"Port", "int"}, // Int (TCP Port)
StatuscakeTriggerRateAnnotation: AnnotationInfo{"TriggerRate", "int"}, // Int (0-60)
StatuscakeContactGroupAnnotation: AnnotationInfo{"ContactGroup", "string"}, // String (0-60)
StatuscakeBasicAuthUserAnnotation: AnnotationInfo{"BasicUser", "string"}, // String (0-60)
}

// buildUpsertForm function is used to create the form needed to Add or update a monitor
func buildUpsertForm(m models.Monitor, cgroup string) url.Values {
f := url.Values{}
f.Add("WebsiteName", m.Name)
f.Add("WebsiteURL", m.URL)
if val, ok := m.Annotations["monitor.stakater.com/statuscake-check-rate"]; ok {
if val, ok := m.Annotations[StatuscakeCheckRateAnnotation]; ok {
f.Add("CheckRate", val)
delete(m.Annotations, "monitor.stakater.com/statuscake-check-rate")
delete(m.Annotations, StatuscakeCheckRateAnnotation)
} else {
f.Add("CheckRate", "300")
}
if val, ok := m.Annotations["monitor.stakater.com/statuscake-test-type"]; ok {
if val, ok := m.Annotations[StatuscakeTestTypeAnnotation]; ok {
f.Add("TestType", val)
delete(m.Annotations, "monitor.stakater.com/statuscake-test-type")
delete(m.Annotations, StatuscakeTestTypeAnnotation)
} else {
f.Add("TestType", "HTTP")
}
if val, ok := m.Annotations["monitor.stakater.com/statuscake-contact-group"]; ok {
if val, ok := m.Annotations[StatuscakeContactGroupAnnotation]; ok {
f.Add("ContactGroup", val)
delete(m.Annotations, "monitor.stakater.com/statuscake-contact-group")
delete(m.Annotations, StatuscakeContactGroupAnnotation)
} else {
if cgroup != "" {
f.Add("ContactGroup", cgroup)
}
}
// If a basic auth annotation is set
if val, ok := m.Annotations[StatuscakeBasicAuthUserAnnotation]; ok {
// Annotation should be set to the username
// Environment variable should define the password
// Mounted via a secret; key is the username, value is the password
basicPass := os.Getenv(val)
if basicPass != "" {
f.Add("BasicUser", val)
f.Add("BasicPass", basicPass)
log.Println("Basic auth requirement detected. Setting username and password")
} else {
log.Println("Error reading basic auth password from environment variable")
}
delete(m.Annotations, StatuscakeBasicAuthUserAnnotation)
}

for key, value := range m.Annotations {
if (AnnotationInfo{}) != AnnotationMap[key] {
meta := AnnotationMap[key]
Expand Down

0 comments on commit ab87dcb

Please sign in to comment.