sostheim / krak8s Goto Github PK
View Code? Open in Web Editor NEWAPI Service for Kraken and Kubernetes Commands
License: Apache License 2.0
API Service for Kraken and Kubernetes Commands
License: Apache License 2.0
See linked issue: https://github.com/reactioncommerce/launchdock/issues/80
Deleting a resource record while that resource is still being created causes the application to drop a stack trace and fails to resolve the state after the failure.
A deleted project is not having it's complete configuration and resources removed.
Initially reported by @jshimko
implement required changes to kraken config.yaml
Resolve errors in deleting objects from the api resources.
When you delete a namespace that has a cluster associated with it, the cluster resource is deleted from krak8s as expected, but it doesn't actually delete anything from AWS.
The API spec has several inconsistently formatted inputs in the request bodies. There are underscores, camelCase, no separation (as with namespaceid
for listing applications), etc. In several cases, there are a mix of these syntaxes within the same object.
Also, every resource endpoint other than clusters is a plural noun (clusters is /v1/projects/${projectId}/cluster
). It also looks like you can't list clusters because that endpoint doesn't exist. Every other resource type can be listed.
Initially reported by @jshimko
GET /v1/projects/5669723d/namespaces
"panic: runtime error: invalid memory address or nil pointer dereference\npanic(0x1434180, 0x200aeb0)\n\t/usr/local/go/src/runtime/panic.go:491 +0x283\nmain.MarshalNamespaceObject(0x0, 0x1)\n\t/go/src/krak8s/namespace.go:34 +0x39\nmain.(*NamespaceController).List(0xc42020e050, 0xc4201f22a0, 0xc4203d8800, 0xc420356ea0)\n\t/go/src/krak8s/namespace.go:107 +0x103\nkrak8s/app.MountNamespaceController.func4(0x2031b00, 0xc4201f2240, 0x202ac40, 0xc4203b7a40, 0xc4203d8800, 0xc4203bd3f8, 0xc4203bd400)\n\t/go/src/krak8s/app/controllers.go:335 +0xdd\nkrak8s/vendor/github.com/goadesign/goa.(*Controller).MuxHandler.func1.1(0x2031b00, 0xc4201f2240, 0x202ac40, 0xc4203b7a40, 0xc4203d8800, 0x2, 0x0)\n\t/go/src/krak8s/vendor/github.com/goadesign/goa/service.go:270 +0xaa\nkrak8s/vendor/github.com/goadesign/goa/middleware.Recover.func1.1(0x2031b00, 0xc4201f2240, 0x202ac40, 0xc4203b7a40, 0xc4203d8800, 0x0, 0x0)\n\t/go/src/krak8s/vendor/github.com/goadesign/goa/middleware/recover.go:37 +0xa0\nkrak8s/vendor/github.com/goadesign/goa/middleware.ErrorHandler.func1.1(0x2031b00, 0xc4201f2240, 0x202ac40, 0xc4203b7a40, 0xc4203d8800, 0x2, 0x2)\n\t/go/src/krak8s/vendor/github.com/goadesign/goa/middleware/error_handler.go:21 +0x90\nkrak8s/vendor/github.com/goadesign/goa/middleware.LogRequest.func1.1(0x2031b00, 0xc4201f2240, 0x202ac40, 0xc4203b7a40, 0xc4203d8800, 0xc420254080, 0x2031b00)\n\t/go/src/krak8s/vendor/github.com/goadesign/goa/middleware/log_request.go:75 +0xd48\nkrak8s/vendor/github.com/goadesign/goa/middleware.RequestIDWithHeaderAndLengthLimit.func1.1(0x2031b00, 0xc4201f21e0, 0x202ac40, 0xc4203b7a40, 0xc4203d8800, 0xc4201f2150, 0x2031b00)\n\t/go/src/krak8s/vendor/github.com/goadesign/goa/middleware/request_id.go:63 +0x144\nkrak8s/vendor/github.com/goadesign/goa.(*Controller).MuxHandler.func1(0x2030980, 0xc4201fe0e0, 0xc4203d8800, 0xc4201f2150)\n\t/go/src/krak8s/vendor/github.com/goadesign/goa/service.go:303 +0x336\nkrak8s/vendor/github.com/goadesign/goa.(*mux).Handle.func1(0x2030980, 0xc4201fe0e0, 0xc4203d8800, 0xc4201f20f0)\n\t/go/src/krak8s/vendor/github.com/goadesign/goa/mux.go:59 +0x1cb\nkrak8s/vendor/github.com/dimfeld/httptreemux.(*TreeMux).ServeLookupResult(0xc420292140, 0x2030980, 0xc4201fe0e0, 0xc4203d8800, 0xc8, 0xc42020e1b0, 0xc4201f20f0, 0x0)\n\t/go/src/krak8s/vendor/github.com/dimfeld/httptreemux/router.go:245 +0x133\nkrak8s/vendor/github.com/dimfeld/httptreemux.(*TreeMux).ServeHTTP(0xc420292140, 0x2030980, 0xc4201fe0e0, 0xc4203d8800)\n\t/go/src/krak8s/vendor/github.com/dimfeld/httptreemux/router.go:266 +0xdb\nkrak8s/vendor/github.com/goadesign/goa.(*mux).ServeHTTP(0xc420285a80, 0x2030980, 0xc4201fe0e0, 0xc4203d8800)\n\t/go/src/krak8s/vendor/github.com/goadesign/goa/mux.go:85 +0x4c\nnet/http.serverHandler.ServeHTTP(0xc42040fee0, 0x2030980, 0xc4201fe0e0, 0xc4203d8800)\n\t/usr/local/go/src/net/http/server.go:2619 +0xb4\nnet/http.(*conn).serve(0xc42018a1e0, 0x2031a40, 0xc4201b1040)\n\t/usr/local/go/src/net/http/server.go:1801 +0x71d\ncreated by net/http.(*Server).Serve\n\t/usr/local/go/src/net/http/server.go:2720 +0x288\n"
Currently the system does a very simple, to simple, brute force search for duplicate terms in the kraken configuration files. If a duplicate is detected, the action is rejected.
Need to improve the communication of the status on a duplicate instance to the client
Need to improve the fidelity of checking for duplicate names to understand the object and it's context before rejecting the action
Need to add user documentation to inform client's of the API what the rules are concerning duplicate, e.g. naming requirements.
As mentioned in Slack last night, the API currently does not work. Just opening an issue to track progress.
I’ve followed the readme examples for the API and I don’t seem to be able to actually create a new cluster. Here are my exact requests/responses (run from inside the Launchdock pod within the cluster). The created cluster never leaves the
create_requested
state and no new nodes have been created.
# create project
curl -X POST -H "Content-Type: application/json" -d '{"name":"acme"}' http://10.37.8.171:8080/v1/projects
{
"created_at": "2017-08-29T00:03:31.043193048Z",
"id": "f614ab6e",
"name": "acme",
"namespaces": null,
"type": "project"
}
# create namespace
curl -X POST -H "Content-Type: application/json" -d '{"name":"acme-prod"}' http://10.37.8.171:8080/v1/projects/f614ab6e/namespaces
{
"applications": null,
"created_at": "2017-08-29T00:06:07.85514329Z",
"id": "298f91ef",
"name": "acme-prod",
"resources": null,
"type": "namespace"
}
# create cluster
curl -X POST -H "Content-Type: application/json" -d '{"namespace_id":"298f91ef", "nodePoolSize": 5}' http://10.37.8.171:8080/v1/projects/f614ab6e/cluster
{
"created_at": "2017-08-29T01:07:28.912574145Z",
"id": "b0ef89bd",
"namespace_id": "298f91ef",
"nodePoolSize": 5,
"state": "create_requested",
"type": "Resource",
"updated_at": "0001-01-01T00:00:00Z"
}
# note that cluster is sitting in "create_requested" state 30 mins later
curl http://10.37.8.171:8080/v1/projects/f614ab6e/cluster/b0ef89bd
{
"created_at": "2017-08-29T01:07:28.912574145Z",
"id": "b0ef89bd",
"namespace_id": "298f91ef",
"nodePoolSize": 5,
"state": "create_requested",
"type": "Resource",
"updated_at": "0001-01-01T00:00:00Z"
}
I have a project, namespace, cluster, etc. and a single application running. I can query for the single application and successfully get it, but I can't list applications in that same namespace.
# GET the single app
curl http://localhost:8080/v1/projects/77907b06/applications/bb7dd432
{
"channel": "stable",
"config": "",
"created_at": "2017-09-18T13:35:53.981897503Z",
"deployment_name": "jeremy-mongodb",
"id": "bb7dd432",
"json_values": "",
"name": "mongodb-replicaset",
"namespace_id": "02678191",
"registry": "quay.io/samsung_cnct",
"server": "quay.io",
"status": {
"deployed_at": "2017-09-18T13:35:57.832285003Z",
"state": "DEPLOYED"
},
"type": "application",
"updated_at": "2017-09-18T13:35:57.832285386Z",
"username": "",
"version": "latest"
}
# GET all apps in that same namespace
curl http://localhost:8080/v1/projects/77907b06/applications \
-H "Content-Type: application/json" \
-d '{ "namespaceid": "02678191" }'
{
"id": "9PjU+W/E",
"code": "invalid_request",
"status": 400,
"detail": "missing required payload"
}
Yes, I realize my body has namespaceid
instead of namespace_id
, but that’s what the spec says. Regardless, I tried both ways and got the same result.
Just to show you that the namespace definitely exists...
curl http://localhost:8080/v1/projects/77907b06/namespaces/02678191
{
"applications": [
{
"oid": "bb7dd432",
"url": "/v1/projects/77907b06/applications/bb7dd432"
}
],
"created_at": "2017-09-11T21:49:32.759664083Z",
"id": "02678191",
"name": "jeremy",
"resources": {
"oid": "e322aa1c",
"url": "/v1/projects/77907b06/cluster/e322aa1c"
},
"type": "namespace"
}
I’ve been trying to get a Mongo deployment to happen via krak8s for hours and I’m still not seeing anything other than a single pending pod.
# proxying to localhost with kubectl...
curl -X "POST" "http://localhost:8080/v1/projects/77907b06/applications" \
-H "Content-Type: application/json" \
-d $'{
"deployment_name": "jeremy-mongodb",
"registry": "quay.io/samsung_cnct",
"namespace_id": "02678191",
"name": "mongodb-replicaset",
"channel": "stable",
"version": "latest"
}'
10-15 mins later…
curl http://localhost:8080/v1/projects/77907b06/applications/bb7dd432
{
"channel": "stable",
"config": "",
"created_at": "2017-09-18T13:35:53.981897503Z",
"deployment_name": "jeremy-mongodb",
"id": "bb7dd432",
"json_values": "",
"name": "mongodb-replicaset",
"namespace_id": "02678191",
"registry": "quay.io/samsung_cnct",
"server": "quay.io",
"status": {
"deployed_at": "2017-09-18T13:35:57.832285003Z",
"state": "DEPLOYED"
},
"type": "application",
"updated_at": "2017-09-18T13:35:57.832285386Z",
"username": "",
"version": "latest"
}
However…
kubectl get pods -n jeremy
NAME READY STATUS RESTARTS AGE
jeremy-mongodb-mongodb-replicaset-0 0/1 Pending 0 11m
and…
kubectl get deploy -n jeremy
No resources found.
As shown in #10 - a failed application deployment is not actually being deployed (fixed in linked issue).
Still at issue is the fact that the deployment status being reported when queried is:
"status": {
"deployed_at": "2017-09-18T13:35:57.832285003Z",
"state": "DEPLOYED"
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.