This repository has been archived by the owner on Jul 22, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
New Plugin Node Labels Resources (#6)
- Loading branch information
1 parent
39157df
commit edffa12
Showing
15 changed files
with
617 additions
and
8 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 |
---|---|---|
|
@@ -47,6 +47,7 @@ jobs: | |
matrix: | ||
plugin: | ||
- fixed-resources | ||
- node-labels-resources | ||
|
||
steps: | ||
- name: Set up QEMU | ||
|
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,2 @@ | ||
// Package main contains the main function for the node-label-resource-plugin. | ||
package main |
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,48 @@ | ||
package main | ||
|
||
import ( | ||
goflags "flag" | ||
"os" | ||
|
||
"github.com/spf13/cobra" | ||
"k8s.io/klog/v2" | ||
|
||
grpcserver "github.com/liqotech/liqo-resource-plugins/pkg/node-labels-resources" | ||
monitorargs "github.com/liqotech/liqo-resource-plugins/pkg/utils/args" | ||
clients "github.com/liqotech/liqo-resource-plugins/pkg/utils/clients" | ||
) | ||
|
||
func main() { | ||
fs := goflags.NewFlagSet("", goflags.PanicOnError) | ||
klog.InitFlags(fs) | ||
klog.SetOutput(os.Stdout) | ||
var port int | ||
nodeLabels := monitorargs.NodeLabelsMap{} | ||
kubernetesClient, err := clients.CreateKubernetesCore() | ||
if err != nil { | ||
klog.Fatalf("error: unable to create kubernetes client: %s", err) | ||
} | ||
var rootCmd = &cobra.Command{ | ||
Use: os.Args[0], | ||
Short: "Liqo plugin which provides resources based on node selector to each remote cluster", | ||
SilenceUsage: true, | ||
RunE: func(cmd *cobra.Command, args []string) error { | ||
return grpcserver.ListenAndServeGRPCServer(port, nodeLabels.NodeLabels, kubernetesClient) | ||
}, | ||
} | ||
|
||
rootCmd.Flags().Var(&nodeLabels, "node-label", "set a node label having format name=value. e.g.: --node-label=label1=v1 --node-label=label2=v2.") | ||
rootCmd.PersistentFlags().IntVar(&port, "port", 6001, "set port where the server will listen on.") | ||
rootCmd.Flags().AddGoFlagSet(fs) | ||
|
||
err = rootCmd.Root().MarkFlagRequired("node-label") | ||
if err != nil { | ||
klog.Fatalf("error: error during marking resource flag as required: %s", err) | ||
} | ||
err = rootCmd.Execute() | ||
if err != nil { | ||
klog.Flush() | ||
os.Exit(1) | ||
} | ||
klog.Flush() | ||
} |
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,13 @@ | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
kind: ClusterRoleBinding | ||
metadata: | ||
creationTimestamp: null | ||
name: liqo-node-label-resource-plugin-role-binding | ||
roleRef: | ||
apiGroup: rbac.authorization.k8s.io | ||
kind: ClusterRole | ||
name: liqo-node-label-resource-plugin-role | ||
subjects: | ||
- kind: ServiceAccount | ||
name: liqo-node-labels-resource-plugin-sa | ||
namespace: liqo |
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,13 @@ | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
kind: ClusterRole | ||
metadata: | ||
name: liqo-node-label-resource-plugin-role | ||
rules: | ||
- apiGroups: | ||
- "" | ||
resources: | ||
- nodes | ||
- pods | ||
verbs: | ||
- list | ||
- watch |
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,42 @@ | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: liqo-node-labels-resources-plugin | ||
labels: | ||
app.kubernetes.io/name: liqo-node-labelsresource-plugins | ||
app.kubernetes.io/instance: external-monitor-node-labels-resources | ||
app.kubernetes.io/component: plugin | ||
app.kubernetes.io/part-of: liqo | ||
app.kubernetes.io/managed-by: manual | ||
spec: | ||
replicas: 1 | ||
selector: | ||
matchLabels: | ||
app.kubernetes.io/name: liqo-resource-plugins | ||
app.kubernetes.io/instance: external-monitor-node-labels-resources | ||
app.kubernetes.io/component: plugin | ||
app.kubernetes.io/part-of: liqo | ||
app.kubernetes.io/managed-by: manual | ||
template: | ||
metadata: | ||
labels: | ||
app.kubernetes.io/name: liqo-resource-plugins | ||
app.kubernetes.io/instance: external-monitor-node-labels-resources | ||
app.kubernetes.io/component: plugin | ||
app.kubernetes.io/part-of: liqo | ||
app.kubernetes.io/managed-by: manual | ||
spec: | ||
serviceAccount: liqo-node-labels-resource-plugin-sa | ||
containers: | ||
- name: external-monitor-container | ||
image: | ||
imagePullPolicy: Always | ||
ports: | ||
- name: grpc-api | ||
containerPort: 6001 | ||
args: | ||
- --node-label=dedicated=liqo | ||
- -v=4 | ||
nodeSelector: {} | ||
tolerations: [] | ||
affinity: {} |
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,5 @@ | ||
apiVersion: v1 | ||
kind: ServiceAccount | ||
metadata: | ||
creationTimestamp: null | ||
name: liqo-node-labels-resource-plugin-sa |
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,17 @@ | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: liqo-node-labels-resources-plugin | ||
spec: | ||
ports: | ||
- name: grpc-api | ||
port: 6001 | ||
protocol: TCP | ||
targetPort: grpc-api | ||
selector: | ||
app.kubernetes.io/name: liqo-resource-plugins | ||
app.kubernetes.io/instance: external-monitor-node-labels-resources | ||
app.kubernetes.io/component: plugin | ||
app.kubernetes.io/part-of: liqo | ||
app.kubernetes.io/managed-by: manual | ||
type: ClusterIP |
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,2 @@ | ||
// Package nodeselectorresources contains the logic for the node-label-resource-plugin. | ||
package nodeselectorresources |
Oops, something went wrong.