This repository has been archived by the owner on Mar 7, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Federation features and cleanup (#194)
* Update go.mod file * Add code-generator to go.mod file * Add newly generated files * Add code-generator for current kubernetes version * Add newly generated factory * Update go version to 1.21.3 * Fix path for docker compose * Update makefile * Remove unnecessary find statements from Makefile * Remove manual binary generation from Makefile * Add Makefile sync * Add fedmanctl generator * Add hack folder * Add custom boilerplate code * Add gen to Makefile * Change copyright of generated files * Update copyright * Fix fedmanctl Makefile * Add comments to Makefile and fix make test command * Change go version in github actions * Test * Update deprecated ioutil functions * Add sleep statement to selective deployment test * Add minikube start script * Add new SD * Add newly SD v1alpha3 * Remove unused inports and add go work file * Remove unused workload informers from SD v1 * Add comments to types * Add comment to types
- Loading branch information
Showing
29 changed files
with
2,188 additions
and
64 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,3 @@ | ||
go 1.21.5 | ||
|
||
use . |
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,4 @@ | ||
github.com/emicklei/go-restful v2.10.0+incompatible h1:l6Soi8WCOOVAeCo4W98iBFC6Og7/X8bpRt51oNLZ2C8= | ||
github.com/fatih/color v1.10.0/go.mod h1:ELkj/draVOlAH/xkhN6mQ50Qd0MPOk5AAr3maGEBuJM= | ||
github.com/mattn/go-colorable v0.1.8/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= | ||
github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc= |
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,54 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -o errexit | ||
set -o nounset | ||
set -o pipefail | ||
|
||
if command -v fedmanctl &>/dev/null; then | ||
echo "fedmanctl is installed. Creating clusters." | ||
|
||
# cluster_names=("cluster-worker-paris" "cluster-worker-munich" "cluster-worker-milan" "cluster-federator-eu") | ||
# cluster_nodes=(2 1 2 1) | ||
# cluster_federators=(0 0 0 1) | ||
|
||
cluster_names=("cluster-worker-paris") | ||
cluster_nodes=(1) | ||
cluster_federators=(0) | ||
|
||
# Create 3 worker 1 federator cluster, this also updates the KUBECONFIG file and adds different contexts. | ||
|
||
for ((i=0; i<${#cluster_names[@]}; i++)); do | ||
echo "> Creating ${cluster_names[i]} with ${cluster_nodes[i]} node(s)" | ||
minikube start --memory 2g --cpus 2 -n ${cluster_nodes[i]} --network bridge -p ${cluster_names[i]} &>/dev/null | ||
done | ||
|
||
# # Setup cert-manager and edgenet | ||
echo "Clusters are created, deploying cert-manager and edgenet" | ||
for ((i=0; i<${#cluster_names[@]}; i++)); do | ||
echo "> Deploying to ${cluster_names[i]}" | ||
kubectl apply -f https://github.com/cert-manager/cert-manager/releases/download/v1.13.2/cert-manager.yaml --context ${cluster_names[i]} | ||
done | ||
|
||
for ((i=0; i<${#cluster_names[@]}; i++)); do | ||
# wait for cert-manager's webhook to run, there can be more sophisticated waiting mechanism | ||
sleep 25 | ||
kubectl apply -f build/yamls/kubernetes/multi-tenancy.yaml --context ${cluster_names[i]} | ||
|
||
# For now delete this. | ||
kubectl delete validatingwebhookconfigurations.admissionregistration.k8s.io edgenet-admission-control --context ${cluster_names[i]} | ||
|
||
# If the cluster is a federator | ||
if [ "${cluster_federators[i]}" = "1" ]; then | ||
kubectl apply -f build/yamls/kubernetes/federation-manager.yaml --context ${cluster_names[i]} | ||
else | ||
kubectl apply -f build/yamls/kubernetes/federation-workload.yaml --context ${cluster_names[i]} | ||
fi | ||
done | ||
|
||
echo "DONE!" | ||
else | ||
echo "fedmanctl is not installed or not in the system's PATH. Exitting..." | ||
fi | ||
|
||
|
||
|
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 |
---|---|---|
@@ -0,0 +1,20 @@ | ||
/* | ||
Copyright 2023 Contributors to the EdgeNet 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. | ||
*/ | ||
|
||
// +k8s:deepcopy-gen=package | ||
// +groupName=apps.edgenet.io | ||
|
||
package v1alpha3 // import "github.com/EdgeNet-project/edgenet/pkg/apis/apps/v1alpha3" |
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,58 @@ | ||
/* | ||
Copyright 2023 Contributors to the EdgeNet project. | ||
Old Credits: | ||
Copyright 2017 The Kubernetes Authors. | ||
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 v1alpha3 | ||
|
||
import ( | ||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
"k8s.io/apimachinery/pkg/runtime" | ||
"k8s.io/apimachinery/pkg/runtime/schema" | ||
|
||
"github.com/EdgeNet-project/edgenet/pkg/apis/apps" | ||
) | ||
|
||
// SchemeGroupVersion is group version used to register these objects | ||
var SchemeGroupVersion = schema.GroupVersion{Group: apps.GroupName, Version: "v1alpha3"} | ||
|
||
// Kind takes an unqualified kind and returns back a Group qualified GroupKind | ||
func Kind(kind string) schema.GroupKind { | ||
return SchemeGroupVersion.WithKind(kind).GroupKind() | ||
} | ||
|
||
// Resource takes an unqualified resource and returns a Group qualified GroupResource | ||
func Resource(resource string) schema.GroupResource { | ||
return SchemeGroupVersion.WithResource(resource).GroupResource() | ||
} | ||
|
||
var ( | ||
// SchemeBuilder initializes a scheme builder | ||
SchemeBuilder = runtime.NewSchemeBuilder(addKnownTypes) | ||
// AddToScheme is a global function that registers this API group & version to a scheme | ||
AddToScheme = SchemeBuilder.AddToScheme | ||
) | ||
|
||
// Adds the list of known types to Scheme. | ||
func addKnownTypes(scheme *runtime.Scheme) error { | ||
scheme.AddKnownTypes(SchemeGroupVersion, | ||
&SelectiveDeployment{}, | ||
&SelectiveDeploymentList{}, | ||
) | ||
metav1.AddToGroupVersion(scheme, SchemeGroupVersion) | ||
return nil | ||
} |
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,107 @@ | ||
/* | ||
Copyright 2023 Contributors to the EdgeNet 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 v1alpha3 | ||
|
||
import ( | ||
appsv1 "k8s.io/api/apps/v1" | ||
batchv1 "k8s.io/api/batch/v1" | ||
batchv1beta "k8s.io/api/batch/v1beta1" | ||
corev1 "k8s.io/api/core/v1" | ||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
) | ||
|
||
// +genclient | ||
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object | ||
|
||
// SelectiveDeployment describes a SelectiveDeployment resource | ||
type SelectiveDeployment struct { | ||
// TypeMeta is the metadata for the resource, like kind and apiversion | ||
metav1.TypeMeta `json:",inline"` | ||
// ObjectMeta contains the metadata for the particular object, including | ||
metav1.ObjectMeta `json:"metadata,omitempty"` | ||
// Spec is the selectivedeployment resource spec | ||
Spec SelectiveDeploymentSpec `json:"spec"` | ||
// Status is the selectivedeployment resource status | ||
Status SelectiveDeploymentStatus `json:"status,omitempty"` | ||
} | ||
|
||
// SelectiveDeploymentSpec is the spec for a SelectiveDeployment resource. | ||
// Selectors filter the nodes to be used for specified workloads. | ||
type SelectiveDeploymentSpec struct { | ||
// Workload can be Deployment, Deamonset, StatefulSet, Job, or CronJob. | ||
Workloads Workloads `json:"workloads"` | ||
// List of Selector resources. Each selector filters the nodes with the | ||
// requested method. | ||
Selector []Selector `json:"selector"` | ||
// If true, selective deployment tries to find another suitable | ||
// node to run the workload in case of a node goes down. | ||
Recovery bool `json:"recovery"` | ||
} | ||
|
||
// Workloads indicates deployments, daemonsets, statefulsets, jobs, or cronjobs. | ||
type Workloads struct { | ||
// Workload can have a list of Deployments. | ||
Deployment []appsv1.Deployment `json:"deployment"` | ||
// Workload can have a list of DaemonSets. | ||
DaemonSet []appsv1.DaemonSet `json:"daemonset"` | ||
// Workload can have a list of StatefulSets. | ||
StatefulSet []appsv1.StatefulSet `json:"statefulset"` | ||
// Workload can have a list of Jobs. | ||
Job []batchv1.Job `json:"job"` | ||
// Workload can have a list of CronJobs. | ||
CronJob []batchv1beta.CronJob `json:"cronjob"` | ||
} | ||
|
||
// Selector to define desired node filtering parameters | ||
type Selector struct { | ||
// Name of the selector. This can be City, State, Country, Continent, or Polygon | ||
Name string `json:"name"` | ||
// Value of the selector. For example; if the name of the selector is 'City' | ||
// then the value can be the city name. For example; if the name of | ||
// the selector is 'Polygon' then the value can be the GeoJSON representation of the polygon. | ||
Value []string `json:"value"` | ||
// Operator means basic mathematical operators such as 'In', 'NotIn', 'Exists', 'NotExsists' etc... | ||
Operator corev1.NodeSelectorOperator `json:"operator"` | ||
// Quantity represents number of nodes on which the workloads will be running. | ||
Quantity int `json:"quantity"` | ||
} | ||
|
||
// SelectiveDeploymentStatus is the status for a SelectiveDeployment resource | ||
type SelectiveDeploymentStatus struct { | ||
// Ready string denotes number of workloads running filtered by the SelectiveDeployments. | ||
// The string is 'x/y' if x instances are running and y instances are requested. | ||
Ready string `json:"ready"` | ||
// Represents state of the selective deployment. This can be 'Failure' if none | ||
// of the workloads are deployed. 'Partial' if some of the the workloads | ||
// are deployed. 'Success' if all of the workloads are deployed. | ||
State string `json:"state"` | ||
// There can be multiple display messages for state description. | ||
Message string `json:"message"` | ||
} | ||
|
||
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object | ||
|
||
// SelectiveDeploymentList is a list of SelectiveDeployment resources | ||
type SelectiveDeploymentList struct { | ||
// TypeMeta is the metadata for the resource, like kind and apiversion | ||
metav1.TypeMeta `json:",inline"` | ||
// ObjectMeta contains the metadata for the particular object, including | ||
metav1.ListMeta `json:"metadata"` | ||
// SelectiveDeploymentList is a list of SelectiveDeployment resources thus, | ||
// SelectiveDeployments are contained here. | ||
Items []SelectiveDeployment `json:"items"` | ||
} |
Oops, something went wrong.