Skip to content

Commit

Permalink
Merge pull request #205 from adamrushuk/develop
Browse files Browse the repository at this point in the history
v1.6.0 release
  • Loading branch information
adamrushuk authored Jul 31, 2021
2 parents 150450e + 32672d5 commit b1d4916
Show file tree
Hide file tree
Showing 25 changed files with 1,133 additions and 687 deletions.
4 changes: 2 additions & 2 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ RUN if [ "${INSTALL_AZURE_CLI}" = "true" ]; then bash /tmp/library-scripts/azcli

# Install Terraform, tflint, Go, PowerShell, and other useful tools
# TODO: move this into main "RUN" layer above
ARG TERRAFORM_VERSION=0.14.9
ARG TFLINT_VERSION=0.18.0
ARG TERRAFORM_VERSION=1.0.0
ARG TFLINT_VERSION=0.29.0
RUN bash /tmp/library-scripts/terraform-debian.sh "${TERRAFORM_VERSION}" "${TFLINT_VERSION}" \
&& bash /tmp/library-scripts/powershell-debian.sh \
&& bash /tmp/library-scripts/kubectl-helm-debian.sh \
Expand Down
4 changes: 2 additions & 2 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
"build": {
"dockerfile": "Dockerfile",
"args": {
"TERRAFORM_VERSION": "0.14.9",
"TFLINT_VERSION": "0.22.0",
"TERRAFORM_VERSION": "1.0.0",
"TFLINT_VERSION": "0.29.0",
"INSTALL_AZURE_CLI": "true",
"INSTALL_DOCKER": "true",
"INSTALL_NODE": "true"
Expand Down
17 changes: 11 additions & 6 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# build - github workflow
# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json

# https://help.github.com/en/actions/reference/workflow-syntax-for-github-actions
name: build

Expand Down Expand Up @@ -58,12 +61,12 @@ env:
TF_INPUT: "false"
TF_PLAN: "tfplan"
# https://github.com/hashicorp/terraform/releases
TF_VERSION: "0.14.9"
TF_VERSION: "1.0.3"
TF_WORKING_DIR: ./terraform
# https://github.com/terraform-linters/tflint-ruleset-azurerm/releases
TFLINT_RULESET_AZURERM_VERSION: "v0.9.0"
TFLINT_RULESET_AZURERM_VERSION: "v0.11.0"
# https://github.com/terraform-linters/tflint/releases
TFLINT_VERSION: "v0.25.0"
TFLINT_VERSION: "v0.30.0"

# Env var concatenation is currently not supported at Workflow or Job scope. See workaround below:
# https://github.community/t5/GitHub-Actions/How-can-we-concatenate-multiple-env-vars-at-workflow-and-job/td-p/48489
Expand Down Expand Up @@ -190,9 +193,11 @@ jobs:
run: ./scripts/push_docker_images.sh

# TODO: Remove once issue has been fixed
# https://github.com/terraform-providers/terraform-provider-azurerm/issues/8546
- name: Restart Function App
run: az functionapp restart --name "${{ env.PREFIX }}-funcapp" --resource-group "${{ env.PREFIX }}-rg-function-app"
- name: Fix Function App version
run: pwsh -command "./scripts/Fix-FunctionApp.ps1"
env:
FUNCTION_APP_NAME: "${{ env.PREFIX }}-funcapp"
FUNCTION_APP_RG: "${{ env.PREFIX }}-rg-function-app"

# Pester tests
- name: 🧪 Run Pester tests
Expand Down
5 changes: 4 additions & 1 deletion .github/workflows/destroy.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# destroy - github workflow
# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json

# https://help.github.com/en/actions/reference/workflow-syntax-for-github-actions
name: destroy

Expand Down Expand Up @@ -52,7 +55,7 @@ env:
TF_LOG_PATH: terraform.log
TF_LOG: TRACE
# https://github.com/hashicorp/terraform/releases
TF_VERSION: "0.14.9"
TF_VERSION: "1.0.3"
TF_WORKING_DIR: terraform

# Env var concatenation is currently not supported at Workflow or Job scope. See workaround below:
Expand Down
16 changes: 7 additions & 9 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
{
"version": "0.2.0",
"configurations": [
{
"name": "Attach to PowerShell Functions",
"type": "PowerShell",
"request": "attach",
"customPipeName": "AzureFunctionsPSWorker",
"runspaceId": 1,
"preLaunchTask": "func: host start"
}
{
"name": "PowerShell Launch Current File",
"type": "PowerShell",
"request": "launch",
"script": "${file}",
"cwd": "${file}"
}
]
}
5 changes: 3 additions & 2 deletions function_app/profile.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,10 @@ function Send-IftttAppNotification {
value3 = $Value3
}

Invoke-RestMethod -Method Get -Uri $webhookUrl -Body $body -ResponseHeadersVariable responseHeaders -StatusCodeVariable statusCode
# TEMP removal of "StatusCodeVariable" until PowerShell 7 function app issues are resolved
Invoke-RestMethod -Method Get -Uri $webhookUrl -Body $body -ResponseHeadersVariable responseHeaders #-StatusCodeVariable statusCode

Write-Host "Status Code: [$statusCode]"
# Write-Host "Status Code: [$statusCode]"
Write-Host "Response Headers:`n"
$responseHeaders | Out-String
}
Expand Down
19 changes: 19 additions & 0 deletions scripts/Fix-FunctionApp.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# source: https://github.com/terraform-providers/terraform-provider-azurerm/issues/8867#issuecomment-849842849

# Fixes PowerShell function app stack version to 7

# Change function app to PS 7
Write-Host 'Change function app to PS 7'
$function = az functionapp show --name $env:FUNCTION_APP_NAME --resource-group $env:FUNCTION_APP_RG | ConvertFrom-Json

if ($function.siteConfig.powerShellVersion -ne "~7") {
Write-Host "Updating powershell version to ~7..."
az functionapp update --name $env:FUNCTION_APP_NAME --resource-group $env:FUNCTION_APP_RG --set "siteConfig.powerShellVersion=~7"

# Restart Function App
# az functionapp restart --name $env:FUNCTION_APP_NAME --resource-group $env:FUNCTION_APP_RG
} else {
Write-Host "Powershell version already set to to ~7"
}

Write-Host ''
4 changes: 2 additions & 2 deletions scripts/tflint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ trap "echo 'error: Script failed: see failed command above'" ERR

# vars
# Set local vars from env var, with default fallbacks
TFLINT_VERSION="${TFLINT_VERSION:-v0.23.1}"
TFLINT_RULESET_AZURERM_VERSION="${TFLINT_RULESET_AZURERM_VERSION:-v0.7.0}"
TFLINT_VERSION="${TFLINT_VERSION:-v0.29.1}"
TFLINT_RULESET_AZURERM_VERSION="${TFLINT_RULESET_AZURERM_VERSION:-v0.10.1}"
TF_FLAGS=("$TF_WORKING_DIR")
export TFLINT_LOG=debug
# use empty array to skip adding disabled rules, eg: "DISABLED_RULES=()"
Expand Down
116 changes: 116 additions & 0 deletions splunk/.terraform.lock.hcl

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

113 changes: 113 additions & 0 deletions splunk/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
# Splunk

Used for Splunk related testing.

## Installation

### Terraform

Build an AKS cluster:

```bash
# Init
cd ./splunk
terraform init #-upgrade

# Apply
terraform apply

# Outputs
terraform output

---

# Delete
terraform destroy
```

### Splunk Operator

There is a current issue with [Admin Installation for All Namespaces](https://github.com/splunk/splunk-operator/issues/206),
so use the [non-admin user method](https://github.com/splunk/splunk-operator/blob/develop/docs/Install.md#installation-using-a-non-admin-user).

#### Install

Install the Splunk Operator as a non-admin user.

```bash
# create namespace
kubectl create namespace splunk-operator

# an admin needs to install the CRDs
kubectl apply -f https://github.com/splunk/splunk-operator/releases/download/1.0.1/splunk-operator-crds.yaml

# install splunk operator into namespace
# v1.0.1 doesnt currently work - I've raised this issue: https://github.com/splunk/splunk-operator/issues/373
kubectl apply -f https://github.com/splunk/splunk-operator/releases/download/1.0.1/splunk-operator-noadmin.yaml --namespace splunk-operator


# 1.0.0 works
kubectl apply -f https://github.com/splunk/splunk-operator/releases/download/1.0.0/splunk-operator-crds.yaml
kubectl apply -f https://github.com/splunk/splunk-operator/releases/download/1.0.0/splunk-operator-noadmin.yaml --namespace splunk-operator
```

### Splunk Deployments

After deploying one of the methods below, [get the password](https://github.com/splunk/splunk-operator/blob/develop/docs/Examples.md#reading-global-kubernetes-secret-object)
by running the following code:

```bash
# kubectl get secret splunk-<desired_namespace>-secret -o go-template=' {{range $k,$v := .data}}{{printf "%s: " $k}}{{if not $v}}{{$v}}{{else}}{{$v | base64decode}}{{end}}{{"\n"}}{{end}}'
kubectl get secret --namespace splunk-operator splunk-splunk-operator-secret -o go-template=' {{range $k,$v := .data}}{{printf "%s: " $k}}{{if not $v}}{{$v}}{{else}}{{$v | base64decode}}{{end}}{{"\n"}}{{end}}'
```

You can then port-forward to the pod and view the web interface:

```bash
kubectl port-forward splunk-s1-standalone-0 8000
kubectl port-forward --namespace splunk-operator splunk-single-standalone-0 8000
```

#### Standalone

https://github.com/splunk/splunk-operator/blob/develop/docs/Examples.md#creating-a-clustered-deployment

```bash
cat <<EOF | kubectl apply --namespace splunk-operator -f -
apiVersion: enterprise.splunk.com/v1
kind: Standalone
metadata:
name: single
finalizers:
- enterprise.splunk.com/delete-pvc
EOF
```

#### Cluster Master and Indexers

https://github.com/splunk/splunk-operator/blob/develop/docs/Examples.md#indexer-clusters

```bash
# Cluster Master
cat <<EOF | kubectl apply -f -
apiVersion: enterprise.splunk.com/v1
kind: ClusterMaster
metadata:
name: cm
finalizers:
- enterprise.splunk.com/delete-pvc
EOF

# Indexers
cat <<EOF | kubectl apply -f -
apiVersion: enterprise.splunk.com/v1
kind: IndexerCluster
metadata:
name: example
finalizers:
- enterprise.splunk.com/delete-pvc
spec:
clusterMasterRef:
name: cm
EOF
```
Loading

0 comments on commit b1d4916

Please sign in to comment.