Revert "Pass communication settings as a k8s secret (#226)" (#232)

This reverts commit 8b2e0f9ba5.
This commit is contained in:
Prasad Ghangal 2019-12-19 15:54:10 +05:30 committed by GitHub
parent 8b2e0f9ba5
commit e6b38ad667
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 117 additions and 181 deletions

View File

@ -178,28 +178,7 @@ data:
# about the best practices for the created resource
recommendations: true
# Setting to support multiple clusters
settings:
# Cluster name to differentiate incoming messages
clustername: not-configured
# Set true to enable kubectl commands execution
allowkubectl: false
# Set true to enable config watcher
configwatcher: true
# Set false to disable upgrade notification
upgradeNotifier: true
---
# secret
apiVersion: v1
kind: Secret
metadata:
name: botkube-communication-secret
labels:
app: botkube
type: Opaque
stringData:
comm_config.yaml: |
# Communication settings
# Channels configuration
communications:
# Settings for Slack
slack:
@ -234,6 +213,18 @@ stringData:
webhook:
enabled: false
url: 'WEBHOOK_URL' # e.g https://example.com:80
# Setting to support multiple clusters
settings:
# Cluster name to differentiate incoming messages
clustername: not-configured
# Set true to enable kubectl commands execution
allowkubectl: false
# Set true to enable config watcher
configwatcher: true
# Set false to disable upgrade notification
upgradeNotifier: true
---
# serviceaccount
apiVersion: v1
@ -275,7 +266,7 @@ subjects:
apiVersion: v1
kind: Secret
metadata:
name: botkube-certificate-secret
name: botkube-secret
labels:
app: botkube
data:
@ -322,15 +313,11 @@ spec:
value: v0.9.1
volumes:
- name: config-volume
projected:
sources:
- configMap:
name: botkube-configmap
- secret:
name: botkube-communication-secret
configMap:
name: botkube-configmap
- name: certs
secret:
secretName: botkube-certificate-secret
secretName: botkube-secret
# run as non privilaged user
securityContext:
runAsUser: 101

View File

@ -179,28 +179,7 @@ data:
# about the best practices for the created resource
recommendations: true
# Setting to support multiple clusters
settings:
# Cluster name to differentiate incoming messages
clustername: not-configured
# Set true to enable kubectl commands execution
allowkubectl: false
# Set true to enable config watcher
configwatcher: true
# Set false to disable upgrade notification
upgradeNotifier: true
---
# secret
apiVersion: v1
kind: Secret
metadata:
name: botkube-communication-secret
labels:
app: botkube
type: Opaque
stringData:
comm_config.yaml: |
# Communication settings
# Channels configuration
communications:
# Settings for Slack
slack:
@ -235,6 +214,17 @@ stringData:
webhook:
enabled: false
url: 'WEBHOOK_URL' # e.g https://example.com:80
# Setting to support multiple clusters
settings:
# Cluster name to differentiate incoming messages
clustername: not-configured
# Set true to enable kubectl commands execution
allowkubectl: false
# Set true to enable config watcher
configwatcher: true
# Set false to disable upgrade notification
upgradeNotifier: true
---
# serviceaccount
apiVersion: v1
@ -311,12 +301,8 @@ spec:
value: v0.9.1
volumes:
- name: config-volume
projected:
sources:
- configMap:
name: botkube-configmap
- secret:
name: botkube-communication-secret
configMap:
name: botkube-configmap
# run as non privilaged user
securityContext:
runAsUser: 101

View File

@ -1,16 +0,0 @@
apiVersion: v1
kind: Secret
metadata:
name: {{ include "botkube.fullname" . }}-communication-secret
labels:
app.kubernetes.io/name: {{ include "botkube.name" . }}
helm.sh/chart: {{ include "botkube.chart" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
stringData:
comm_config.yaml: |
# Communication settings
communications:
{{- with .Values.communications }}
{{- toYaml . | nindent 4 }}
{{- end }}

View File

@ -8,7 +8,7 @@ metadata:
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
data:
resource_config.yaml: |
config.yaml: |
{{- with .Values.config }}
{{- toYaml . | nindent 4 }}
{{- end }}

View File

@ -52,16 +52,12 @@ spec:
{{- end }}
volumes:
- name: config-volume
projected:
sources:
- configMap:
name: {{ include "botkube.fullname" . }}-configmap
- secret:
name: {{ include "botkube.fullname" . }}-communication-secret
configMap:
name: {{ include "botkube.fullname" . }}-configmap
{{- if .Values.config.ssl.enabled }}
- name: certs
secret:
secretName: {{ include "botkube.fullname" . }}-certificate-secret
secretName: {{ include "botkube.fullname" . }}-secret
{{ end }}
{{- if .Values.securityContext }}
securityContext:

View File

@ -3,7 +3,7 @@
apiVersion: v1
kind: Secret
metadata:
name: {{ include "botkube.fullname" . }}-certificate-secret
name: {{ include "botkube.fullname" . }}-secret
labels:
app.kubernetes.io/name: {{ include "botkube.name" . }}
helm.sh/chart: {{ include "botkube.chart" . }}

View File

@ -202,6 +202,43 @@ config:
enabled: false # Set to true and specify cert path in the next line after uncommenting
#cert: # SSL Certificate file e.g certs/my-cert.crt
# Channels configuration
communications:
# Settings for Slack
slack:
enabled: false
channel: 'SLACK_CHANNEL' # Slack channel name without '#' prefix where you have added BotKube and want to receive notifications in
token: 'SLACK_API_TOKEN'
notiftype: short # Change notification type short/long you want to receive. notiftype is optional and Default notification type is short (if not specified)
# Settings for Mattermost
mattermost:
enabled: false
url: 'MATTERMOST_SERVER_URL' # URL where Mattermost is running. e.g https://example.com:9243
token: 'MATTERMOST_TOKEN' # Personal Access token generated by BotKube user
team: 'MATTERMOST_TEAM' # Mattermost Team to configure with BotKube
channel: 'MATTERMOST_CHANNEL' # Mattermost Channel for receiving BotKube alerts
notiftype: short # Change notification type short/long you want to receive. notiftype is optional and Default notification type is short (if not specified)
# Settings for ELS
elasticsearch:
enabled: false
server: 'ELASTICSEARCH_ADDRESS' # e.g https://example.com:9243
username: 'ELASTICSEARCH_USERNAME'
password: 'ELASTICSEARCH_PASSWORD'
# ELS index settings
index:
name: botkube
type: botkube-event
shards: 1
replicas: 0
# Settings for Webhook
webhook:
enabled: false
url: 'WEBHOOK_URL' # e.g https://example.com:80
# Setting to support multiple clusters
settings:
# Cluster name to differentiate incoming messages
@ -213,42 +250,6 @@ config:
# Set false to disable upgrade notification
upgradeNotifier: true
# Communication settings
communications:
# Settings for Slack
slack:
enabled: false
channel: 'SLACK_CHANNEL' # Slack channel name without '#' prefix where you have added BotKube and want to receive notifications in
token: 'SLACK_API_TOKEN'
notiftype: short # Change notification type short/long you want to receive. notiftype is optional and Default notification type is short (if not specified)
# Settings for Mattermost
mattermost:
enabled: false
url: 'MATTERMOST_SERVER_URL' # URL where Mattermost is running. e.g https://example.com:9243
token: 'MATTERMOST_TOKEN' # Personal Access token generated by BotKube user
team: 'MATTERMOST_TEAM' # Mattermost Team to configure with BotKube
channel: 'MATTERMOST_CHANNEL' # Mattermost Channel for receiving BotKube alerts
notiftype: short # Change notification type short/long you want to receive. notiftype is optional and Default notification type is short (if not specified)
# Settings for ELS
elasticsearch:
enabled: false
server: 'ELASTICSEARCH_ADDRESS' # e.g https://example.com:9243
username: 'ELASTICSEARCH_USERNAME'
password: 'ELASTICSEARCH_PASSWORD'
# ELS index settings
index:
name: botkube
type: botkube-event
shards: 1
replicas: 0
# Settings for Webhook
webhook:
enabled: false
url: 'WEBHOOK_URL' # e.g https://example.com:80
service:
name: metrics
port: 2112

View File

@ -34,11 +34,8 @@ const (
// EventType to watch
type EventType string
// ResourceConfigFileName is a name of botkube resource configuration file
var ResourceConfigFileName = "resource_config.yaml"
// CommunicationConfigFileName is a name of botkube communication configuration file
var CommunicationConfigFileName = "comm_config.yaml"
// ConfigFileName is a name of botkube configuration file
var ConfigFileName = "config.yaml"
// Notify flag to toggle event notification
var Notify = true
@ -137,30 +134,14 @@ func (eventType EventType) String() string {
func New() (*Config, error) {
c := &Config{}
configPath := os.Getenv("CONFIG_PATH")
resourceConfigFilePath := filepath.Join(configPath, ResourceConfigFileName)
resourceConfigFile, err := os.Open(resourceConfigFilePath)
defer resourceConfigFile.Close()
configFile := filepath.Join(configPath, ConfigFileName)
file, err := os.Open(configFile)
defer file.Close()
if err != nil {
return c, err
}
b, err := ioutil.ReadAll(resourceConfigFile)
if err != nil {
return c, err
}
if len(b) != 0 {
yaml.Unmarshal(b, c)
}
communicationConfigFilePath := filepath.Join(configPath, CommunicationConfigFileName)
communicationConfigFile, err := os.Open(communicationConfigFilePath)
defer communicationConfigFile.Close()
if err != nil {
return c, err
}
b, err = ioutil.ReadAll(communicationConfigFile)
b, err := ioutil.ReadAll(file)
if err != nil {
return c, err
}

View File

@ -217,7 +217,7 @@ func sendMessage(c *config.Config, notifiers []notify.Notifier, msg string) {
func configWatcher(c *config.Config, notifiers []notify.Notifier) {
configPath := os.Getenv("CONFIG_PATH")
configFile := filepath.Join(configPath, config.ResourceConfigFileName)
configFile := filepath.Join(configPath, config.ConfigFileName)
watcher, err := fsnotify.NewWatcher()
if err != nil {

View File

@ -361,7 +361,7 @@ func runVersionCommand(args []string, clusterName string) string {
func showControllerConfig() (configYaml string, err error) {
configPath := os.Getenv("CONFIG_PATH")
configFile := filepath.Join(configPath, config.ResourceConfigFileName)
configFile := filepath.Join(configPath, config.ConfigFileName)
file, err := os.Open(configFile)
defer file.Close()
if err != nil {

View File

@ -1,35 +0,0 @@
# Communication settings
communications:
# Settings for Slack
slack:
enabled: true
channel: 'cloud-alerts'
token: 'ABCDEFG'
notiftype: short # Change notification type short/long you want to receive. notiftype is optional and Default notification type is short (if not specified)
# Settings for Mattermost
mattermost:
enabled: false
url: 'MATTERMOST_SERVER_URL' # URL where Mattermost is running. e.g https://example.com:9243
token: 'MATTERMOST_TOKEN' # Personal Access token generated by BotKube user
team: 'MATTERMOST_TEAM' # Mattermost Team to configure with BotKube
channel: 'MATTERMOST_CHANNEL' # Mattermost Channel for receiving BotKube alerts
notiftype: short # Change notification type short/long you want to receive. notiftype is optional and Default notification type is short (if not specified)
# Settings for ELS
elasticsearch:
enabled: false
server: 'ELASTICSEARCH_ADDRESS' # e.g https://example.com:9243
username: 'ELASTICSEARCH_USERNAME'
password: 'ELASTICSEARCH_PASSWORD'
# ELS index settings
index:
name: botkube
type: botkube-event
shards: 1
replicas: 0
# Settings for Webhook
webhook:
enabled: true
url: 'WEBHOOK_URL' # e.g https://example.com:80

View File

@ -180,6 +180,42 @@ resources:
# about the best practices for the created resource
recommendations: true
# Channels configuration
communications:
# Settings for Slack
slack:
enabled: true
channel: 'cloud-alerts'
token: 'ABCDEFG'
notiftype: short # Change notification type short/long you want to receive. notiftype is optional and Default notification type is short (if not specified)
# Settings for Mattermost
mattermost:
enabled: false
url: 'MATTERMOST_SERVER_URL' # URL where Mattermost is running. e.g https://example.com:9243
token: 'MATTERMOST_TOKEN' # Personal Access token generated by BotKube user
team: 'MATTERMOST_TEAM' # Mattermost Team to configure with BotKube
channel: 'MATTERMOST_CHANNEL' # Mattermost Channel for receiving BotKube alerts
notiftype: short # Change notification type short/long you want to receive. notiftype is optional and Default notification type is short (if not specified)
# Settings for ELS
elasticsearch:
enabled: false
server: 'ELASTICSEARCH_ADDRESS' # e.g https://example.com:9243
username: 'ELASTICSEARCH_USERNAME'
password: 'ELASTICSEARCH_PASSWORD'
# ELS index settings
index:
name: botkube
type: botkube-event
shards: 1
replicas: 0
# Settings for Webhook
webhook:
enabled: true
url: 'WEBHOOK_URL' # e.g https://example.com:80
# Setting to support multiple clusters
settings:
# Cluster name to differentiate incoming messages