How to create reusable templates for dependabot configurations? - dependabot

I have a C# project containing multiple assemblies with some node modules as dev dependencies.
Given this example dependabot.yml configuration file
version: 2
updates:
- package-ecosystem: 'npm'
directory: '/'
schedule:
interval: 'weekly'
labels:
- 'dependencies'
target-branch: 'dev'
commit-message:
prefix: 'deps'
reviewers:
- 'user1'
- 'user2'
- 'user3'
- package-ecosystem: 'nuget'
directory: '/MyCsharpProject/Assembly1'
schedule:
interval: 'weekly'
labels:
- 'dependencies'
target-branch: 'dev'
commit-message:
prefix: 'deps'
reviewers:
- 'user1'
- 'user2'
- 'user3'
both configurations are almost the same. The only things that are different:
the ecosystem
the directory
is there a way I can create some templates? This is a pseudo implementation I'm looking for
version: 2
updates:
- template
name: 'my-template'
schedule:
interval: 'weekly'
labels:
- 'dependencies'
target-branch: 'dev'
commit-message:
prefix: 'deps'
reviewers:
- 'user1'
- 'user2'
- 'user3'
- package-ecosystem: 'npm'
directory: '/'
fill-from: 'my-template'
- package-ecosystem: 'nuget'
directory: '/MyCsharpProject/Assembly1'
fill-from: 'my-template'
Currently my C# project has 8 assemblies and the configuration requires a lot of copy paste. It would be nice to make things reusable.

It does not appear that the YAML Schema of the dependabot configuration file supports either;
- template
name:
or fill-from:
These are the official docs for dependabot configuration and detail the allowed key/value pairs available for configuration.
Sadly it doesn't look like it will let you adhere to the DRY principle. 😕️

Related

How do I use an imagestream from another namespace in openshift?

I have been breaking my head over the following:
I have a set of buildconfigs that build images and create imagestreams for it in the "openshift" namespace. This gives me for example the netclient-userspace imagestream.
krist#MacBook-Pro netmaker % oc get is netclient-userspace
NAME IMAGE REPOSITORY TAGS UPDATED
netclient-userspace image-registry.openshift-image-registry.svc:5000/openshift/netclient-userspace latest About an hour ago
What I have however not been able to figure out is how to use this imagestream in a deployment in a different namespace.
Take for example this:
kind: Pod
apiVersion: v1
metadata:
name: netclient-test
namespace: "kvb-netclient-test"
spec:
containers:
- name: netclient
image: netclient-userspace:latest
When I deploy this I get errors...
Failed to pull image "netclient-userspace:latest": rpc error: code =
Unknown desc = reading manifest latest in
docker.io/library/netclient-userspace: errors: denied: requested
access to the resource is denied unauthorized: authentication required
So openshift goest and looks for the image on dockerhub. It shouldn't. How do I tell openshift to use the imagestream here?
When using an ImageStreamTag for a Deployment image source, you need to use the image.openshift.io/triggers annotation. It instructs OpenShift to replace the image: attribute in a Deployment with the value of an ImageStreamTag (and to redeploy it when the ImageStreamTag changes in the future).
Importantly, note the annotation and the image: ' ' with the explicit space character in the yaml string.
apiVersion: apps/v1
kind: Deployment
metadata:
annotations:
image.openshift.io/triggers: '[{"from":{"kind":"ImageStreamTag","name":"content-netclient-userspace:latest","namespace":"openshift"},"fieldPath":"spec.template.spec.containers[?(#.name==\"netclient\")].image"}]'
name: netclient-test
namespace: "kvb-netclient-test"
spec:
...
template:
...
spec:
containers:
- command:
- ...
image: ' '
name: netclient
...
I will also mention that, in order to pull images from different namespaces, it may be required to authorize the Deployment's service account to do so: OpenShift Docs.

error while loading shared libraries when running prehook pod

I am new to OpenShift, I am deploying my flask app onto it, but encountered some problem. My app/container name is flog.
I set up a lifecycle prehook to ensure the database is created correctly for the app deployment. Here is my config(critical part):
spec:
replicas: 1
selector:
deploymentconfig: flog
strategy:
activeDeadlineSeconds: 21600
resources: {}
rollingParams:
intervalSeconds: 1
maxSurge: 25%
maxUnavailable: 25%
pre:
execNewPod:
command:
- flask
- init
containerName: flog
env:
- name: FLASK_APP
value: wsgi.py
failurePolicy: Abort
timeoutSeconds: 600
updatePeriodSeconds: 1
type: Rolling
It works correctly in building but breaks in prehook
--> pre: Running hook pod ...
/opt/app-root/bin/python3: error while loading shared libraries: libpython3.5m.so.rh-python35-1.0: cannot open shared object file: No such file or directory
However, when I debug in terminal and type python3 command, it works well.
Thanks in advance for any help.
You will need to add a shell script into your image which in turns then runs your command. The shell script wrapper is needed as initialisation of the shell environment has the side effect of enabling the Python environment, including setting environment variables so it can find the Python shared library.
So change:
command:
- flask
- init
to:
command:
- somescript
And in somescript have:
#!/bin/bash
flask init

Cronjob of existing Pod

I have a django app running on Openshift 3. I need to run certain manage.py commands on a regular basis. In Openshift 2 I used the Cron gear and now in Openshift 3 I want to use the CronJob pod type.
I want to create a pod for the cronjob, use the same source as the django app is using, but not expose it.
For example:
W1 - Django app
D1 - Postgres DB
M1 - django app for manage.py jobs, run as a cronjob pod.
Any help is appreciated.
You want to use a scheduled job.
https://docs.openshift.com/container-platform/3.5/dev_guide/cron_jobs.html
https://kubernetes.io/docs/concepts/workloads/controllers/cron-jobs/
https://blog.openshift.com/openshift-jobs/
Note that at this time (OpenShift 3.5), you have to use batch/v2alpha1 as the API version. Be careful of out of date documentation showing older version labels.
What I am not sure of is how you can easily reference the image associated with an existing imagestream produced when you used the S2I builder to build you application and you want to use the same image. The base Kubernetes object for this expects you to refer to the image from the image registry. You would thus need to work that out by looking at the imagestream and copying the image registry IP and image details over by hand.
UPDATE 1
See:
https://stackoverflow.com/a/45227960/128141
for details of how from OpenShift 3.6 you can have it resolve the imagestream name automatically. That mechanism is still alpha status in 3.6, but does work.
I've gotten it to work with specifying the image name in the YAML, but then tried to get it to work as part of the template, but ran into an error when trying to use the batch/v1 version on this server
Cannot create cron job "djangomanage". The API version batch/v1 for kind CronJob is not supported by this server.
My template code is
- apiVersion: batch/v1
kind: CronJob
metadata:
name: djangomanage
spec:
schedule: "*/5 * * * *"
jobTemplate:
spec:
template:
spec:
containers:
- name: djangomanage
image: '${NAME}:latest'
env:
- name: APP_SCRIPT
value: "/opt/app-root/src/cron.sh"
restartPolicy: Never
CRON.SH
python /opt/app-root/src/manage.py
you need to update line 1 with this:
- apiVersion: batch/v1beta1
see link below:
https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.18/#cronjob-v1beta1-batch

Bluemix DevOps deployment error with launch configuration

I am trying to deploy the people in the news sample application and this is the error, Could not find launch configuration manifest nor the top-level project manifest. Please restore it or provide a project manifest.
I am following this one http://peopleinnews.mybluemix.net/deployinfo.html
When I get to number 8 the path has a ' . ' (period) on my UI and I can not remove it to type peopleInNews/
peopleinthenews/manifest.yml (below)
applications:
- services:
- ttn-cloudantNoSQLDB
- re-service
disk_quota: 1024M
host: peopleinnews
name: People In News
command: node app.js
path: .
domain: mybluemix.net
instances: 1
memory: 512M
then I tried changing path manually (below)
applications:
- services:
- ttn-cloudantNoSQLDB
- re-service
disk_quota: 1024M
host: peopleinnews
name: People In News
command: node app.js
path: peopleinnews/
domain: mybluemix.net
instances: 1
memory: 512M
Can anyone tell me more of what this error with the project manifest is?
The manifest.yml file is formatted incorrectly. For the values you've provided, this is how it should be formatted
applications:
- name: People In News
disk_quota: 1024M
host: peopleinnews
command: node app.js
path: peopleinnews/
domain: mybluemix.net
instances: 1
memory: 512M
services:
- ttn-cloudantNoSQLDB
- re-service
Specifically, services is property at the same level as the other properties, and the service names should be properties nested under the services property.
YAML can be a confusing syntax to author; when in doubt, use the awesome CF Manifest Generator at http://cfmanigen.mybluemix.net/ to build your manifest online.
The deployment instruction for the 'People In The News' sample application has been updated in http://peopleinnews.mybluemix.net/deployinfo.html#DeployJazzHub. The important change is in the 'Command' field within the launch configuration panel. Once the correct location of the 'app.js' is specified, the deployment should then go smoothly.

AWS Beanstalk Application Health Check

We use Beanstalk to deploy node applications. It works very well. I've created a couple of config files in an .ebextensions directory, to apply configuration info to our apps when we load them up. Again mostly works well. I have one thing that does not, and that is defining the application health check URL. I can't get it to go. One odd thing about it, it seems to be only parameter I have come across so far that has spaces in it, and I'm wondering about that. I have tried enclosing the values in quotes, just to see if that is the problem, but it still doesn't work. Has anyone done this before, and can tell me whether it works, and if there is something syntactical about this that is incorrect? As I said, the rest of the params get set correctly in beanstalk, just the last one doesn't. Note #environment# gets replaced with a grunt script before this gets deployed.
Here's the config file:
option_settings:
- namespace: aws:elasticbeanstalk:application:environment
option_name: NODE_ENV
value: #environment#
- namespace: aws:elasticbeanstalk:container:nodejs
option_name: NodeVersion
value: 0.10.10
- namespace: aws:autoscaling:trigger
option_name: LowerThreshold
value: 40
- namespace: aws:autoscaling:trigger
option_name: MeasureName
value: CPUUtilization
- namespace: aws:autoscaling:trigger
option_name: UpperThreshold
value: 60
- namespace: aws:autoscaling:trigger
option_name: Unit
value: Percent
- namespace: aws:elasticbeanstalk:application
option_name: Application Healthcheck URL
value: /load_balance_test
Adding this worked for me:
# .ebextensions/healthcheckurl.config
option_settings:
- namespace: aws:elasticbeanstalk:application
option_name: Application Healthcheck URL
value: /health
- namespace: aws:elasticbeanstalk:environment:process:default
option_name: HealthCheckPath
value: /health
I discovered the second setting by doing eb config, which gives a nice overview of environment settings that can be overriden with option_settings in .ebextensions/yet-another.config files.
The spaces in this property name are weird, but it works when used with the alternative shorthand syntax for options:
option_settings:
aws:elasticbeanstalk:application:
Application Healthcheck URL: /
I use CloudFormation for EB, and in CF the syntax for that parameter is very strange. If that config file works the same as CF, the following string should work for you:
HTTP:80/load_balance_test
If you're using Terraform, then just make sure you have spaces in the name, and it will work fine:
setting {
namespace = "aws:elasticbeanstalk:application"
name = "Application Healthcheck URL"
value = "/api/health"
}
I just tried. It worked for me. Only the format specified in the original question worked for me i.e.,
option_settings:
- namespace: aws:elasticbeanstalk:application
option_name: Application Healthcheck URL
value: /api/v1/health/
you also might want to set the health_check_type to ELB instead of default EC2.
this is how I configured mine
$ cat .ebextensions/0090_healthcheckurl.config
Resources:
AWSEBAutoScalingGroup:
Type: "AWS::AutoScaling::AutoScalingGroup"
Properties:
HealthCheckType: "ELB"
HealthCheckGracePeriod: "600"
option_settings:
- namespace: aws:elasticbeanstalk:application
option_name: Application Healthcheck URL
value: /_status