Cannot use underscore inside command in kubernetes deployment? - kubernetes

I need to issue a command "python manage.py rebuild_index" for rebuilding index of apache solr in my app deployment. But i get the following error:
The Deployment "test-app" is invalid: spec.template.spec.initContainers[5].name: Invalid value: "rebuild_index": a DNS-1123 label must consist of lower case alphanumeric characters or '-', and must start and end with an alphanumeric character (e.g. 'my-name', or '123-abc', regex used for validation is '[a-z0-9]([-a-z0-9]*[a-z0-9])?')

As per your error message I don't think the error is due to '_' in command, I guess you have named initContainers name as well "rebuild_index" that is where the error has been generated.
Object Name in k8s should be an alphanumeric character where only "." and "-" special characters are allowed. You can read more on this documentation link. Please change the initContainer name to "rebuild-index" which will resolve your issue.
Thanks,

Related

Process YAML File step of the Kubernetes plugin throwing error if the image name has / slash

The image in the deployment yaml is in the below format :
'${DockerRegistry}/${orgName}/${projectName}/${ImageName}:${version}'
There are 3 forward slashes in the image name after the docker registry name and this is causing an error. I tried with Kubernetes plugin of 16, 17, 18 & 19 and Process Yaml step of Kubernetes is throwing the below error.
Loading /opt/ibm-ucd/agent/var/work/lr-central-credit-register/common/openshift/dc.yml The desired versions for existing image components is [:] Creating ibm-ucd-kubernetes.yaml Creating component: cbrpoc-loan-requests-cbrpoc-loan-requests/lr-central-credit-register Caught: java.io.IOException: 400 Error processing command: Name cannot contain the following characters: / \ [ ] % java.io.IOException: 400 Error processing command: Name cannot contain the following characters: / \ [ ] % at com.urbancode.ud.client.UDRestClient.invokeMethod(UDRestClient.java:225) at com.urbancode.ud.client.ComponentClient.createComponent(ComponentClient.java:180) at processyaml.createComponent(processyaml.groovy:481) at processyaml.this$4$createComponent(processyaml.groovy) at processyaml$_run_closure6.doCall(processyaml.groovy:362) at processyaml.run(processyaml.groovy:325)
According to the official documentation of Docker Registry HTTP API V2
A repository name is broken up into path components. A component of a
repository name must be at least one lowercase, alpha-numeric
characters, optionally separated by periods, dashes or underscores.
More strictly, it must match the regular expression
[a-z0-9]+(?:[._-][a-z0-9]+)*. If a repository name has two or more
path components, they must be separated by a forward slash (“/”). The
total length of a repository name, including slashes, must be less
than 256 characters.
Please make sure you are using Docker Registry HTTP API V2 and follow all the above rules.
While the V1 registry protocol is usable, there are several problems with the architecture that have led to V2.
Additionally, you can try to use Docker Tag
Create a tag TARGET_IMAGE that refers to SOURCE_IMAGE
More info with examples lined above.
Please let me know if that helped.

Rancher Cluster `cloud_provider` YAML: How to use Active Directory Domain Credentials (i.e. user name with back slash) in YAML?

I'm attempting to put my AD domain credentials into the YAML config file created by rancher so that I may use vSphere storage within Rancher / Kubernetes, however, I'm running into an issue with the formatting of the virtual_center config portion:
(...)
virtual_center:
<IP>:
(...)
user: "DOMAIN/username"
password: <PASSWORD>
The cluster doesn't seem to like a backslash (or two backslashes including the escape character), and it also doesn't seem to like a forward slash.
How should I enter my domain credentials in here?
EDIT
nvm, i figured it out.
JK, answer below.
Apparently the solution is to use a user#domain.site.local format rather than a DOMAIN\user format.
See:
https://github.com/rancher/rancher/issues/16371

What does the "One of the deployment parameters has an empty key" mean in VSTS ARM release

My ARM template resource group deployment fails in VSTS.
I get an error without any specific reference to parameter that has an issue: "One of the deployment parameters has an empty key. Please see https://aka.ms/arm-deploy/#parameter-file for details."
The referenced url contain general information, with one comment asking the same question, but no answer to it.
Person asking it alluded that it may have something to do with the version of the deployment step (2.*) and it not using Powershell anymore. I went though the template back and forth comparing parameters in BeyondCompare and nothing sticks out...
Does anyone know what does this error mean?
I had the same issue and found out that some parameters has a space in their values.
So you should write -adminUsername "$(vmuser)".
This works for me
Check Your parameter key or value does not have space in between.
if your value required space then, use "".
check this link.
Example,
direct value -param1 "Value with Space"
value from pipeline variables -param1 "$(valueFromVariables)".
It means you've got a parameterkey in your deployment template without a name. For example "-" instead of "-parametername" or "- parametername" (notice the space).
It can also happen if you manage to paste an 'em-dash' (e.g. from a web browser) instead of a standard dash.
We had the same as matendie; a space between the dash and the parameter name:
- pricingTier "standard"
^ note the space
So, I'm not sure what the issue was, but I gave up on trying to identify the problem, and I deleted the release definition. Recreating it from scratch using the same template, works fine now...
Maybe the definition got some how corrupted.
Not sure, but new one is not having this issue.
Thanks
In my case the problem was with template parameters override. I needed to put parameter value in quotes - "DEV" on screenshot below.
Ran into this the other day. The release pipeline used to be working, and it suddenly started failing continuously with this error:
Error text:
##[error] One of the deployment parameters has an empty key. Please see https://aka.ms/resource-manager-parameter-files for details.
##[warning] Validation errors were found in the Azure Resource Manager template. This can potentially cause template deployment to fail. Task failed while creating or updating the template deployment.. Please follow https://learn.microsoft.com/en-us/azure/azure-resource-manager/templates/template-syntax
Starting Deployment.
Deployment name is TemplateDeployment-20220504-******-****
There were errors in your deployment. Error code: InvalidDeploymentParameterKey.
##[error] One of the deployment parameters has an empty key. Please see https://aka.ms/resource-manager-parameter-files for details.
##[error] Check out the troubleshooting guide to see if your issue is addressed: https://learn.microsoft.com/en-us/azure/devops/pipelines/tasks/deploy/azure-resource-group-deployment?view=azure-devops#troubleshooting
##[error] Task failed while creating or updating the template deployment.
Change that caused the error
I had changed the build pipeline such that the build numbers would now have spaces in it: so it changed from my-build-number to my build number. I was still using template param overrides this way: -buildNumber $(Build.BuildNumber):
this would expand to -buildNumber my build number, which breaks the command line processing of the ARM template deployment release task.
Solution
Used quotes for my build number variable: -buildNumber "$(Build.BuildNumber)":
Now this would expand to -buildNumber "my build number", and the Azure Resource Manager (ARM) template deployment release task is happy:

How to read Azure Service Bus Topic Name contains / in it. eg: xxx/t000 in PowerShell

I am using PowerShell to read the Azure Service Bus Topics. The topic name contains some special characters in it. Eg. Topic name is xxx/t000.
When I use:
Get-AzureRmServiceBusSubscription -ResourceGroup 'rg_name' -NamespaceName 'sbname' -TopicName "xxx/t000"
I am getting error:
Operation returned an invalid Status code "Not Found"
So I am predicting the issue with the / in the topic name.
Can someone help me on how to read the topic name which contains "/" in it?
Try putting the topic name in single quotes.
-TopicName 'xxx/t000'
This problem is related to Azure Resource Manager, which doesn't support resource names that have "/". You should be able to reference the topic by replacing '/' with '~'.
Here's a good behind the scenes description about this subject on MSDN: https://blogs.msdn.microsoft.com/servicebus/2017/06/21/azure-service-bus-azure-resource-manager-and-this-character/
On the Service Bus side we will convert "/" to "~" when interfacing
with ARM, but retain the slashes in our back-end so things continue to
work the way they are supposed to.

Comma separator in Lambda function environment settings using the Serverless Framework

I am trying to add a MongoDB cluster as part of a Serverless deployment, but I can't set the environment variable.
Here is part of the serverless.yml file:
service: serverless-test
plugins:
- serverless-offline
provider:
name: aws
runtime: nodejs4.3
environment:
MONGO_URI: "mongodb://mongo-6:27000,mongo-7:27000,mongo-8:27000/db-dev?replicaSet=mongo"
How do I pass the MONGO_URI to contain the cluster as a comma separated value?
Any advise is much appreciated.
Unfortunately, you can't use commas in Lambda environment variables. This is an AWS limitation and not a Serverless issue.
For example, browse the AWS console and try to add a environment variable that contains a comma:
When you save, you will get the following error:
1 validation error detected: Value at 'environment.variables' failed to satisfy constraint: Map value must satisfy constraint: [Member must satisfy regular expression pattern: [^,]*]
The error message says that the regex [^,]* must be satisfied and what this small regex explicitly says is to not (^) accept the comma (,). Any other char is acceptable.
I don't know why they don't accept the comma and this is not explained in their documentation, but at least their error message shows that it is intentional.
As a workaround, you can replace your commas by another symbol (like #) to create the env var and replace it back to comma after reading the variable, or you will need to create multiple env vars to store the endpoints.