Microk8s create a namespace with rewrited dash to underscore - microk8s

I face a curious state on my microk8s cluster while dealing with namespace creation and deletion.
One namespace in terminating space is listed with a dash in the kubectl get namespaces response
$ kubectl get namespaces | grep mongo
mongodb-shared Terminating 3d22h
but when requested with it ressource name it is not found:
$ kubectl get namespace mongodb-shared Error from server (NotFound):
namespaces "mongodb-shared" not found
I found that it was accessible with an underscore:
but it ressource name (even in the yaml view) is with a dash
$ kubectl get namespace mongodb_shared
NAME STATUS AGE
mongodb-shared Terminating 3d22h
Therefore, I cannot udpate the finalizers to force kill this namespace
I can extract the yaml or json descriptor with :
kubectl get namespace ${NAMESPACE} -o yaml
but I cannot apply any change
I always have the error message:
"the name of the object (mongodb-shared) does not match the name on
the URL (mongodb_shared)"

Related

How to check consul service health if there is space in the name and tag both

I want to fetch service health information from consul. How can I search a service with curl cmd when there is space in their name and tag both
one more question is curl --get http://127.0.0.1:8500/v1/health/checks/$service will check for service check, I want to check if a Node check is failing for a service or not. How to do that?
curl --get http://127.0.0.1:8500/v1/health/checks/$service --data-urlencode 'filter=Status == "critical"'
here if service name and tag both are "ldisk gd" then with this cmd it will throw
curl: (6) Could not resolve host: gd; Name or service not known
Can't pass the name within quotes with that getting Bad request error

gcloud cli failing to add record when contents start with dash

I'm working with the LetsEncrypt dns-01 challenge system which entails dynamically creating a TXT record in Google Cloud DNS with specific content, so LE can assert proof of ownership for generating a wildcard certificate (so I can't use http-01). The problem is sometimes LE tells me to create a TXT record that starts with a "-", for example -E_DFDFHJKF1783FSHDJ. I cannot get the gcloud cli to properly accept this data no matter what I do.
Example:
gcloud dns record-sets transaction start --zone=myzone
gcloud dns record-sets transaction add "-E_ASDFSDF" --ttl=30 --zone=myzone --name=test --type=TXT
gcloud dns record-sets transaction remove "-A_DSFKHSDF" --ttl=30 --zone=myzone --name=test2 --type=TXT
If you run those commands and inspect the resulting transaction.yaml you can see whether it properly contains the right string. If it did it correct, you should see something like:
- kind: dns#resourceRecordSet
name: test.
rrdatas:
- '"ASDFASDF"'
ttl: 30
type: TXT
I am executing this via Node's child_process, but I have the issue even if I execute it directly from bash, so Node isn't really meaningful issue at the moment. I've tried echoing the value in. I've tried setting an environment variable and using that in the string.
No matter what I do I get an error like the following:
ERROR: (gcloud.dns.record-sets.transaction.add) unrecognized arguments: -E_ASDFSDF
It turns out some characters need to be escaped in the CLI. I can confirm that the following works:
gcloud dns --project=myprojectid record-sets transaction add "\-test123" --name=test.mydomain.com. --ttl=300 --type=TXT --zone=myzoneid

Parse string in sh file

For a gitlab ci/cd project, I need to find the url of a knative service (used to deploy a webservice) so that I can utilize it as my base url for load testing
I have found that I can find the url (and other information) with the command: kubectl get ksvc helloworld-go, which outputs:
NAME URL LATESTCREATED LATESTREADY READY REASON
helloworld-go http://helloworld-go.default.34.83.80.117.xip.io helloworld-go-96dtk helloworld-go-96dtk True
Can someone please provide me an easy way to extract only the url in a sh script? I believe the easiest way might be to find the text between the first and second space on the second line.
kubectl get ksvc helloworld-go | grep -oP "http://[^\t]*"
or
kubectl get ksvc helloworld-go | grep -Eo "http://[^[:space:]]*"

Deploying CAM I get Internal error occurred: admission webhook error

I'm getting this error code deploying CAM helm chart:
Internal service error : rpc error: code = Unknown desc = release cam failed: Internal error occurred: admission webhook "trust.hooks.securityenforcement.admission.cloud.ibm.com" denied the request: Deny "mycluster.icp:8500/services/icam-bpd-cds:3.1.0.0-x86_64", no matching repositories in ClusterImagePolicy and no ImagePolicies in the "services" namespace
Via cmd line:
kubectl edit clusterimagepolicies $(kubectl get clusterimagepolicies --no-headers | awk ‘{print $1}’)
Inspect the list of -name entries. Should already be something in there for
mycluster.icp:8500/*
You can try adding an explicit
-name mycluster.icp:8500/services/icam-bpd-cds:*
entry and wq to write and quit and see if that helps.

how to use aws public ips with elixir

Have 2 iex shells running on different servers in EC2 but when I try to connect from one to the other I get this error:
Node.connect :them#ip-172-30-<--snip-->
** (ArithmeticError) bad argument in arithmetic expression
:erlang
It looks like elixir doesn't like that the hostname has dashes in it. How can I change the hostname without breaking the routing between the EC2 instances?
Thanks!
The error was caused by atom literal can not contain dash.
You can try :a-b-c and :"a-b-c" in iex.
So you should use Node.connect :"them#ip-172-30-<--snip-->".
Besides, you can use --name NAME instead of --sname NAME to name a node.
sname option makes and assigns a short name with your hostname.
You can name the node with --name like iex --name "them#thisismyhost.

Resources