kubernetes-cd-plugin
kubernetes-cd-plugin copied to clipboard
Expecting to have "Kubernetes Namespace for Secret" support system variable
We currently have pipeline create and deploy services in namespaces according the branch-name and we found there is a small gap prevent us to make things perfect.
That is, when I run the whole stuff in default namespace I am able to leverage $KUBERNETES_SECRET_NAME but when I am using system variable as the name of namespaces dynamically and deploy things inside the namespace, I found I just cannot use system variable in the field "Kubernetes Namespace for Secret" field.
apiVersion: v1
kind: Namespace
metadata:
name: ${KUBERNETES_NS}
labels:
name: ${KUBERNETES_NS}
And I put ${KUBERNETES_NS} in the configuration field "Kubernetes Namespace for Secret" but it seems this configuration does not honor the system parameters configuration.
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: sample-k8s-deployment
spec:
replicas: 1
template:
metadata:
labels:
app: sample-k8s-app
spec:
containers:
- name: sample-k8s-app-container
image: <username or registry URL>/<image_name>:<tag(maybe $BUILD_NUMBER)>
ports:
- containerPort: 8080
imagePullSecrets:
- name: $KUBERNETES_SECRET_NAME
Will appreciate if anyone could have a look and provide a suggestion on this. Thank you!
I have the same problem.
In my opinion, the problem with the variables is even bigger. We habe a Jenkins job with a choice parameter for selecting the customer. In my GIT repository, i have YAML files per customer (each one in a subdirectory with the customer name), so I want so put ${CUSTOMER}/kubernetes.yaml
to the field where the config file is specified. But unfortunately, the plugin does not support variables in this field. So please add support for variables in all plugin fields, so the plugin finally becomes usable.
Today i had the same problem. After some research i found issue #53.
If you have a variable that you want to use inside the config, you should define it as env.VARIABLE_OF_CHOICHE = "value"
.
Then you can use $VARIABLE_OF_CHOICHE
in the kubernetes config.
@gutschet I think in your situation you could do this. You dont have to define it as an environment variable because that is for using it inside the file. For using variables inside strings make sure you use double qoutes.
kubernetesDeploy(configs: "${CUSTOMER}/fj-producties.yaml", kubeconfigId: "your-kubeconfig")