@@ -31,6 +31,7 @@ import (
3131 batchv1 "k8s.io/api/batch/v1"
3232 batchv1beta1 "k8s.io/api/batch/v1beta1"
3333 corev1 "k8s.io/api/core/v1"
34+ networkingv1 "k8s.io/api/networking/v1"
3435 policyv1 "k8s.io/api/policy/v1"
3536 policyv1beta1 "k8s.io/api/policy/v1beta1"
3637 apierrors "k8s.io/apimachinery/pkg/api/errors"
@@ -65,7 +66,8 @@ or attach as a email reply to your existing Support Ticket` + "\n"
6566Please request file share link by emailing [email protected] ` + "\n " 6667)
6768
68- var namespacedResources = []schema.GroupVersionResource {{
69+ // namespaced resources that have a cluster Label
70+ var clusterNamespacedResources = []schema.GroupVersionResource {{
6971 Group : appsv1 .SchemeGroupVersion .Group ,
7072 Version : appsv1 .SchemeGroupVersion .Version ,
7173 Resource : "statefulsets" ,
@@ -126,6 +128,17 @@ var removedNamespacedResources = []schema.GroupVersionResource{{
126128 Resource : "poddisruptionbudgets" ,
127129}}
128130
131+ // namespaced resources that impact PGO created objects in the namespace
132+ var otherNamespacedResources = []schema.GroupVersionResource {{
133+ Group : networkingv1 .SchemeGroupVersion .Group ,
134+ Version : networkingv1 .SchemeGroupVersion .Version ,
135+ Resource : "ingresses" ,
136+ }, {
137+ Group : corev1 .SchemeGroupVersion .Group ,
138+ Version : corev1 .SchemeGroupVersion .Version ,
139+ Resource : "limitranges" ,
140+ }}
141+
129142// newSupportCommand returns the support subcommand of the PGO plugin.
130143func newSupportExportCommand (config * internal.Config ) * cobra.Command {
131144 cmd := & cobra.Command {
@@ -142,7 +155,9 @@ PostgresCluster.
142155 deployments.apps [list]
143156 endpoints [list]
144157 events [get list]
158+ ingresses.networking.k8s.io [list]
145159 jobs.batch [list]
160+ limitranges [list]
146161 namespaces [get]
147162 nodes [list]
148163 persistentvolumeclaims [list]
@@ -300,7 +315,20 @@ kubectl pgo support export daisy --monitoring-namespace another-namespace --outp
300315
301316 // TODO (jmckulk): pod describe output
302317 if err == nil {
303- err = gatherNamespacedAPIResources (ctx , dynamicClient , namespace , clusterName , tw , cmd )
318+ // get Namespaced resources that have cluster label
319+ nsListOpts := metav1.ListOptions {
320+ LabelSelector : "postgres-operator.crunchydata.com/cluster=" + clusterName ,
321+ }
322+ err = gatherNamespacedAPIResources (ctx , dynamicClient , namespace ,
323+ clusterName , clusterNamespacedResources , nsListOpts , tw , cmd )
324+ }
325+
326+ if err == nil {
327+ // get other Namespaced resources that do not have the cluster label
328+ // but may otherwise impact the PostgresCluster's operation
329+ otherListOpts := metav1.ListOptions {}
330+ err = gatherNamespacedAPIResources (ctx , dynamicClient , namespace ,
331+ clusterName , otherNamespacedResources , otherListOpts , tw , cmd )
304332 }
305333
306334 if err == nil {
@@ -556,14 +584,13 @@ func gatherNamespacedAPIResources(ctx context.Context,
556584 client dynamic.Interface ,
557585 namespace string ,
558586 clusterName string ,
587+ namespacedResources []schema.GroupVersionResource ,
588+ listOpts metav1.ListOptions ,
559589 tw * tar.Writer ,
560590 cmd * cobra.Command ,
561591) error {
562592 for _ , gvr := range namespacedResources {
563- list , err := client .Resource (gvr ).Namespace (namespace ).
564- List (ctx , metav1.ListOptions {
565- LabelSelector : "postgres-operator.crunchydata.com/cluster=" + clusterName ,
566- })
593+ list , err := client .Resource (gvr ).Namespace (namespace ).List (ctx , listOpts )
567594 // If the API returns an IsNotFound error, it is likely because the kube version in use
568595 // doesn't support the version of the resource we are attempting to use and there is an
569596 // earlier version we can use. This block will check the "removed" resources for a match
@@ -573,9 +600,7 @@ func gatherNamespacedAPIResources(ctx context.Context,
573600 if bgvr .Resource == gvr .Resource {
574601 gvr = bgvr
575602 list , err = client .Resource (gvr ).Namespace (namespace ).
576- List (ctx , metav1.ListOptions {
577- LabelSelector : "postgres-operator.crunchydata.com/cluster=" + clusterName ,
578- })
603+ List (ctx , listOpts )
579604 break
580605 }
581606 }
0 commit comments