Rundeck : How to check Rundeck health status? - api

We have a few jobs in production rundeck, due to other application running and throttling CPU, rundeck sometimes goes slow and lag sometimes nearly dead but rundeckd process will be still running. I wanted to set up cron(which I know) to query rundeck healthcheck and report if its sluggish till we migrate rundeck to dedicated VM. I found rundeck3.3 has api enabled by default and I am able to query in browser like http://rundesckhost:4440/metrics/ping which will return pong. Apparently http://rundeckhost:4440/metrics/healthcheck shows json
{"dataSource.connection.time":{"healthy":true,"message":"Datasource connection healthy with timeout 5 seconds"},"quartz.scheduler.threadPool":{"healthy":true}}
I have generated API token of admin user for authentication in scripting purpose. All I wanted to know how to use API to curl with token to get the result ? I tried following but couldn't get the required result.
curl --location --request GET 'http://rundeckhost:4440/metrics/ping' \
--header 'Accept: application/json' \
--header 'X-Rundeck-Auth-Token: <generated token here>'
My ENV spec:
OS : Centos 8 |
Java : 8 |
Rundeck: 3.3 community edition |
Scripting Language : curl, bash

Your ping API call is wrong, with the following call it works:
curl --location --request GET 'http://rundeckhost:4440/api/35/metrics/ping' \
--header 'Accept: application/json' \
--header 'X-Rundeck-Auth-Token: <your-token-here>'
Just in case, also you can use RD CLI tool for that, with the command:
$ rd metrics ping
Result:
# [2020-07-31T09:09:37.200] Pinging server...
# [2020-07-31T09:09:37.503] pong

More insight answer to my own question :
if anyone is having issues in using URL http://rundeckhost:4440/api/35/metrics/ping then it would be wrong api version which could be different for different versions of rundeck. so you can find out the right version by accessing your own rundeck http://rundeckhostIP:4440/api/ which will show up xml with api version in it as follows:
Use that version number in the querying URL in which in my case its 35.

Related

Isolated Azure Kubernetes Service (AKS) SSL Error

I deployed a helm chart onto an isolated server and in the self-signed certificate HTTPS post it does to the kube-api it is failing w/ this error:
curl: (35) OpenSSL SSL_connect: SSL_ERROR_SYSCALL in connection to kubernetes.default.svc:443
Anyone seen it before? This is the “POST”:
echo "Creating a secret for the certificate and keys"
STATUS=$(curl -ik \
-o ${TMP_DIR}/output \
-w "%{http_code}" \
-X POST \
-H "Authorization: Bearer $TOKEN" \
-H 'Accept: application/json' \
-H 'Content-Type: application/json' \
-d '{
"kind": "Secret",
"apiVersion": "v1",
"metadata": {
"name": "spark-webhook-certs",
"namespace": "'"$NAMESPACE"'"
},
"data": {
"ca-cert.pem": "'"$ca_cert"'",
"ca-key.pem": "'"$ca_key"'",
"server-cert.pem": "'"$server_cert"'",
"server-key.pem": "'"$server_key"'"
}
}' \
https://kubernetes.default.svc/api/v1/namespaces/${NAMESPACE}/secrets
The error is occuring due to a self signed certificate whose .sh is being invoked by a docker image command here: https://github.com/GoogleCloudPlatform/spark-on-k8s-operator/blob/master/hack/gencerts.sh
I know it's not getting to the end of this because it's failing to make the secret it's trying to post. Where do y'all think I should look to start troubleshooting? I've posted additional info here including screen shots: https://github.com/GoogleCloudPlatform/spark-on-k8s-operator/issues/926
I would try to update the contents of gencerts.sh to get some more context on the error:
Add the -v or --verbose option to the curl command.
Use strace to invoke the curl command
Both of those options will send more outputs to stderr so you should be able to inspect in your log and get a better idea of the failure mode. Fair warning: strace will generate a lot of output.
Another source of information would be the kube-apiserver logs. You'll need to enable collection of master logs by adjusting the configuration of your cluster. You should expect every API request to be logged by kube-apiserver.
The first question here is whether the request is received by the control plane at all. To troubleshoot this, I would get a shell on a container inside the cluster and try to recreate the curl request that gencerts.sh is making. There is some information on accessing the cluster API without kubectl in the kubernetes docs.

Unable to connect server via parse dashboard?

I have set up the parse-server and parse-dashboard in a dedicated instance on Alibaba Cloud with 2vCPU and 8GB of RAM with ApsaraDB for MongoDB as DB for Parse.
I successfully setup the dashboard and server. When I tried to access the server I get the following error,
"Unable to connect to server."
Parse Dashboard Error Screenshot
I am successfully able to make POST and GET Requests like below
curl -X POST \
-H "X-Parse-Application-Id: APPLICATION_ID" \
-H "Content-Type: application/json" \
-d '{"score":1337,"playerName":"Sean Plott","cheatMode":false}' \
http://localhost:1337/parse/classes/GameScore
//Response
{
"objectId": "2ntvSpRGIK",
"createdAt": "2016-03-11T23:51:48.050Z"
}
I am able to connect via putty and FTP.
Thanks
While your computer (by that I mean other applications) is reaching the server the Parse dashboard isn't.
Inside your dashboard config you can try changing
http://localhost:1337/parse
to
http://[ip-address]:1337/parse
Also go through this thread, you might be able to get some more insight on why it is not working:
https://github.com/parse-community/parse-dashboard/issues/785

Google FCM - can not subscribe to topic - returns 502 or "error INTERNAL"

Trying to subscribe device token to a topic on server. According to FCM server docs proceeding the request:
curl --header "Authorization: key=AAAA...qC1GXg" \
--header "Content-Type:application/json" \
-X POST -d '{}' \
"https://iid.googleapis.com/iid/v1/BY7kK...rbZ/rel/topics/mytopic"
which returns :
502. The server encountered a temporary error and could not complete your request.<p>Please try again in 30 seconds
The same 502 is returned when I'm trying to get token info with "details" parameter, like this:
curl --header "Authorization: key=AAAA...C1GXg" \
"https://iid.googleapis.com/iid/info/BY7kK...rbZ?details=true"
While if not adding "details" parameter, it all ok - it returns 200 and json data:
{"applicationVersion":"24","attestStatus":"UNKNOWN","application":"com.my.app","scope":"*","authorizedEntity":"...","appSigner":"...","platform":"ANDROID"}
I have also tried a batchAdd:
curl --header "Authorization: key=AAAA...81GXg" \
--header "Content-Type:application/json" \
-X POST \
-d '{"to":"/topics/mytopic", "registration_tokens": ["BY7k...rbZ"]}' \
"https://iid.googleapis.com/iid/v1:batchAdd"
and it ends up with :
{"results":[{"error":"INTERNAL"}]}
Authorization key and device token I use should be OK, since I can get token data (without topics), and sending messages to that device (also using curl) works OK.
Still, this 502 is happening for more than 24h for me so far.
That's a new FCM project - I'm not migrating from GCM or anything. Android app is live on market for some time, but I haven't used cloud messaging there before.
Any ideas with what could be wrong here? Thank you.
Found the cause. In case if someone will make the same mistake:
My Android app is published under one Google account, while I have created a project in Firebase console under a different account.
Having the app and Firebase project under same Google account - and all works like a charm.
Meanwhile, Google maps API keys, which also are used in my Android app, were generated under that second account, and everything is OK.

Load balancing in KONG API Gateway

We have multiple instance of a micro service behind the Kong API gateway where we want to balance the load for the user requests.
Say Micro service 1 is multiplied in multiple instances which are kept behind the KONG API gateway; in such case the request from user 1 should hit the first instance and the request from user 2 should hit some other instance of same service based on their availability (load balancing). (ie) Whether can i have multiple upstream URL for a single API in kong. we dont want to use nginx for load balancing. Please advice how can we solve it.
Ring-balancer Strategy can be used in Kong if you don't want DNS-based loadbalancing. For details please refer to Kong Load Balancing Reference!
# create an upstream
$ curl -X POST http://kong:8001/upstreams \
--data "name=address.v1.service"
# add two targets to the upstream
$ curl -X POST http://kong:8001/upstreams/address.v1.service/targets \
--data "target=192.168.34.15:80"
--data "weight=100"
$ curl -X POST http://kong:8001/upstreams/address.v1.service/targets \
--data "target=192.168.34.16:80"
--data "weight=50"
# create an API targeting the Blue upstream
$ curl -X POST http://kong:8001/apis/ \
--data "name=address-service" \
--data "hosts=address.mydomain.com" \
--data "upstream_url=http://address.v1.service/address"
Requests with host header set to address.mydomain.com will now be proxied by Kong to the two defined targets; 2/3 of the requests will go to http://192.168.34.15:80/address (weight=100), and 1/3 will go to http://192.168.34.16:80/address (weight=50).
Starting from 0.10 you will be able to create a named upstream, and associate/remove targets from it.
For example if you have upstream_url=http://helloworld/ you can create a helloworld upstream and associate targets to it:
curl -d "name=helloworld" 127.0.0.1:8001/upstreams
curl -d "host=some.host.com" 127.0.0.1:8001/upstreams/helloworld/targets/
curl -d "host=2.2.2.2" 127.0.0.1:8001/upstreams/helloworld/targets/

mule server auto deployment details

I am using mmc for deployment of mule based application. All deployed application through mmc goes to apps directory under mule server. If I put an application directly under mule-server/apps, launch the application, application runs successfully, but I am not able to view the deployment details in mmc. Where I need to make the changes in mule server to view the deployed application details in mmc?
I need to make a auto deployment through shell script. For this, I am creating a sample project, create zip file, copy this zip file under mule server apps direction. Finally, once mmc is launched, I need to see the deployed application in mmc for viewing flows, running application, flow analyzer etc.
EDIT
Based on answer given below to deploy a new application, I have given my url as:
curl --basic -u admin:admin -F file=#C:/apps/testserver-1.0.0-SNAPSHOT.zip -F name=test-app -F version=2.0 --header 'Content-Type: multipart/form-data' http://almule1.ux.corp.local:8585/mmc/api/repository
Response I received:
curl: (6) Could not resolve host: multipart {"versionId":"local$5015b8d6-b149-4245-a218-55c12aecc8e7","applicationId":"local$74616cb9-9ecb-4fd6-b167-bf153c8e59fb"}
I am using windows env to deploy in unix server.
MMC retrieves information from Mule ESB, so you shouldn't make any changes. Anyway I think that deploying an application outside MMC is not a good idea. For scripting purposes I would prefer to use MMC Deployments REST API. You can deploy an application by simply running:
Upload zipped application
This uploads your application to MMC.
curl --basic -u admin:admin -F file=#my-zipped-app.zip -F name=test-app -F version=2.0 --header 'Content-Type: multipart/form-data' http://localhost:8080/mmc/api/repository
List available servers
curl --basic -u admin:admin http://localhost:8080/mmc-console-3.4.0/api/servers
There you should get the server Id (let's suppose it is local$26f2fea8-3b7c-45a7-84a8-d1509e73fca4), then use it in this command:
Create deployment
Before starting your application you need to create a deployment telling MMC to which server, and the id of the uploaded application.
curl --basic -u admin:admin -d '{"name" : "ExampleDeployment" , "servers": [ "local$26f2fea8-3b7c-45a7-84a8-d1509e73fca4" ], "applications": [ "local$32bb47d3-d180-4bb9-8906-2378dad9ae21" ]}' --header 'Content-Type: application/json' http://localhost:8080/mmc/api/deployments
Perform deploy
Once you have a server and a deployment you can finally start the application.
curl --basic -u admin:admin -X POST 'http://localhost:8080/mmc/api/deployments/local$97e3c184-09ed-423e-a5a5-9b94713a9e36/deploy'
Here is the auto deployment on windows environment which deploys in Unix server.
Application Name: testserver-1.0.zip
step1: Upload
curl --basic -u admin:admin -F file=#C:/apps/testserver-1.0.zip -F name=auto-deploy-server -F version=1.0 --header "Content-Type: multipart/form-data" http://allmule1.ux.corp.local:8585/mmc/api/repository
Response:
{"versionId":"local$fd507b45-25c2-4cc9-afe9-9f020f685867","applicationId":"local$47bcf1f3-72bc-4c08-ba50-4fe33422199c"}
step2: Get server details:
curl --basic -u admin:admin http://allmule1.ux.corp.local:8585/mmc/api/servers
Response:
{"total":1,"data":[{"agents":[{......,"agentUrl":"https://localhost:7777/mmc-support","version":"3.4.2","name":"Mule-3.4.2","id":"local$5a6c4f81-7b35-425d-95bd-200224f60a2b"}]}
Note: Here server id is: local$5a6c4f81-7b35-425d-95bd-200224f60a2b
Get the VERSION ID (not application id) from step 1
step3: deployments
curl --basic -u admin:admin -d "{\"name\" : \"Auto-Deployment\" , \"servers\": [ \"local$5a6c4f81-7b35-425d-95bd-200224f60a2b\" ], \"applications\": [ \"local$fd507b45-25c2-4cc9-afe9-9f020f685867\" ]}" --header "Content-Type: application/json" http://allmule1.ux.corp.local:8585/mmc/api/deployments
Response:
{"applications":["local$fd...,"name":"Auto-Deployment","id":"local$9062bbe7-75ab-4658-b021-8314b1681511","lastModified":"Wed, 18 Jun 2014 12:27:30.610 PDT"}
Note here Deployment Id: local$9062bbe7-75ab-4658-b021-8314b1681511
Step4: Deploy
curl --basic -u admin:admin -X POST http://allmule1.ux.corp.local:8585/mmc/api/deployments/local$9062bbe7-75ab-4658-b021-8314b1681511/deploy
Response: The deployments were deployed
verify your server console, application might have deployed.
Redeploy
curl --basic -u admin:admin -X POST http://allmule1.ux.corp.local:8585/mmc/api/deployments/local$9062bbe7-75ab-4658-b021-8314b1681511/redeploy
Undeploy:
curl --basic -u admin:admin -X POST http://allmule1.ux.corp.local:8585/mmc/api/deployments/local$9062bbe7-75ab-4658-b021-8314b1681511/undeploy
Automated Deployment with Mule Management Console and Maven
https://dzone.com/articles/automated-deployment-mule?mz=38541-devops