Repository navigation
Conversation
|
Hi @sarvaniy. Would you mind looking into the failing tests? |
|
If I'm reading the code correctly... This is just a port of Helm 2's implementation of Compare that to the output of Can you please look further into the implementation details of |
| return &Result{Created: resources}, nil | ||
| } | ||
|
|
||
| func (c *Client) Get(rel *release.Release) (string, error) { |
There was a problem hiding this comment.
This should accept a ResourceList similar to Create and Update. It should be the job of the client to call .Build to retrieve a result and pass that along to Get.
There was a problem hiding this comment.
Hi,
I had modified the code as per your suggestion. I had gone through "kubectl get" implementation in depper. I found that Transformrequests is used to get the status of resources instead of rely on packages internal to kubernetes/kubernetes.
I had modified the code and tested, it worked fine. Could you please review it. You can check the resources output in below conservations.
|
I started playing around with this to see what we can do. In order to get this to work, this code would need to rely on packages internal to kubernetes/kubernetes, in particular the I'm not sure this can reasonably be achieved without reintroducing the entire kubernetes client library code, which we went to great lengths to remove in Helm 3. For now, Let us know if you find out something different. |
|
@bacongobbler Thanks for update, as you suggest I will try to look into kubectl get implementation in deeper. |
… of release in helm status command Signed-off-by: sarvani mounika <[email protected]>
|
@bacongobbler Hi, I had gone through "kubectl get" implementation in depper. I found that Transformrequests is used to get the status of resources instead of rely on packages internal to kubernetes/kubernetes. I had modified the code and tested, it worked fine. example: NAME: prometheus ==> v1beta1/ClusterRole ==> v1beta1/ClusterRoleBinding ==> v1/Service ==> v1/DaemonSet ==> v1/Deployment ==> v1/ConfigMap ==> v1/PersistentVolumeClaim TEST SUITE: None Get the Prometheus server URL by running these commands in the same shell: The Prometheus alertmanager can be accessed via port 80 on the following DNS name from within your cluster: Get the Alertmanager URL by running these commands in the same shell: WARNING: Pod Security Policy has been moved to a global property.use .Values.podSecurityPolicy.enabled with pod-basedannotations(e.g. .Values.nodeExporter.podSecurityPolicy.annotations)################################################################################# The Prometheus PushGateway can be accessed via port 9091 on the following DNS name from within your cluster: Get the PushGateway URL by running these commands in the same shell: For more information on running Prometheus, visit: And I had Commited the same tested code. |
mattfarina
left a comment
There was a problem hiding this comment.
I really like that this is being worked on. I know of tools that use this and parse the information.
But, to make it better with JSON/YAML output I think there can be a better option... see below...
| req.Param("includeObject", "Object") | ||
| } | ||
|
|
||
| func (c *Client) Get(resources ResourceList) (string, error) { |
There was a problem hiding this comment.
If this is used with the normal display this would be fine. But, if JSON or YAML is the output the complex string is going to end up inside a key and not be easily parsed.
I would suggest getting the output should be different per type and a print time operation depending on the output format. This would be more useful for getting this information in a machine format.
There was a problem hiding this comment.
Hi Matt,
Commited code is worked fine for different output formats like yaml and json as well.
I think that in helm2 also the output is same, for "helm status" command with different output formats like yaml, json.
Below is the genearted output without format and with different format cases in helm3
Without output format case
helm status firsthelm-0-1579514513
NAME: firsthelm-0-1579514513
LAST DEPLOYED: Mon Jan 20 05:01:57 2020
NAMESPACE: default
STATUS: deployed
REVISION: 1
RESOURCES:
==> v1/Service
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
firsthelm-0-1579514513 ClusterIP 10.96.41.237 <none> 80/TCP 50d
==> v1/Deployment
NAME READY UP-TO-DATE AVAILABLE AGE
firsthelm-0-1579514513 1/1 1 1 50d
NOTES:
1. Get the application URL by running these commands:
export POD_NAME=$(kubectl get pods --namespace default -l "app.kubernetes.io/name=firsthelm,app.kubernetes.io/instance=firsthelm-0-1579514513" -o jsonpath="{.items[0].metadata.name}")
echo "Visit http://127.0.0.1:8080 to use your application"
kubectl port-forward $POD_NAME 8080:80
With yaml as output format
helm status firsthelm-0-1579514513 -o yaml
Resources: |2+
==> v1/Service
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
firsthelm-0-1579514513 ClusterIP 10.96.41.237 <none> 80/TCP 50d
==> v1/Deployment
NAME READY UP-TO-DATE AVAILABLE AGE
firsthelm-0-1579514513 1/1 1 1 50d
hooks:
- events:
- test
kind: Pod
last_run:
completed_at: ""
phase: ""
started_at: ""
manifest: |-
apiVersion: v1
kind: Pod
metadata:
name: "firsthelm-0-1579514513-test-connection"
labels:
app.kubernetes.io/name: firsthelm
helm.sh/chart: firsthelm-0.1.0
app.kubernetes.io/instance: firsthelm-0-1579514513
app.kubernetes.io/version: "1.0"
app.kubernetes.io/managed-by: Helm
annotations:
"helm.sh/hook": test-success
spec:
containers:
- name: wget
image: busybox
command: ['wget']
args: ['firsthelm-0-1579514513:80']
restartPolicy: Never
name: firsthelm-0-1579514513-test-connection
path: firsthelm/templates/tests/test-connection.yaml
info:
deleted: ""
description: Install complete
first_deployed: "2020-01-20T05:01:57.370835613-05:00"
last_deployed: "2020-01-20T05:01:57.370835613-05:00"
notes: |
1. Get the application URL by running these commands:
export POD_NAME=$(kubectl get pods --namespace default -l "app.kubernetes.io/name=firsthelm,app.kubernetes.io/instance=firsthelm-0-1579514513" -o jsonpath="{.items[0].metadata.name}")
echo "Visit http://127.0.0.1:8080 to use your application"
kubectl port-forward $POD_NAME 8080:80
status: deployed
manifest: |
---
# Source: firsthelm/templates/service.yaml
apiVersion: v1
kind: Service
metadata:
name: firsthelm-0-1579514513
labels:
app.kubernetes.io/name: firsthelm
helm.sh/chart: firsthelm-0.1.0
app.kubernetes.io/instance: firsthelm-0-1579514513
app.kubernetes.io/version: "1.0"
app.kubernetes.io/managed-by: Helm
spec:
type: ClusterIP
ports:
- port: 80
targetPort: http
protocol: TCP
name: http
selector:
app.kubernetes.io/name: firsthelm
app.kubernetes.io/instance: firsthelm-0-1579514513
---
# Source: firsthelm/templates/deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: firsthelm-0-1579514513
labels:
app.kubernetes.io/name: firsthelm
helm.sh/chart: firsthelm-0.1.0
app.kubernetes.io/instance: firsthelm-0-1579514513
app.kubernetes.io/version: "1.0"
app.kubernetes.io/managed-by: Helm
spec:
replicas: 1
selector:
matchLabels:
app.kubernetes.io/name: firsthelm
app.kubernetes.io/instance: firsthelm-0-1579514513
template:
metadata:
labels:
app.kubernetes.io/name: firsthelm
app.kubernetes.io/instance: firsthelm-0-1579514513
spec:
containers:
- name: firsthelm
image: "nginx:stable"
imagePullPolicy: IfNotPresent
ports:
- name: http
containerPort: 80
protocol: TCP
livenessProbe:
httpGet:
path: /
port: http
readinessProbe:
httpGet:
path: /
port: http
resources:
{}
name: firsthelm-0-1579514513
namespace: default
version: 1
With json as output format
helm status firsthelm-0-1579514513 -o json
{"name":"firsthelm-0-1579514513","info":{"first_deployed":"2020-01-20T05:01:57.370835613-05:00","last_deployed":"2020-01-20T05:01:57.370835613-05:00","deleted":"","description":"Install complete","status":"deployed","notes":"1. Get the application URL by running these commands:\n export POD_NAME=$(kubectl get pods --namespace default -l \"app.kubernetes.io/name=firsthelm,app.kubernetes.io/instance=firsthelm-0-1579514513\" -o jsonpath=\"{.items[0].metadata.name}\")\n echo \"Visit http://127.0.0.1:8080 to use your application\"\n kubectl port-forward $POD_NAME 8080:80\n"},"manifest":"---\n# Source: firsthelm/templates/service.yaml\napiVersion: v1\nkind: Service\nmetadata:\n name: firsthelm-0-1579514513\n labels:\n app.kubernetes.io/name: firsthelm\n helm.sh/chart: firsthelm-0.1.0\n app.kubernetes.io/instance: firsthelm-0-1579514513\n app.kubernetes.io/version: \"1.0\"\n app.kubernetes.io/managed-by: Helm\nspec:\n type: ClusterIP\n ports:\n - port: 80\n targetPort: http\n protocol: TCP\n name: http\n selector:\n app.kubernetes.io/name: firsthelm\n app.kubernetes.io/instance: firsthelm-0-1579514513\n---\n# Source: firsthelm/templates/deployment.yaml\napiVersion: apps/v1\nkind: Deployment\nmetadata:\n name: firsthelm-0-1579514513\n labels:\n app.kubernetes.io/name: firsthelm\n helm.sh/chart: firsthelm-0.1.0\n app.kubernetes.io/instance: firsthelm-0-1579514513\n app.kubernetes.io/version: \"1.0\"\n app.kubernetes.io/managed-by: Helm\nspec:\n replicas: 1\n selector:\n matchLabels:\n app.kubernetes.io/name: firsthelm\n app.kubernetes.io/instance: firsthelm-0-1579514513\n template:\n metadata:\n labels:\n app.kubernetes.io/name: firsthelm\n app.kubernetes.io/instance: firsthelm-0-1579514513\n spec:\n containers:\n - name: firsthelm\n image: \"nginx:stable\"\n imagePullPolicy: IfNotPresent\n ports:\n - name: http\n containerPort: 80\n protocol: TCP\n livenessProbe:\n httpGet:\n path: /\n port: http\n readinessProbe:\n httpGet:\n path: /\n port: http\n resources:\n {}\n","hooks":[{"name":"firsthelm-0-1579514513-test-connection","kind":"Pod","path":"firsthelm/templates/tests/test-connection.yaml","manifest":"apiVersion: v1\nkind: Pod\nmetadata:\n name: \"firsthelm-0-1579514513-test-connection\"\n labels:\n app.kubernetes.io/name: firsthelm\n helm.sh/chart: firsthelm-0.1.0\n app.kubernetes.io/instance: firsthelm-0-1579514513\n app.kubernetes.io/version: \"1.0\"\n app.kubernetes.io/managed-by: Helm\n annotations:\n \"helm.sh/hook\": test-success\nspec:\n containers:\n - name: wget\n image: busybox\n command: ['wget']\n args: ['firsthelm-0-1579514513:80']\n restartPolicy: Never","events":["test"],"last_run":{"started_at":"","completed_at":"","phase":""}}],"version":1,"namespace":"default","Resources":"\n==\u003e v1/Service\nNAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE\nfirsthelm-0-1579514513 ClusterIP 10.96.41.237 \u003cnone\u003e 80/TCP 50d\n\n==\u003e v1/Deployment\nNAME READY UP-TO-DATE AVAILABLE AGE\nfirsthelm-0-1579514513 1/1 1 1 50d\n\n"}
There was a problem hiding this comment.
The release part of this is a string of the output. Instead, we should have that as structured metadata. It doesn't need to be the same as the output of kubectl get po --output json. I would expect the structure to be a JSON object that represents the table as JSON.
Right now (in Helm v2) machines need to use a regex to parse the content of the status information. That includes getting information about things like pods. If this was represented as JSON/YAML when the output was JSON or YAML it would make machines using this easier.
There was a problem hiding this comment.
@sarvaniy this seems to require fixing, are you able to do that?
|
Hi All, Could you please review the code and comments. Thanks in advance |
|
Hi All, |
mattfarina
left a comment
There was a problem hiding this comment.
Thanks for the continued work on this. I just worked out how to do this with Helm v2 (see PR link in comments). Helm v2 has a simpler situation as the JSON/YAML output we expect to be different. I commented on the previous thread about that as well.
| group := metav1beta1.GroupName | ||
| version := metav1beta1.SchemeGroupVersion.Version | ||
|
|
||
| tableParam := fmt.Sprintf("application/json;as=Table;v=%s;g=%s, application/json", version, group) |
There was a problem hiding this comment.
This should also accept the v1 as well as the v1beta1. You can see the work I did for Helm v2 on this at #7785.
There was a problem hiding this comment.
Hi Matt,
Thanks for the explanation. As you suggest, i made changes inorder to support both metav1 and metav1beta1 cases. I had gone through the above PR link and used the structured metadata for JSON/YAML. Everything is working fine.
Below are the code-snippet changes.
func transformRequests(req *rest.Request) {
tableParam := strings.Join([]string{
fmt.Sprintf("application/json;as=Table;v=%s;g=%s", metav1.SchemeGroupVersion.Version, metav1.GroupName),
fmt.Sprintf("application/json;as=Table;v=%s;g=%s", metav1beta1.SchemeGroupVersion.Version, metav1beta1.GroupName),
"application/json",
}, ",")
req.SetHeader("Accept", tableParam)
// if sorting, ensure we receive the full object in order to introspect its fields via jsonpath
req.Param("includeObject", "Object")
}
func sortTableSlice(objs []runtime.Object) []runtime.Object {
if len(objs) < 2 {
return objs
}
ntbl := &metav1.Table{}
// Sort the list of objects
var newObjs []runtime.Object
namesCache := make(map[string]runtime.Object, len(objs))
var names []string
for _, obj := range objs {
unstr, ok := obj.(*unstructured.Unstructured)
if !ok {
return objs
}
if err := runtime.DefaultUnstructuredConverter.FromUnstructured(unstr.Object, ntbl); err != nil {
return objs
}
namesCache[ntbl.GetSelfLink()] = obj
names = append(names, ntbl.GetSelfLink())
}
sort.Strings(names)
for _, name := range names {
newObjs = append(newObjs, namesCache[name])
}
return newObjs
}
func (c *Client) Get(resources ResourceList) (string, error) {
buf := new(bytes.Buffer)
printFlags := get.NewHumanPrintFlags()
typePrinter, _ := printFlags.ToPrinter("")
printer := &get.TablePrinter{Delegate: typePrinter}
objs := make(map[string][]runtime.Object)
err := resources.Visit(func(info *resource.Info, err error) error {
if err != nil {
return err
}
gvk := info.ResourceMapping().GroupVersionKind
vk := gvk.Version + "/" + gvk.Kind
obj, err := getResource(info)
if err != nil {
return err
}
objs[vk] = append(objs[vk], obj)
return nil
})
if err != nil {
return "", err
}
var sortingkeys []string
for key := range objs {
sortingkeys = append(sortingkeys, key)
}
// Sort alphabetically by version/kind keys
sort.Strings(sortingkeys)
for _, t := range sortingkeys {
if _, err = fmt.Fprintf(buf, "==> %s\n", t); err != nil {
return "", err
}
vk := objs[t]
vk = sortTableSlice(vk)
for _, resource := range vk {
if err := printer.PrintObj(resource, buf); err != nil {
c.Log("failed to print object type %s: %v", t, err)
return "", err
}
}
if _, err := buf.WriteString("\n"); err != nil {
return "", err
}
}
return buf.String(), nil
}
func getResource(info *resource.Info) (runtime.Object, error) {
obj, err := resource.NewHelper(info.Client, info.Mapping).Get(info.Namespace, info.Name, false)
if err != nil {
return nil, err
}
return obj, nil
}
Could you please look into it and let me know is this okay or not. If yes, then i will commit the code changes.
There was a problem hiding this comment.
This part looks ok. Once I have the PR to review in a full code editor I can do a better review. I look forward to seeing your changes.
There was a problem hiding this comment.
Hi Matt,
I had commited the changes. Could you please review the code.
Latest() should not have been added Validate Closes helm#7728 Signed-off-by: Matt Farina <[email protected]>
|
Hi Matt, |
|
Thanks Matt
…On Fri, Mar 27, 2020, 6:07 PM Matt Farina ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In pkg/kube/client.go
<#7728 (comment)>:
> @@ -105,6 +109,64 @@ func (c *Client) Create(resources ResourceList) (*Result, error) {
return &Result{Created: resources}, nil
}
+func transformRequests(req *rest.Request) {
+ group := metav1beta1.GroupName
+ version := metav1beta1.SchemeGroupVersion.Version
+
+ tableParam := fmt.Sprintf("application/json;as=Table;v=%s;g=%s, application/json", version, group)
This part looks ok. Once I have the PR to review in a full code editor I
can do a better review. I look forward to seeing your changes.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#7728 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/ANQYGPNZAEFKR42GHQL3NQLRJSM2PANCNFSM4LBEAEHA>
.
|
|
I will do Matt. :)
On Fri, Mar 27, 2020, 6:23 PM Yakkala Mounika <[email protected]>
wrote:
… Thanks Matt
On Fri, Mar 27, 2020, 6:07 PM Matt Farina ***@***.***>
wrote:
> ***@***.**** commented on this pull request.
> ------------------------------
>
> In pkg/kube/client.go
> <#7728 (comment)>:
>
> > @@ -105,6 +109,64 @@ func (c *Client) Create(resources ResourceList) (*Result, error) {
> return &Result{Created: resources}, nil
> }
>
> +func transformRequests(req *rest.Request) {
> + group := metav1beta1.GroupName
> + version := metav1beta1.SchemeGroupVersion.Version
> +
> + tableParam := fmt.Sprintf("application/json;as=Table;v=%s;g=%s, application/json", version, group)
>
> This part looks ok. Once I have the PR to review in a full code editor I
> can do a better review. I look forward to seeing your changes.
>
> —
> You are receiving this because you were mentioned.
> Reply to this email directly, view it on GitHub
> <#7728 (comment)>, or
> unsubscribe
> <https://github.com/notifications/unsubscribe-auth/ANQYGPNZAEFKR42GHQL3NQLRJSM2PANCNFSM4LBEAEHA>
> .
>
|
accept both v1 and v1beta Signed-off-by: sarvani mounika <[email protected]>
|
Hi Matt, Thanks. |
|
Hi Matt, I had commited the changes. Could you please review the code. Thanks. |
merged now ? |
|
Hi svolence, Just now , i had resolved the merge conflicts, you can merge it. Thanks for the response. |
Signed-off-by: yakkala sarvani mounika <[email protected]>
|
Hopefully this PR doesn't die. This is something I and others would still love to have. Very much missed from helm2. |
|
@sarvaniy hi,pod display repeats if statefulset resources are available. |
|
This feature in Helm 2 enables a lot of cool workflows like ensuring that all Helm-installed chart objects are still present in the cluster. This has saved us a few times after devs accidentally deleted a deployment :D Helm 3 really, really needs this. |
|
Throwing this onto the 3.6.0 milestone for (re-)review. |
|
This adds a method to an Interface, which is defined as a breaking change by the Go authors. To refactor that, we'd have to add another interface that just has the |
|
Unfortunately, this can't be merged. The |
|
@koulq can you look through this PR and identify what might be causing that issue? How does it affect |
|
@koulq any help here on identifying this or what's causing it? We would love to see this get over the finish line. |
|
Unfortunately, it looks like this PR has become stale since the last time we provided feedback. As a result we won't be able to merge it into Helm 3.7 in its current state. Several others have found bugs with the implementation that need further inspection. So, if someone wants to take over the work here and re-submit a new pull request with the changes suggested earlier, there is a slim chance we could bring this into Helm 3.7. Removing from Helm 3.7's milestone for now. |
…oyed as part of release in helm status command Creating a new PR based on this existing stale PR helm#7728 Signed-off-by: SoujanyaMangipudi <[email protected]>
…oyed as part of release in helm status command Creating a new PR based on this existing stale PR helm#7728 Signed-off-by: SoujanyaMangipudi <[email protected]> Signed-off-by: Soujanya Mangipudi <[email protected]>
…oyed as part of release in helm status command Creating a new PR based on this existing stale PR helm#7728 Signed-off-by: SoujanyaMangipudi <[email protected]> Signed-off-by: Soujanya Mangipudi <[email protected]>
…oyed as part of release in helm status command Creating a new PR based on this existing stale PR helm#7728 Signed-off-by: Soujanya Mangipudi <[email protected]>
…oyed as part of release in helm status command Creating a new PR based on this existing stale PR helm#7728 Signed-off-by: Soujanya Mangipudi <[email protected]> # Conflicts: # go.sum
…oyed as part of release in helm status command Creating a new PR based on this existing stale PR helm#7728 Signed-off-by: Soujanya Mangipudi <[email protected]> # Conflicts: # go.sum
|
Closing as an alternative PR for this has been merged. |


… of release in helm status command