Skip to content

Single Command-Node

This is an example of a simple command sent via the "zero trust host access" control channel to specific nodes in clusters.


Send Query

In this example, we want to execute a simple command "kubectl get pods -A" from the identified nodes in the cluster.

curl --location --request POST 'https://app.phani-ptnr-1219.dev.rafay-edge.net/cmdexec/v1/projects/j2q4j5k/edges/3mxg7ek/execute/' \
--header 'X-RAFAY-API-KEYID: f6869debbd24b1c235aa79b4d2971bdca4855d6f' \
--header 'Content-Type: application/json' \
--data-raw '{
    "target" : ["madhuarm-ubuntu201","madhuamd-ubuntu201"],
    "target_type" : "node",
    "command": "kubectl get pods -A",
    "content_type": "string",
    "timeout": 360
}'

Example Output

curl --location --request GET 'https://app.phani-ptnr-1219.dev.rafay-edge.net/cmdexec/v1/projects/j2q4j5k/edges/3mxg7ek/execution/wg29ek0/' \
--header 'X-RAFAY-API-KEYID: g5439debbd24b1c876aa79b4d2997bdca7009f3g'

Retrieve Results

curl --location --request GET 'https://app.phani-ptnr-1219.dev.rafay-edge.net/cmdexec/v1/projects/j2q4j5k/edges/3mxg7ek/execution/q6kn4ml/' \
--header 'X-RAFAY-API-KEYID: g5439debbd24b1c876aa79b4d2997bdca7009f3g'

Example Output

{
    "NodeResponses": [
        {
            "Name": "madhuamd-ubuntu201",
            "Resp": {
                "Return": "NAMESPACE      NAME                                                  READY   STATUS    RESTARTS   AGE\nkube-system    calico-kube-controllers-7f4f5bf95d-d2wz6              1/1     Running   8          3d23h\nkube-system    calico-node-mqc8d                                     1/1     Running   1          3d23h\nkube-system    calico-node-vmr7j                                     1/1     Running   0          25m\nkube-system    coredns-57444d77b9-wtnr8                              1/1     Running   1          3d23h\nkube-system    coredns-57444d77b9-z965c                              1/1     Running   1          3d23h\nkube-system    glusterfs-czpzn                                       1/1     Running   0          25m\nkube-system    heketi-9ff7d86d7-l9zc9                                1/1     Running   0          25m\nkube-system    kube-apiserver-madhuamd-ubuntu201                     1/1     Running   1          3d22h\nkube-system    kube-controller-manager-madhuamd-ubuntu201            1/1     Running   3          3d22h\nkube-system    kube-proxy-9hxx4                                      1/1     Running   1          3d23h\nkube-system    kube-proxy-dbzdn                                      1/1     Running   1          3d23h\nkube-system    kube-scheduler-madhuamd-ubuntu201                     1/1     Running   3          3d22h\nkube-system    kubelet-rubber-stamp-8448dfc5-5vkfw                   1/1     Running   0          25m\nmadhuw2        madhuaddon1-app-d9b6dbfcc-bshmc                       1/1     Running   1          3d23h\nopenebs        openebs-localpv-provisioner-778b7cbcc5-bvsxg          1/1     Running   0          25m\nopenebs        openebs-ndm-krfrz                                     1/1     Running   2          3d22h\nopenebs        openebs-ndm-operator-598cc8c47c-pxkvd                 1/1     Running   0          25m\nopenebs        openebs-ndm-qdvh6                                     1/1     Running   1          3d22h\nrafay-infra    log-aggregator-648dc99787-mktgb                       1/1     Running   0          25m\nrafay-infra    log-router-dssb8                                      2/2     Running   0          25m\nrafay-infra    rafay-prometheus-adapter-6b5dfbfb47-647d5             1/1     Running   0          25m\nrafay-infra    rafay-prometheus-alertmanager-0                       1/2     Running   0          25m\nrafay-infra    rafay-prometheus-helm-exporter-5f4b757869-5zrpw       1/1     Running   0          25m\nrafay-infra    rafay-prometheus-kube-state-metrics-6b8857675-xkrcw   1/1     Running   0          25m\nrafay-infra    rafay-prometheus-metrics-server-85bff87ffd-j5zwv      1/1     Running   0          25m\nrafay-infra    rafay-prometheus-node-exporter-arm64-njjvc            1/1     Running   0          25m\nrafay-infra    rafay-prometheus-node-exporter-rt45t                  1/1     Running   0          25m\nrafay-infra    rafay-prometheus-server-0                             2/2     Running   0          25m\nrafay-system   controller-manager-574cd8fc97-gn97k                   1/1     Running   0          25m\nrafay-system   edge-client-75b7fd6894-mf2qk                          1/1     Running   0          25m\nrafay-system   ingress-nginx-controller-hq9sg                        1/1     Running   1          3d23h\nrafay-system   ingress-nginx-controller-tzdn6                        1/1     Running   1          3d23h\nrafay-system   l4err-6f6d598b58-mnsv5                                1/1     Running   0          25m\nrafay-system   rafay-connector-59cd68fd77-c2wsn                      1/1     Running   0          25m\nrafay-system   relay-agent-58b59b5fc7-2pdxt                          1/1     Running   0          25m",
                "Retcode": 0,
                "Success": true
            }
        }
    ],
    "Responded": [
        "madhuamd-ubuntu201"
    ],
    "Unreachable": [
        "madhuarm-ubuntu201"
    ],
    "Unapproved": [],
    "Pending": []
}