Skip to content
This repository has been archived by the owner on Jul 23, 2020. It is now read-only.

API: Provide websocket support #2528

Closed
2 tasks
jiekang opened this issue Mar 9, 2018 · 9 comments
Closed
2 tasks

API: Provide websocket support #2528

jiekang opened this issue Mar 9, 2018 · 9 comments

Comments

@jiekang
Copy link
Collaborator

jiekang commented Mar 9, 2018

Parent: #2380

Task

Provide websocket based API for the deployments page

Sub-Tasks

  • Provide events API
  • Provide pods API
@jiekang
Copy link
Collaborator Author

jiekang commented May 31, 2018

Sample Events data from k8s

{
	"metadata": {
		"name": "osio-prod-1.1533c1b153fafd6f",
		"namespace": "jkang-stage",
		"selfLink": "/api/v1/namespaces/jkang-stage/events/osio-prod-1.1533c1b153fafd6f",
		"uid": "a643f0b5-64e0-11e8-8d2f-02e52a0be43d",
		"resourceVersion": "1133031845",
		"creationTimestamp": "2018-05-31T14:41:05Z"
	},
	"involvedObject": {
		"kind": "DeploymentConfig",
		"namespace": "jkang-stage",
		"name": "osio-prod-1",
		"uid": "1b494f1a-5e29-11e8-a0e5-02d7377a4b17",
		"apiVersion": "apps.openshift.io",
		"resourceVersion": "1133031843"
	},
	"reason": "ReplicationControllerScaled",
	"message": "Scaled replication controller \"osio-prod-1-3\" from 2 to 1",
	"source": {
		"component": "deploymentconfig-controller"
	},
	"firstTimestamp": "2018-05-31T14:41:05Z",
	"lastTimestamp": "2018-05-31T14:41:05Z",
	"count": 1,
	"type": "Normal"
}

{
	"metadata": {
		"name": "osio-prod-1-3.1533c0a028f7976e",
		"namespace": "jkang-stage",
		"selfLink": "/api/v1/namespaces/jkang-stage/events/osio-prod-1-3.1533c0a028f7976e",
		"uid": "eaf47ee6-64dd-11e8-8c9e-0233cba325d9",
		"resourceVersion": "1133018536",
		"creationTimestamp": "2018-05-31T14:21:32Z"
	},
	"involvedObject": {
		"kind": "ReplicationController",
		"namespace": "jkang-stage",
		"name": "osio-prod-1-3",
		"uid": "d1a40fee-6422-11e8-8445-02e52a0be43d",
		"apiVersion": "v1",
		"resourceVersion": "1133018419"
	},
	"reason": "FailedCreate",
	"message": "(combined from similar events): Error creating: pods \"osio-prod-1-3-mtbrw\" is forbidden: exceeded quota: compute-resources, requested: limits.cpu=1,limits.memory=512Mi, used: limits.cpu=2,limits.memory=1Gi, limited: limits.cpu=2,limits.memory=1Gi",
	"source": {
		"component": "replication-controller"
	},
	"firstTimestamp": "2018-05-31T14:21:32Z",
	"lastTimestamp": "2018-05-31T14:21:40Z",
	"count": 3,
	"type": "Warning"
}

@jiekang
Copy link
Collaborator Author

jiekang commented Jun 13, 2018

Another sample:

{
	"metadata": {
		"name": "abc-123-1-bzmhz.1537c7865275bc9d",
		"namespace": "jkang-stage",
		"selfLink": "/api/v1/namespaces/jkang-stage/events/abc-123-1-bzmhz.1537c7865275bc9d",
		"uid": "04f86fc4-6f2d-11e8-bc5d-0233cba325d9",
		"resourceVersion": "1146081162",
		"creationTimestamp": "2018-06-13T17:12:58Z"
	},
	"involvedObject": {
		"kind": "Pod",
		"namespace": "jkang-stage",
		"name": "abc-123-1-bzmhz",
		"uid": "035d2fd8-6f2d-11e8-99de-02d7377a4b17",
		"apiVersion": "v1",
		"resourceVersion": "1146081121",
		"fieldPath": "spec.containers{vertx}"
	},
	"reason": "Pulled",
	"message": "Successfully pulled image \"docker-registry.default.svc:5000/jkang-stage/abc-123@sha256:4c1bb4adcdd3d462b1f3953ce947afc0c3afcd0dd810c007f4d3ed56220ac323\"",
	"source": {
		"component": "kubelet",
		"host": "ip-172-31-69-6.us-east-2.compute.internal"
	},
	"firstTimestamp": "2018-06-13T17:12:58Z",
	"lastTimestamp": "2018-06-13T17:12:58Z",
	"count": 1,
	"type": "Normal"
}

@jiekang
Copy link
Collaborator Author

jiekang commented Jun 13, 2018

Suggested reduced data object returned by deployments API

{
  involvedObject: {
    kind,
    namespace,
    name,
  },
  reason,
  message,
  count,
  type,
}

@andrewazores Thoughts? Do you think the information here will cover our needs? Are there any fields that could be dropped, or maybe added?

@andrewazores
Copy link
Collaborator

The timestamps might be useful at least for logging purposes, so I'd add those. Otherwise I think it's a good minimal set.

@jiekang
Copy link
Collaborator Author

jiekang commented Jun 13, 2018

For timestamps we have

metadata.creationTimestamp: CreationTimestamp is a timestamp representing the server time when this object was created.

firstTimestamp: The time at which the event was first recorded. (Time of server receipt is in TypeMeta.)
lastTimestamp: The time at which the most recent occurrence of this event was recorded.

Which were you thinking of? All three? Or maybe metadata.creationTimestamp is sufficient? Or just the first/last, hahah.

@andrewazores
Copy link
Collaborator

Hmm. Not really sure. Maybe creationTimestamp?

@jiekang
Copy link
Collaborator Author

jiekang commented Jun 14, 2018

Yeah if anything it can be changed pretty easily.

Sample transformed object:

{
	"involvedObject": {
		"kind": "ReplicationController",
		"namespace": "jkang-stage",
		"name": "abc-123-1",
		"uid": "0187287e-6f2d-11e8-bc5d-0233cba325d9",
		"apiVersion": "v1",
		"resourceVersion": "1146930893"
	},
	"reason": "FailedCreate",
	"message": "Error creating: pods \"abc-123-1-fn79z\" is forbidden: exceeded quota: compute-resources, requested: limits.cpu=1,limits.memory=512Mi, used: limits.cpu=2,limits.memory=1Gi, limited: limits.cpu=2,limits.memory=1Gi",
	"count": 1,
	"type": "Warning",
	"creationTimestamp": "2018-06-14T12:41:39Z"
}

@andrewazores
Copy link
Collaborator

That looks like it'll meet our needs.

@jiekang
Copy link
Collaborator Author

jiekang commented Aug 30, 2018

Feature has been merged. Closing.

@jiekang jiekang closed this as completed Aug 30, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants