Skip to content
Merged
Show file tree
Hide file tree
Changes from 33 commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
62bd318
Added managed by label - issue 110
matthewgoodman13 Jun 13, 2022
87d6b78
Merge pull request #1 from aws/main
matthewgoodman13 Jun 17, 2022
39b4a1e
Merge branch 'main' of https://github.com/matthewgoodman13/aws-cloud-…
matthewgoodman13 Jun 27, 2022
5247ede
Merge branch 'main' of https://github.com/aws/aws-cloud-map-mcs-contr…
matthewgoodman13 Jun 27, 2022
6101a8b
migration to multigroup structure
matthewgoodman13 Jun 29, 2022
51f7bfd
updated paths in PROJECT
matthewgoodman13 Jun 29, 2022
fe47782
updated paths in .golangci & .codecov
matthewgoodman13 Jun 29, 2022
b2cd852
ClusterID recognized & watched for changes + sync
matthewgoodman13 Jul 7, 2022
0c64aa0
clusterid sync with cloudmap + recognized
matthewgoodman13 Jul 7, 2022
1e2ea91
Merge branch 'multicluster-clusterproperty' of https://github.com/mat…
matthewgoodman13 Jul 7, 2022
317683f
fix commit - clusterid recon + synced
matthewgoodman13 Jul 7, 2022
e3d3628
Merge branch 'multicluster-clusterproperty' of https://github.com/mat…
matthewgoodman13 Jul 7, 2022
83efd8a
fix controller
matthewgoodman13 Jul 7, 2022
df658e1
Merge branch 'multicluster-clusterproperty' of https://github.com/mat…
matthewgoodman13 Jul 7, 2022
ecb982a
test constants
matthewgoodman13 Jul 7, 2022
875f1a6
recon
matthewgoodman13 Jul 7, 2022
225dc65
changes to test
matthewgoodman13 Jul 13, 2022
1ebd09c
cm controller
matthewgoodman13 Jul 13, 2022
c62594f
Merge branch 'aws:main' into main
matthewgoodman13 Jul 13, 2022
eb48ca3
controllers
matthewgoodman13 Jul 13, 2022
da59438
fix commit - clusterid recon + synced
matthewgoodman13 Jul 7, 2022
e2ecb4c
fix controller
matthewgoodman13 Jul 7, 2022
afc57c5
clusterid sync with cloudmap + recognized
matthewgoodman13 Jul 7, 2022
b927ad9
ClusterID recognized & watched for changes + sync
matthewgoodman13 Jul 7, 2022
9469117
test constants
matthewgoodman13 Jul 7, 2022
7c38f36
recon
matthewgoodman13 Jul 7, 2022
0807deb
changes to test
matthewgoodman13 Jul 13, 2022
e617634
cm controller
matthewgoodman13 Jul 13, 2022
76f2cb0
Merge branch 'reconcileclusterid' of https://github.com/matthewgoodma…
matthewgoodman13 Jul 13, 2022
0bbf754
rm changes
matthewgoodman13 Jul 13, 2022
56514cd
rm meta
matthewgoodman13 Jul 13, 2022
87b0dbf
rm return
matthewgoodman13 Jul 14, 2022
a8da279
unit tests + clusterid error
matthewgoodman13 Jul 16, 2022
b35bc75
addition of clustersetid and other changes
matthewgoodman13 Jul 21, 2022
1768755
cleanup of get/set of clusterId and clustersetId
matthewgoodman13 Jul 26, 2022
b04b7db
clusterUtils
matthewgoodman13 Jul 29, 2022
ad4e972
Merge branch 'main' into reconcileclusterid
matthewgoodman13 Jul 29, 2022
62e4f8d
fix merge conflicts
matthewgoodman13 Jul 29, 2022
1aa5dde
clusterId/setId method called twice
matthewgoodman13 Jul 29, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 65 additions & 0 deletions config/crd/bases/about.k8s.io_clusterproperties.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
---
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.8.0
creationTimestamp: null
name: clusterproperties.about.k8s.io
spec:
group: about.k8s.io
names:
kind: ClusterProperty
listKind: ClusterPropertyList
plural: clusterproperties
singular: clusterproperty
scope: Cluster
versions:
- additionalPrinterColumns:
- jsonPath: .spec.value
name: value
type: string
- jsonPath: .metadata.creationTimestamp
name: age
type: date
name: v1alpha1
schema:
openAPIV3Schema:
description: ClusterProperty is the Schema for the clusterproperties API
properties:
apiVersion:
description: 'APIVersion defines the versioned schema of this representation
of an object. Servers should convert recognized schemas to the latest
internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
type: string
kind:
description: 'Kind is a string value representing the REST resource this
object represents. Servers may infer this from the endpoint the client
submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
type: string
metadata:
type: object
spec:
description: ClusterPropertySpec defines the desired state of ClusterProperty
properties:
value:
description: ClusterProperty value
minLength: 1
type: string
required:
- value
type: object
status:
description: ClusterPropertyStatus defines the observed state of ClusterProperty
type: object
type: object
served: true
storage: true
subresources:
status: {}
status:
acceptedNames:
kind: ""
plural: ""
conditions: []
storedVersions: []
6 changes: 6 additions & 0 deletions config/crd/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,29 @@
# since it depends on service name and namespace that are out of this kustomize package.
# It should be run by config/default
resources:
- bases/about.k8s.io_clusterproperties.yaml
- bases/multicluster.x-k8s.io_serviceexports.yaml
- bases/multicluster.x-k8s.io_serviceimports.yaml
#+kubebuilder:scaffold:crdkustomizeresource

patchesStrategicMerge:
# [WEBHOOK] To enable webhook, uncomment all the sections with [WEBHOOK] prefix.
# patches here are for enabling the conversion webhook for each CRD
#- patches/webhook_in_clusterproperties.yaml
#- patches/webhook_in_serviceexports.yaml
#- patches/webhook_in_serviceimports.yaml
#+kubebuilder:scaffold:crdkustomizewebhookpatch

# [CERTMANAGER] To enable webhook, uncomment all the sections with [CERTMANAGER] prefix.
# patches here are for enabling the CA injection for each CRD
#- patches/cainjection_in_clusterproperties.yaml
#- patches/cainjection_in_serviceexports.yaml
#- patches/cainjection_in_serviceimports.yaml
#+kubebuilder:scaffold:crdkustomizecainjectionpatch

# Patch adds an annotation to pass protected groups approval required to use domain "k8s.io"
- patches/annotation_for_clusterproperties.yaml

# the following config is for teaching kustomize how to do kustomization for CRDs.
configurations:
- kustomizeconfig.yaml
7 changes: 7 additions & 0 deletions config/crd/patches/annotation_for_clusterproperties.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# The following patch adds an annotation to pass protected groups approval required to use domain "k8s.io"
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
api-approved.kubernetes.io: "https://github.com/kubernetes/kubernetes/pull/78458"
name: clusterproperties.about.k8s.io
7 changes: 7 additions & 0 deletions config/crd/patches/cainjection_in_clusterproperties.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# The following patch adds a directive for certmanager to inject CA into the CRD
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
cert-manager.io/inject-ca-from: $(CERTIFICATE_NAMESPACE)/$(CERTIFICATE_NAME)
name: clusterproperties.about.k8s.io
16 changes: 16 additions & 0 deletions config/crd/patches/webhook_in_clusterproperties.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# The following patch enables a conversion webhook for the CRD
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
name: clusterproperties.about.k8s.io
spec:
conversion:
strategy: Webhook
webhook:
clientConfig:
service:
namespace: system
name: webhook-service
path: /convert
conversionReviewVersions:
- v1
8 changes: 8 additions & 0 deletions config/samples/about_v1alpha1_clusterproperty.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# An example object of `id.k8s.io ClusterProperty`

apiVersion: about.k8s.io/v1alpha1
kind: ClusterProperty
metadata:
name: id.k8s.io
spec:
value: sample-mcs-clusterid
3 changes: 3 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"sigs.k8s.io/controller-runtime/pkg/healthz"
"sigs.k8s.io/controller-runtime/pkg/log/zap"

aboutv1alpha1 "github.com/aws/aws-cloud-map-mcs-controller-for-k8s/pkg/apis/about/v1alpha1"
multiclusterv1alpha1 "github.com/aws/aws-cloud-map-mcs-controller-for-k8s/pkg/apis/multicluster/v1alpha1"
multiclustercontrollers "github.com/aws/aws-cloud-map-mcs-controller-for-k8s/pkg/controllers/multicluster"
// +kubebuilder:scaffold:imports
Expand All @@ -36,6 +37,8 @@ func init() {
utilruntime.Must(clientgoscheme.AddToScheme(scheme))

utilruntime.Must(multiclusterv1alpha1.AddToScheme(scheme))

utilruntime.Must(aboutv1alpha1.AddToScheme(scheme))
//+kubebuilder:scaffold:scheme
}

Expand Down
52 changes: 52 additions & 0 deletions pkg/apis/about/v1alpha1/clusterproperty_types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
package v1alpha1

import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized.

// ClusterPropertySpec defines the desired state of ClusterProperty
type ClusterPropertySpec struct {
// INSERT ADDITIONAL SPEC FIELDS - desired state of cluster
// Important: Run "make" to regenerate code after modifying this file

// ClusterProperty value
// +kubebuilder:validation:Maxlength=128000
// +kubebuilder:validation:MinLength=1
Value string `json:"value"`
}

// ClusterPropertyStatus defines the observed state of ClusterProperty
type ClusterPropertyStatus struct {
// INSERT ADDITIONAL STATUS FIELD - define observed state of cluster
// Important: Run "make" to regenerate code after modifying this file
}

//+kubebuilder:object:root=true
//+kubebuilder:subresource:status
//+kubebuilder:resource:scope=Cluster

// ClusterProperty is the Schema for the clusterproperties API
// +kubebuilder:printcolumn:name="value",type=string,JSONPath=`.spec.value`
// +kubebuilder:printcolumn:name="age",type=date,JSONPath=`.metadata.creationTimestamp`
type ClusterProperty struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`

Spec ClusterPropertySpec `json:"spec,omitempty"`
Status ClusterPropertyStatus `json:"status,omitempty"`
}

//+kubebuilder:object:root=true

// ClusterPropertyList contains a list of ClusterProperty
type ClusterPropertyList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []ClusterProperty `json:"items"`
}

func init() {
SchemeBuilder.Register(&ClusterProperty{}, &ClusterPropertyList{})
}
20 changes: 20 additions & 0 deletions pkg/apis/about/v1alpha1/groupversion_info.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// Package v1alpha1 contains API Schema definitions for the about v1alpha1 API group
//+kubebuilder:object:generate=true
//+groupName=about.k8s.io
package v1alpha1

import (
"k8s.io/apimachinery/pkg/runtime/schema"
"sigs.k8s.io/controller-runtime/pkg/scheme"
)

var (
// GroupVersion is group version used to register these objects
GroupVersion = schema.GroupVersion{Group: "about.k8s.io", Version: "v1alpha1"}

// SchemeBuilder is used to add go types to the GroupVersionKind scheme
SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion}

// AddToScheme adds the types in this group-version to the given scheme.
AddToScheme = SchemeBuilder.AddToScheme
)
115 changes: 115 additions & 0 deletions pkg/apis/about/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions pkg/cloudmap/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,7 @@ func TestServiceDiscoveryClient_RegisterEndpoints(t *testing.T) {
tc.mockCache.EXPECT().GetServiceIdMap(test.HttpNsName).Return(getServiceIdMapForTest(), true)

attrs1 := map[string]string{
model.ClusterIdAttrName: test.ClusterIdValue,
model.EndpointIpv4Attr: test.EndptIp1,
model.EndpointPortAttr: test.PortStr1,
model.EndpointPortNameAttr: test.PortName1,
Expand All @@ -293,6 +294,7 @@ func TestServiceDiscoveryClient_RegisterEndpoints(t *testing.T) {
model.ServiceTargetPortAttr: test.PortStr1,
}
attrs2 := map[string]string{
model.ClusterIdAttrName: test.ClusterIdValue,
model.EndpointIpv4Attr: test.EndptIp2,
model.EndpointPortAttr: test.PortStr2,
model.EndpointPortNameAttr: test.PortName2,
Expand Down Expand Up @@ -362,6 +364,7 @@ func getHttpInstanceSummaryForTest() []types.HttpInstanceSummary {
{
InstanceId: aws.String(test.EndptId1),
Attributes: map[string]string{
model.ClusterIdAttrName: test.ClusterIdValue,
model.EndpointIpv4Attr: test.EndptIp1,
model.EndpointPortAttr: test.PortStr1,
model.EndpointPortNameAttr: test.PortName1,
Expand All @@ -375,6 +378,7 @@ func getHttpInstanceSummaryForTest() []types.HttpInstanceSummary {
{
InstanceId: aws.String(test.EndptId2),
Attributes: map[string]string{
model.ClusterIdAttrName: test.ClusterIdValue,
model.EndpointIpv4Attr: test.EndptIp2,
model.EndpointPortAttr: test.PortStr2,
model.EndpointPortNameAttr: test.PortName2,
Expand Down
12 changes: 12 additions & 0 deletions pkg/controllers/multicluster/controllers_common_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package controllers

import (
aboutv1alpha1 "github.com/aws/aws-cloud-map-mcs-controller-for-k8s/pkg/apis/about/v1alpha1"
multiclusterv1alpha1 "github.com/aws/aws-cloud-map-mcs-controller-for-k8s/pkg/apis/multicluster/v1alpha1"
"github.com/aws/aws-cloud-map-mcs-controller-for-k8s/test"
"github.com/aws/aws-sdk-go-v2/aws"
Expand Down Expand Up @@ -83,3 +84,14 @@ func endpointSliceWithIpsAndPortsForTest(ips []string, ports []discovery.Endpoin

return slice
}

func clusterPropertyWithIdForTest() *aboutv1alpha1.ClusterProperty {
return &aboutv1alpha1.ClusterProperty{
ObjectMeta: metav1.ObjectMeta{
Name: ClusterIdName,
},
Spec: aboutv1alpha1.ClusterPropertySpec{
Value: "test_clusterid",
},
}
}
Loading