-
Notifications
You must be signed in to change notification settings - Fork 110
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This patch introduces a set of commands allowing to generate a user with the minimum permissions to create a peering from the cluster with the specified cluster ID
- Loading branch information
1 parent
d03e24a
commit 6f648e2
Showing
20 changed files
with
996 additions
and
20 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
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,65 @@ | ||
rules: | ||
- apiGroups: | ||
- "networking.liqo.io" | ||
resources: | ||
- "configurations" | ||
- "gatewayclients" | ||
- "gatewayservers" | ||
- "publickeies" | ||
verbs: | ||
- "create" | ||
- "update" | ||
- "get" | ||
- "list" | ||
- "delete" | ||
- apiGroups: | ||
- "networking.liqo.io" | ||
resources: | ||
- "connections" | ||
verbs: | ||
- "get" | ||
- "list" | ||
- apiGroups: | ||
- "networking.liqo.io" | ||
resources: | ||
- "gatewayclients/status" | ||
- "gatewayservers/status" | ||
verbs: | ||
- "get" | ||
- apiGroups: | ||
- "" | ||
resources: | ||
- "configmaps" | ||
- "secrets" | ||
verbs: | ||
- "create" | ||
- "get" | ||
- "list" | ||
- "delete" | ||
- apiGroups: | ||
- "" | ||
resources: | ||
- "services" | ||
verbs: | ||
- "get" | ||
- apiGroups: | ||
- "apps" | ||
resources: | ||
- "deployments" | ||
verbs: | ||
- "get" | ||
- apiGroups: | ||
- "ipam.liqo.io" | ||
resources: | ||
- "ips" | ||
verbs: | ||
- "create" | ||
- "update" | ||
- "get" | ||
- "delete" | ||
- apiGroups: | ||
- "authentication.liqo.io" | ||
resources: | ||
- "tenants/status" | ||
verbs: | ||
- "get" |
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 @@ | ||
rules: | ||
- apiGroups: | ||
- "" | ||
resources: | ||
- configmaps | ||
verbs: | ||
- get | ||
- list | ||
- watch | ||
- apiGroups: | ||
- "networking.liqo.io" | ||
resources: | ||
- "wggatewayservertemplates" | ||
- "wggatewayclienttemplates" | ||
verbs: | ||
- "get" | ||
- "list" |
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 @@ | ||
{{- $peeringroles := (merge (dict "name" "peering-user" "module" "peering-user") .) -}} | ||
|
||
apiVersion: rbac.authorization.k8s.io/v1 | ||
kind: ClusterRole | ||
metadata: | ||
name: {{ include "liqo.prefixedName" $peeringroles}} | ||
labels: | ||
{{- include "liqo.labels" $peeringroles| nindent 4 }} | ||
{{ .Files.Get (include "liqo.cluster-role-filename" (dict "prefix" ( include "liqo.prefixedName" $peeringroles))) }} | ||
--- | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
kind: Role | ||
metadata: | ||
name: {{ include "liqo.prefixedName" $peeringroles}} | ||
labels: | ||
{{- include "liqo.labels" $peeringroles| nindent 4 }} | ||
{{ .Files.Get (include "liqo.role-filename" (dict "prefix" ( include "liqo.prefixedName" $peeringroles))) }} |
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 |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// Copyright 2019-2025 The Liqo 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 peeringuser | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/spf13/cobra" | ||
|
||
"github.com/liqotech/liqo/pkg/liqoctl/rest" | ||
) | ||
|
||
// Create implements the create command. | ||
func (o *Options) Create(_ context.Context, _ *rest.CreateOptions) *cobra.Command { | ||
panic("not implemented") | ||
} |
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,74 @@ | ||
// Copyright 2019-2025 The Liqo 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 peeringuser | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
|
||
"github.com/spf13/cobra" | ||
"k8s.io/apimachinery/pkg/util/runtime" | ||
|
||
liqov1beta1 "github.com/liqotech/liqo/apis/core/v1beta1" | ||
"github.com/liqotech/liqo/pkg/liqoctl/output" | ||
"github.com/liqotech/liqo/pkg/liqoctl/rest" | ||
"github.com/liqotech/liqo/pkg/liqoctl/rest/peering-user/userfactory" | ||
) | ||
|
||
const liqoctlDeletePeeringUserHelp = `elete an existing user with the permissions to peer with this cluster. | ||
Delete a peering user, so that it will no longer be able to peer with this cluster from the cluster with the given Cluster ID. | ||
The previous credentials will be invalidated, and cannot be used anymore, even if the user is recreated. | ||
Examples: | ||
$ {{ .Executable }} delete peering-user --consumer-cluster-id=<cluster-id>` | ||
|
||
// Delete deletes a user. | ||
func (o *Options) Delete(ctx context.Context, options *rest.DeleteOptions) *cobra.Command { | ||
cmd := &cobra.Command{ | ||
Use: "peering-user", | ||
Short: "Delete an existing user with the permissions to peer with this cluster", | ||
Long: liqoctlDeletePeeringUserHelp, | ||
Args: cobra.NoArgs, | ||
|
||
PreRun: func(_ *cobra.Command, _ []string) { | ||
o.deleteOptions = options | ||
}, | ||
|
||
Run: func(_ *cobra.Command, _ []string) { | ||
output.ExitOnErr(o.handleDelete(ctx)) | ||
}, | ||
} | ||
|
||
cmd.Flags().Var(&o.clusterID, "consumer-cluster-id", "The cluster ID of the cluster from which peering has been performed") | ||
|
||
runtime.Must(cmd.MarkFlagRequired("consumer-cluster-id")) | ||
|
||
return cmd | ||
} | ||
|
||
func (o *Options) handleDelete(ctx context.Context) error { | ||
opts := o.deleteOptions | ||
clusterID := liqov1beta1.ClusterID(*o.clusterID.ClusterID) | ||
|
||
if err := userfactory.RemovePermissions(ctx, opts.CRClient, clusterID); err != nil { | ||
wErr := fmt.Errorf("unable to delete peering user: %w", err) | ||
opts.Printer.Error.Println(wErr) | ||
return wErr | ||
} | ||
|
||
opts.Printer.Success.Printfln("Peering user for cluster with ID %q deleted successfully", clusterID) | ||
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,16 @@ | ||
// Copyright 2019-2025 The Liqo 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 peeringuser contains the rest API commands to allow liqoctl to create an authentication token to authenticate to this cluster. | ||
package peeringuser |
Oops, something went wrong.