-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* k8s1.25 * interface * GetAnnotations() replaces ClusterName field in ClusterResourceId interface * actually support k8s v1.25 (with controller-runtime v0.13.1) * update go templates; changelog; dep updates * put changelog in folder * update from generated code * add annotations field to ClusterObjectRef proto to match ClusterResourceId interface * remove annotations field from ClusterObjectRef proto * Adding changelog file to new location * Deleting changelog file from old location * add function to allow ClusterObjectRef struct to satisfy the ClusterResourceId interface * handle possibility of clusterName being set by annotation or field * pr feedback during working session with eitan * Update contrib/pkg/sets/sets.go Co-authored-by: J. Conrad Hanson <[email protected]> * contrib/reconciler: Update to converting to new interface. Not stored directly as its not exported. * Adding changelog file to new location * Deleting changelog file from old location * remove extraneous separators * mod: Revert the comingled k8s1.25 changes * changelog: Update to reference what is being done correctly * add back * codegen * fix input reconciler * register: Update to ensure that sa secret exists. Note: Not handled on SA creation but seems to be the only place where we need to ensure secrets exist * register: Make sure to have a namespace * register: Make sure wait for token population * reigster: Longer delay now that extra controller layer is needed for secrets * mod: skv2 tocreate on the correct cluster * secret-type change * templ/input: Set clusters in a novel way * templ/input: Set clusters consistently given new novel approach * kubeconfig: Update comment * ezkube: Method for converting deprecated objects will no longer blow away other annotations * register: harden service account getting * test/registration: Change expectations given serviceaccount changes * template/inputs/hybrid: Clusternaming Co-authored-by: Eitan Yarmush <[email protected]> Co-authored-by: Conrad Hanson <[email protected]> Co-authored-by: changelog-bot <changelog-bot> Co-authored-by: Jenny Shu <[email protected]>
- Loading branch information
1 parent
40f066a
commit 3055431
Showing
13 changed files
with
162 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
changelog: | ||
- type: BREAKING_CHANGE | ||
issueLink: https://github.com/solo-io/gloo-mesh-enterprise/issues/5158 | ||
description: > | ||
In the ClusterResourceId interface, ClusterName field is replaced with GetAnnotations method, | ||
since k8s v1.24+ removes the ClusterName field from resources. | ||
Now, a resource annotation of "cluster.solo.io/cluster" is expected to hold a string of the cluster name. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,86 @@ | ||
package ezkube | ||
|
||
import ( | ||
"sigs.k8s.io/controller-runtime/pkg/client" | ||
) | ||
|
||
const ClusterAnnotation = "cluster.solo.io/cluster" | ||
|
||
// ResourceId represents a global identifier for a k8s resource. | ||
type ResourceId interface { | ||
GetName() string | ||
GetNamespace() string | ||
} | ||
|
||
// ResourceId represents a global identifier for a k8s resource. | ||
// ClusterResourceId represents a global identifier for a k8s resource. | ||
type ClusterResourceId interface { | ||
GetName() string | ||
GetNamespace() string | ||
GetAnnotations() map[string]string | ||
} | ||
|
||
// internal struct needed to create helper func that converts ref to struct that satisfies ClusterResourceId interface | ||
type clusterResourceId struct { | ||
name, namespace string | ||
annotations map[string]string | ||
} | ||
|
||
func (c clusterResourceId) GetName() string { | ||
return c.name | ||
} | ||
|
||
func (c clusterResourceId) GetNamespace() string { | ||
return c.namespace | ||
} | ||
|
||
func (c clusterResourceId) GetAnnotations() map[string]string { | ||
return c.annotations | ||
} | ||
|
||
type deprecatedClusterResourceId interface { | ||
GetName() string | ||
GetNamespace() string | ||
GetClusterName() string | ||
} | ||
|
||
// ConvertRefToId converts a ClusterObjectRef to a struct that implements the ClusterResourceId interface | ||
// Will not set an empty cluster name over an existing cluster name | ||
func ConvertRefToId(ref deprecatedClusterResourceId) ClusterResourceId { | ||
// if ref is already stores annotations then we need to store the updates | ||
anno := map[string]string{} | ||
|
||
if cri, ok := ref.(ClusterResourceId); ok { | ||
anno = cri.GetAnnotations() | ||
} | ||
cn := ref.GetClusterName() | ||
if cn != "" { | ||
anno[ClusterAnnotation] = cn | ||
} | ||
|
||
return clusterResourceId{ | ||
name: ref.GetName(), | ||
namespace: ref.GetNamespace(), | ||
annotations: anno, | ||
} | ||
} | ||
|
||
func GetDeprecatedClusterName(id ResourceId) string { | ||
if id, ok := id.(deprecatedClusterResourceId); ok { | ||
return id.GetClusterName() | ||
} | ||
return "" | ||
} | ||
|
||
func GetClusterName(id ClusterResourceId) string { | ||
if id.GetAnnotations() == nil { | ||
return "" | ||
} | ||
return id.GetAnnotations()[ClusterAnnotation] | ||
} | ||
|
||
func SetClusterName(obj client.Object, cluster string) { | ||
if obj.GetAnnotations() == nil { | ||
obj.SetAnnotations(map[string]string{}) | ||
} | ||
obj.GetAnnotations()[ClusterAnnotation] = cluster | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters