I'm trying to make argocd cli output yaml/json to prep it for script ingestion.
According to this PR: https://github.com/argoproj/argo-cd/pull/2551
It should be available but I can't find the option in cli help nor in documentation.
#argocd version:
argocd: v2.1.2+7af9dfb
...
argocd-server: v2.0.3+8d2b13d
Some commands accept the -o json flag to request JSON output.
Look in the commands documentation to find commands which support that flag.
argocd cluster list -o json, for example, will return a JSON list of configured clusters. The documentation looks like this:
Options
-h, --help help for get
-o, --output string
Output format. One of: json|yaml|wide|server (default "yaml")
Related
I am trying to set up kubemq in my cluster, and this is the command the shown in their README
kubectl apply -f https://deploy.kubemq.io/community
There are a lot of empty field in that yaml and I want to customize it. How can I override an external yaml file applied by kubectl?
In the Kubernetes world, It's generally an unsafe idea to run a command like the below unless you trust the URL:
kubectl apply -f <some/web/url>
This is essentially the same as the following in the non-Kubernetes world:
curl </some/web/url> |bash
In both cases, we aren't inspecting the content downloaded from the URL and directly executing them by feeding to kubectl and bash directly. What if the URL is compromised with some harmful code?
A better approach is to break the single step into parts:
Download the manifest file
Inspect the manifest file.
Run kubectl apply/create on it, only you are satisfied.
Example:
//download the file
curl -fsSL -o downloaded.yml https://deploy.kubemq.io/community
// inspect the file or edit the file
//Now apply the downloaded file after inspecting.
kubectl apply -f downloaded.yml
Why don't you just copy the content in a text file?
Change whatever you want and apply it.
I'm trying to extract a "sub-map" from a K8s object using kubectl. The result has to be legal JSON syntax so it can be parsed by the Groovy JsonSlurper class.
If I run a command like this:
kubectl get configmap ... -o jsonpath="{.data}"
I get output like this:
map[...
This cannot be parsed by JsonSlurper.
If I instead do this:
kubectl get configmap ... -o json | jq .data
I get something like this:
{
"...": "....",
This should be parseable by JsonSlurper.
You might first say, "well, why don't you just DO that then?". I could, but I'm in a situation where I have to limit what applications I assume are installed in the environment. I'm not certain that "jq" is available on all of our build nodes (they aren't running in a container yet).
Is there some way that I can make kubectl with jsonpath output emits a value in legal JSON syntax?
I'm currently using kubectl v1.14.0, with v1.13.5 on the server.
I'm using the API to add some project configuration keys and would like to use them as job parameters. Is this possible? If so, how can I do it? I've looked in the official documentation but am not seeing much.
Indeed, that is achievable, from the documentation, you will need to update the project’s configuration with a “Project global execution variable” key and value, then that variable will be available in all execution contexts as ${globals.X} and can be referenced in scripts and commands. You can send the project’s configuration key as JSON, xml or plain text via curl or as a file directly via the RD CLI. e.g:
If you use the “rd” cli, you need to create a file, which can be a .properties, JSON or YAML file. We will create a JSON file named test.json, that contains the following ‘KEY’ and ‘VALUE’:
{ "project.globals.test" : "testvalue" }
Then, you can update the project configuration with this rd command syntax:
rd projects configure update -f [/path/to/test.json] -p [project_name]
That will update your projects configuration. Then you can reference it as follows:
Via bash: $RD_GLOBALS_TEST
Via command: ${globals.test}
In a script content: #globals.test#
Alternatively, you could use the API directly with curl. For this example I’m using an API token to authenticate with Rundeck’s API and sending the same key and value, but as xml:
curl -H "X-Rundeck-Auth-Token: INSERT_TOKEN" -H "Content-Type: application/xml" -d '<property key="project.globals.test" value="valuetest"/>' -X PUT http://[RD_HOST]:[PORT]/api/23/project/[PROJECT_NAME]/config/[KEY]
Hope it helps.
I am attempting to try out sparkle formation following the documentation, but I do not receive any output from the command bundle exec sfn print --file compute. I have also tried different paths to my compute file with no change. I would like to view the template cloudformation json that this is supposed to create. How can I do that?
The guide is somewhat incomplete and I needed to add a name for my stack and the exact path to the template file into the command: bundle exec sfn print my-stack-name --file sparkleformation/compute.rb
I’m using the command gcloud compute instances list in a script, but I’m worried that the exact output format isn’t static. What should I do?
You should use the --format flag, available for most gcloud commands.
For instance, if you’d like to get the exact same output as the current (as of the time of writing of this answer) format, you can run:
$ gcloud compute instances list --format="table(
name,
zone.basename(),
machineType.basename(),
scheduling.preemptible.yesno(yes=true, no=''),
networkInterfaces[0].networkIP:label=INTERNAL_IP,
networkInterfaces[0].accessConfigs[0].natIP:label=EXTERNAL_IP,
status
)"
The output of this command will not change between releases, even if the default output of the command does (unless the resource being formatted changes; this should be rare).1 Showing the default format for resources in commands is a work in progress.2
You can also specify a format like YAML or JSON for machine-readable output:
$ gcloud compute instances list --format=yaml
$ gcloud compute instances list --format=json
Note that this output contains much more information than is present in the default output for this command; this is the information you have to work with when constructing a custom format.
CSV is another format option. Like table, it requires a projection–a specification for how to print each row.3
$ gcloud compute instances list --format="csv(name,zone,status)"
name,zone,status
example-instance,us-central1-f,RUNNING
...
For more information on the formatting capabilities of gcloud, see the output of gcloud topic formats and gcloud topic projections.
You can see all possible fields by running gcloud compute instances list --format=flattened.
For some commands, like gcloud beta test android locales list, you can pass the --verbosity=info flag and look for INFO: Display format.
This is because CSV data cannot be nested like JSON or YAML, and the data structures being printed may be nested.