Skip to content

Commit

Permalink
Generate new 'setup-sumologic.yaml.tmpl'
Browse files Browse the repository at this point in the history
  • Loading branch information
Travis CI authored and sumo-drosiek committed Oct 22, 2020
1 parent ac55b14 commit 010786e
Showing 1 changed file with 53 additions and 2 deletions.
55 changes: 53 additions & 2 deletions deploy/kubernetes/setup-sumologic.yaml.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,41 @@ metadata:
app: collection-sumologic

data:
custom.sh: |
#!/bin/bash
#
# This script copies files from /customer-scripts to /scripts/<dirname> basing on the filename
#
# Example file structure:
#
# /customer-scripts
# ├── dir1_main.tf
# ├── dir1_setup.sh
# ├── dir2_list.txt
# └── dir2_setup.sh
#
# Expected structure:
#
# /scripts
# ├── dir1
# │ ├── main.tf
# │ └── setup.sh
# └── dir2
# ├── list.txt
# └── setup.sh
#
# shellcheck disable=SC2010
# extract target directory names from the file names using _ as separator
for dir in $(ls -1 /customer-scripts | grep _ | grep -oE '^.*?_' | sed 's/_//g' | sort | uniq); do
target="/scripts/${dir}"
mkdir "${target}"
# shellcheck disable=SC2010
# Get files for given directory and take only filename part (after first _)
for file in $(ls -1 "/customer-scripts/${dir}_"* | grep -oE '_.*' | sed 's/_//g'); do
cp "/customer-scripts/${dir}_${file}" "${target}/${file}"
done
cd "${target}" && bash setup.sh
done
locals.tf: |
locals {
default_events_source = "events"
Expand Down Expand Up @@ -124,7 +159,7 @@ data:

type = "Opaque"
}
setup.sh: |-
setup.sh: |
#!/bin/bash
cp /etc/terraform/{locals,main,providers,resources,variables}.tf /terraform
cd /terraform
Expand Down Expand Up @@ -154,11 +189,17 @@ data:
terraform import sumologic_http_source.scheduler_metrics_source "$COLLECTOR_NAME/kube-scheduler-metrics"
terraform import sumologic_http_source.state_metrics_source "$COLLECTOR_NAME/kube-state-metrics"


# Kubernetes Secret
terraform import kubernetes_secret.sumologic_collection_secret $NAMESPACE/sumologic

terraform apply -auto-approve

# Cleanup env variables
export SUMOLOGIC_BASE_URL=
export SUMOLOGIC_ACCESSKEY=
export SUMOLOGIC_ACCESSID=

bash /etc/terraform/custom.sh
variables.tf: |-
variable "cluster_name" {
type = string
Expand Down Expand Up @@ -264,6 +305,10 @@ spec:
configMap:
name: collection-sumologic-setup
defaultMode: 0777
- name: custom
configMap:
name: collection-sumologic-setup-custom
defaultMode: 0777
containers:
- name: setup
image: sumologic/kubernetes-fluentd:1.3.0
Expand All @@ -280,6 +325,8 @@ spec:
volumeMounts:
- name: setup
mountPath: /etc/terraform
- name: custom
mountPath: /customer-scripts
env:
- name: SUMOLOGIC_ACCESSID
value: $SUMOLOGIC_ACCESSID
Expand All @@ -297,6 +344,10 @@ spec:
securityContext:
runAsUser: 999

---
# Source: sumologic/templates/setup/setup-custom-configmap.yaml


---
# Source: sumologic/templates/setup/setup-scc.yaml

Expand Down

0 comments on commit 010786e

Please sign in to comment.