Helm: How to add unclassified tag in Jenkins values.yaml - helm-jenkins

I installed Jenkins (https://github.com/helm/charts/tree/master/stable/jenkins) Helm Chart as a requirement in my own chart.
I'm trying to add the the sonarGlobalConfiguration to the installation:
unclassified:
sonarGlobalConfiguration:
installations:
- name: sonar
serverUrl: 'http://sonar.local.host'
This code works fine with docker, but not with the Jenkins Chart, any idea under which tag i can add it?
Any help would be awesome!

This solved it:
JCasC:
enabled: true
defaultConfig: true
configScripts:
globalConfig: |
unclassified:
sonarGlobalConfiguration:
buildWrapperEnabled: true
installations:
- name: "sonar"
serverUrl: "http://delivery-pipeline-sonarqube:9000"

Related

Negate a boolean value in helm yaml file

I have 3 helm charts. I would like to deploy either two or one based on a condition. global.useFirstChart is a boolean variable.
- name: first-chart
version: 0.1.0
condition: charts.useFirstChart
- name: second-chart
version: 0.1.0
condition: not charts.useFirstChart
- name: third-chart
version: 0.1.0
condition: not global.useFirstChart
However when we tried using this chart, if useFirstChart equals true it deploys all three, if it equals false, it deploys second-chart and third-chart (like expected).
I used 'not' to negate the boolean value, but it doesn't work.
Also we're suspecting the value is string not bool because we set it from Terraform.
is there a way to negate the bool value in helm ?
is there a workaround to deploy specific charts and not others ?

Helm - Can't install dependencies from private Github repository

I'm trying to install packages from a private repository I've deployed using chart-releases, but I'm not being able to do it.
Here is what I've done:
I've created a new private repository, added a sample chart to it and ran the following commands:
helm package charts/* --destination .deploy
cr upload -o odelucca -r helm-charts -p .deploy -t $MY_TOKEN
I've created the index.yaml with the following command:
cr index --config .cr.yaml -t $MY_TOKEN
# My .cr.yaml file:
# owner: odelucca
# git-repo: helm-charts
# package-path: .deploy
# index-path: index.yaml
# charts-repo: https://github.com/odelucca/helm-charts/
I've commit the index.yaml to the repo
I've added the remote helm repo with the following command:
helm repo add helm-charts https://raw.githubusercontent.com/odelucca/helm-charts/master --username $MY_EMAIL --password $MY_TOKEN
The repo was added, then I've added the following dependency to a local chart:
dependencies:
- name: serverless-common
version: 1.0.0
repository: "#helm-charts"
Now, I've tried to run the following:
helm dep update
I get the following errors:
Hang tight while we grab the latest from your chart repositories...
...Unable to get an update from the "local" chart repository (http://127.0.0.1:8879/charts):
Get http://127.0.0.1:8879/charts/index.yaml: dial tcp 127.0.0.1:8879: connect: connection refused
...Successfully got an update from the "helm-charts" chart repository
...Successfully got an update from the "stable" chart repository
Update Complete.
Saving 1 charts
Downloading serverless-common from repo https://raw.githubusercontent.com/odelucca/helm-charts/master
Save error occurred: could not download https://github.com/odelucca/helm-charts/releases/download/serverless-common-1.0.0/serverless-common-1.0.0.tgz: Failed to fetch https://github.com/odelucca/helm-charts/releases/download/serverless-common-1.0.0/serverless-common-1.0.0.tgz : 404 Not Found
Deleting newly downloaded charts, restoring pre-update state
Error: could not download https://github.com/odelucca/helm-charts/releases/download/serverless-common-1.0.0/serverless-common-1.0.0.tgz: Failed to fetch https://github.com/odelucca/helm-charts/releases/download/serverless-common-1.0.0/serverless-common-1.0.0.tgz : 404 Not Found
Anyone can help me? I've tried a lot of different approaches, and none of them fix it
Have you tried editing the repository config file?
You should have something like this:
vim ${HOEM}/.config/helm/repositories.yaml
apiVersion: ""
generated: "0001-01-01T00:00:00Z"
repositories:
- caFile: ""
certFile: ""
insecure_skip_tls_verify: false
keyFile: ""
name: helm-charts
password: ""
url: "https://raw.githubusercontent.com/odelucca/helm-charts/master"
username: ""
Edit it and put your username and password to connect to your private registry.
For me, this works fine.
Maybe you also need to check your repo path.
You should be able to download with an URL like this:
${repository}/${name}-${version}.tgz

Multiple subcharts with differents .Values properties

I'm trying to create a chart with multiple subcharts ( 2 instances of ibm-db2oltp-dev). Is there a way to define in the same values.yaml file, different configuration for each instance?
I need two databases:
db2inst.instname: user1
db2inst.password: password1
options.databaseName: dbname1
db2inst.instname: user2
db2inst.password: password2
options.databaseName: dbname2
I saw it could be done via alias but I didn't find an example explaining how to do it. Is it possible?
Yes, it is possible:
In Chart.yaml for Helm 3 or in requirements.yaml for Helm 2:
dependencies:
- name: ibm-db2oltp-dev *(full chart name here)*
repository: http://localhost:10191 *(Actual repository url here)*
version: 0.1.0 *(Required version)*
alias: db1inst *(The name of the chart locally)*
- name: ibm-db2oltp-dev
repository: http://localhost:10191
version: 0.1.0
alias: db2inst
parentChart/values.yaml:
someParentChartValueX: x
someParentChartValueY: y
db1inst:
instname: user1
db2inst: password1
db2inst:
instname: user2
db2inst: password2
Actually it cannot be achieved in Helm (by aliases too) because values resolving doesn't work for aliased charts. The only way is to define values for chart name:
<chart_name not alias>:
var1: value
var2: value
The source issue: https://github.com/helm/helm/issues/7093

Serverless conditional function deployment by region

Following config is extracted from my serverless.yml
service: test-svc
provider:
name: aws
...
functions:
apiHandler:
handler: index.handler
events:
- http: ANY /
- http: 'ANY {proxy+}'
taskHandler:
handler: task.handler
events:
- sqs:
...
alexaHandler:
handler: alexa.handler
events:
- alexaSmartHome: ...
I want to deploy apiHandler and taskHandler function in only region-a
And deploy alexaHandler in region-b, region-c and region-d.
If I execute the command sls deploy --region us-east-1 all three functions will be deployed, but I don't need that. I need only 2 functions to be deployed.
Using sls deploy function is not an option because it only swaps zip file.
Putting alexaHandler in sub-directory with new serverless.yml didn't work because deployment only packs sub-directory and won't include code from the parent directory. (Many codes are shared between 3 function)
Any suggestion to deal with this requirement?
After going through all the serverless plugin list I found above requirement could be achieved through serverless-plugin-select
Using this plugin we can select to deploy only a few functions from serverless.yml depending on stage or region value. In my case using region value.
Following is modified serverless.yml. plugins section added and regions key added in each function.
service: test-svc
plugins:
- serverless-plugin-select
provider:
name: aws
...
functions:
apiHandler:
...
regions:
- us-west-2
taskHandler:
...
regions:
- us-west-2
alexaHandler:
...
regions:
- eu-west-1
- us-east-1
- us-west-2
With the above config, I use the following bash script to deploy for all region.
#!/usr/bin/env bash
serverless deploy --region eu-west-1
serverless deploy --region us-east-1
serverless deploy --region us-west-2
You can conditionally select values in serverless.yml by storing the conditional functions in a custom variable like
### serverless.yml
provider:
name: << aws or your provider >>
runtime: << your runtime, eg nodejs8.10 >>
region: << your aws region >>
stage: ${opt:stage, 'dev'}
custom:
extraCode:
dev:
testing: ${file(testing_only/testing_endpoints.yml)}
prod:
...
## and then at the functions section of serverless.yml
functions:
- ${file(functions/someFunctionsInAFile.yml)}
- ${file(functions/someMoreFunctions.yml)}
- ${self:custom.extraCode.${self:provider.stage}}
When you deploy serverless you should pass in the command line option --stage=myStageName so that when you pass in --stage=dev or --stage=prod the last line in the function section will be blank and nothing will deployed.
If you pass in --stage=testing the last line in the functions sections will be filled with the file set in your custom variable section and then your test code will be deployed.

Use CAPABILITY_AUTO_EXPAND for nested stacks on CloudFormation

I am trying to use nested stack and when my ChangeSet is being executed, I got this error:
Requires capabilities : [CAPABILITY_AUTO_EXPAND]
I went and create a pipeline with cloudformation.
This can be use to create a pipeline:
Configuration:
ActionMode: CHANGE_SET_REPLACE
ChangeSetName: changeset
RoleArn: ??
Capabilities: CAPABILITY_IAM
StackName: appsync-graphql
TemplatePath: BuildArtifact::output.yaml
This can’t:
Configuration:
ActionMode: CHANGE_SET_REPLACE
ChangeSetName: changeset
RoleArn: ??
Capabilities:
- CAPABILITY_IAM
- CAPABILITY_AUTO_EXPAND
StackName: appsync-graphql
TemplatePath: BuildArtifact::output.yaml
The error was: “Value of property Configuration must be an object with String (or simple type) properties”
This is the closest docs that I find: https://docs.aws.amazon.com/AWSCloudFormation/latest/APIReference/API_UpdateStack.html
It said: Type: Array of strings for capabilites, and the aws cli docs says similarly, but doesn’t give an example.
So I ran out of ideas about what else to try to have CAPABILITY_AUTO_EXPAND capability.
I tried another variant and it worked!
Configuration:
..
Capabilities: CAPABILITY_IAM,CAPABILITY_AUTO_EXPAND
...
I got the answer from Keeton Hodgson, this cli command works:
sam deploy --template-file output.yaml --stack-name <AppName> --capabilities CAPABILITY_IAM CAPABILITY_AUTO_EXPAND
Notice that there is no comma.
I still don't know how to change the pipeline template for it to work.
I tried the solutions above and what worked for me today (June 2020) using the higher level sam was adding a space between the capabilities listed. It's complete insanity that there's no resilience in this text file interpretation. SAM's cli is open source so I guess I could put my code where my mouth is and submit a PR. Anyway.
samconfig.toml:
...
capabilities = "CAPABILITY_IAM CAPABILITY_AUTO_EXPAND"
...
Then:
sam deploy
Output:
...
Capabilities : ["CAPABILITY_IAM", "CAPABILITY_AUTO_EXPAND"]
...
Put the capabilities property at the very end like this
aws cloud formation deploy COMMAND --capabilities CAPABILITY_NAMED_IAM
Change the order
Configuration:
ActionMode: CHANGE_SET_REPLACE
ChangeSetName: changeset
RoleArn: ??
StackName: appsync-graphql
TemplatePath: BuildArtifact::output.yaml
Capabilities:
- CAPABILITY_IAM
- CAPABILITY_AUTO_EXPAND
After some research found that you can actually add those capabilities in console.
Reference Capabilities - optional section in the cfn deploy phase definition in console