-
Notifications
You must be signed in to change notification settings - Fork 270
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How can I get the termination information via webhook? #161
Comments
The default webhook request template is for slack webhooks. Depending on what server you're sending the request to, you may need to change the template to match the expected request body. There's an example in our end-to-end test suite where we change the template to the expected request structure for amazon chime webhooks:
|
@bwagner5 Thanks for your answering. |
@bwagner5 We're already running v1.3.1 on EKS 1.14. |
@HankChow I did a test with a flask server: Flask Source Code$ cat flaskapp.py
from flask import Flask
from flask import request
app = Flask(__name__)
@app.route('/', methods=['POST'])
def index():
print(request.data)
return aws-node-termination-handler local binary$ git clone [email protected]:aws/aws-node-termination-handler.git
$ cd aws-node-termination-handler
$ go build cmd/node-termination-handler.go
$ ./node-termination-handler --dry-run --node-name test --webhook-url http://localhost:5000 --metadata-url http://localhost:1338 EC2 Metadata Mock$ curl -Lo ec2-metadata-mock https://github.com/aws/amazon-ec2-metadata-mock/releases/download/v0.9.0/amazon-ec2-metadata-mock-$(uname | tr '[:upper:]' '[:lower:]')-amd64
$ chmod +x ec2-metadata-mock
$ ./ec2-metadata-mock spotitn
...
2020/05/14 14:38:02 Initiating amazon-ec2-metadata-mock for EC2 Spot interruption notice on port 1338
... Flask Stdout Log$ pip3 install flask
$ export FLASK_APP="flaskapp.py"
$ flask run
* Serving Flask app "flaskapp.py"
* Environment: production
WARNING: This is a development server. Do not use it in a production deployment.
Use a production WSGI server instead.
* Debug mode: off
* Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
b'{"text":"[NTH][Instance Interruption] EventID: spot-itn-1229fe2a46345395a6df93665219d2f184213a5edefed2092a2343c2ff797b63 - Kind: SPOT_ITN - Description: Spot ITN received. Instance will be interrupted at 2020-05-14T19:34:54Z \n - Start Time: 2020-05-14 19:34:54 +0000 UTC"}' Printing |
@bwagner5 Thanks for your answering. |
I have deployed aws-node-termination-handler as DaemonSet in an EKS cluster. I set the configuration of flags in order to receive notification via webhook when a spot instance terminates.
To test whether the flags will work, I only set the flag WEBHOOK_URL with a url which is listening for HTTP requests and leave blanks for other flags as default.
I did receive an POST request from a terminating spot instance in EKS cluster terminates. It is expected a JSON like
{"text":"[NTH][Instance Interruption] EventID: {{ .EventID }} - Kind: {{ .Kind }} - Description: {{ .Description }} - State: {{ .State }} - Start Time: {{ .StartTime }}"}
which provided by the official documentation. But I can't see anything in the request payload.The text was updated successfully, but these errors were encountered: