Skip to content
This repository has been archived by the owner on Nov 30, 2023. It is now read-only.

Commit

Permalink
Add APIs for coastguard
Browse files Browse the repository at this point in the history
Below 3 APIs are created:
1. ClustersetNetworkPolicy
2. RemotePod
3. RemoteNamespace

Signed-off-by: Janki Chhatbar <[email protected]>
  • Loading branch information
Jaanki committed May 15, 2023
1 parent 65f884a commit 7732c24
Show file tree
Hide file tree
Showing 11 changed files with 1,042 additions and 130 deletions.
20 changes: 20 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,28 @@ export BASE_BRANCH

ifneq (,$(DAPPER_HOST_ARCH))

CONTROLLER_GEN := $(CURDIR)/bin/controller-gen

# Running in Dapper

GO ?= go

# Ensure we prefer binaries we build
export PATH := $(CURDIR)/bin:$(PATH)

# Targets to make

# Download controller-gen locally if not already downloaded.
$(CONTROLLER_GEN):
mkdir -p $(@D)
$(GO) build -o $@ sigs.k8s.io/controller-tools/cmd/controller-gen

controller-gen: $(CONTROLLER_GEN)

# Generate deep-copy code
generate: controller-gen
$(CONTROLLER_GEN) object:headerFile="$(CURDIR)/hack/boilerplate.go.txt,year=$(shell date +"%Y")" paths="./..."

IMAGES ?= coastguard
images: build

Expand Down
69 changes: 69 additions & 0 deletions api/v1alpha1/clustersetnetworkpolicy_types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
/*
SPDX-License-Identifier: Apache-2.0
Copyright Contributors to the Submariner project.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package v1alpha1

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

// Important: Run "make generate" to regenerate code after modifying this file

// ClusterSetNetworkPolicySpec defines the desired state of ClusterSetNetworkPolicy.
type ClusterSetNetworkPolicySpec struct {
PolicyTypes []string `json:"policyTypes"`
PodSelector metav1.LabelSelector `json:"podSelector"`
Ingress networkingv1.NetworkPolicyIngressRule `json:"ingress"`
Egress networkingv1.NetworkPolicyEgressRule `json:"egress"`
}

// ClusterSetNetworkPolicyStatus defines the observed state of ClusterSetNetworkPolicy.
type ClusterSetNetworkPolicyStatus struct {
// +optional
// +patchStrategy=merge
// +patchMergeKey=type
// +listType=map
// +listMapKey=type
Conditions []metav1.Condition `json:"conditions,omitempty" patchStrategy:"merge" patchMergeKey:"type"`
}

//+kubebuilder:object:root=true
//+kubebuilder:subresource:status

// ClusterSetNetworkPolicy is the Schema for the ClusterSetnetworkpolicies API.
type ClusterSetNetworkPolicy struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`

Spec ClusterSetNetworkPolicySpec `json:"spec,omitempty"`
Status ClusterSetNetworkPolicyStatus `json:"status,omitempty"`
}

//+kubebuilder:object:root=true

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

func init() {
SchemeBuilder.Register(&ClusterSetNetworkPolicy{}, &ClusterSetNetworkPolicyList{})
}
38 changes: 38 additions & 0 deletions api/v1alpha1/groupversion_info.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
SPDX-License-Identifier: Apache-2.0
Copyright Contributors to the Submariner project.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

// Package v1alpha1 contains API Schema definitions for the v1alpha1 API group
// +kubebuilder:object:generate=true
// +groupName=submariner.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: "submariner.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
)
54 changes: 54 additions & 0 deletions api/v1alpha1/remotenamespace_types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/*
SPDX-License-Identifier: Apache-2.0
Copyright Contributors to the Submariner project.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package v1alpha1

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

// Important: Run "make generate" to regenerate code after modifying this file

// RemoteNamespaceSpec defines the desired state of RemoteNamespace
type RemoteNamespaceSpec struct {
ClusterID string `json:"clusterID"`
}

//+kubebuilder:object:root=true
//+kubebuilder:subresource:status

// RemoteNamespace is the Schema for the remotenamespaces API
type RemoteNamespace struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`

Spec RemoteNamespaceSpec `json:"spec,omitempty"`
}

//+kubebuilder:object:root=true

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

func init() {
SchemeBuilder.Register(&RemoteNamespace{}, &RemoteNamespaceList{})
}
56 changes: 56 additions & 0 deletions api/v1alpha1/remotepod_types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/*
SPDX-License-Identifier: Apache-2.0
Copyright Contributors to the Submariner project.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package v1alpha1

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

// Important: Run "make generate" to regenerate code after modifying this file

// RemotePodSpec defines the desired state of RemotePod
type RemotePodSpec struct {
ClusterID string `json:"clusterID"`
PodIPs []string `json:"podIPs"`
Namespace string `json:"namespace"`
}

//+kubebuilder:object:root=true
//+kubebuilder:subresource:status

// RemotePod is the Schema for the remotepods API
type RemotePod struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`

Spec RemotePodSpec `json:"spec,omitempty"`
}

//+kubebuilder:object:root=true

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

func init() {
SchemeBuilder.Register(&RemotePod{}, &RemotePodList{})
}
Loading

0 comments on commit 7732c24

Please sign in to comment.