Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ rbacs: controller-gen
$(CONTROLLER_GEN) paths="./cmd/telemetry" rbac:roleName=liqo-telemetry output:rbac:stdout | awk -v RS="---\n" 'NR>1{f="./deployments/liqo/files/liqo-telemetry-" $$4 ".yaml";printf "%s",$$0 > f; close(f)}' && $(SED_COMMAND) deployments/liqo/files/liqo-telemetry-ClusterRole.yaml
$(CONTROLLER_GEN) paths="{./pkg/gateway/...,./cmd/gateway/...,./pkg/firewall/...,./pkg/route/...}" rbac:roleName=liqo-gateway output:rbac:stdout | awk -v RS="---\n" 'NR>1{f="./deployments/liqo/files/liqo-gateway-" $$4 ".yaml";printf "%s",$$0 > f; close(f)}' && $(SED_COMMAND) deployments/liqo/files/liqo-gateway-ClusterRole.yaml
$(CONTROLLER_GEN) paths="{./cmd/fabric/...,./pkg/firewall/...,./pkg/route/...,./pkg/fabric/...}" rbac:roleName=liqo-fabric output:rbac:stdout | awk -v RS="---\n" 'NR>1{f="./deployments/liqo/files/liqo-fabric-" $$4 ".yaml";printf "%s",$$0 > f; close(f)}' && $(SED_COMMAND) deployments/liqo/files/liqo-fabric-ClusterRole.yaml
$(CONTROLLER_GEN) paths="./cmd/ipam/" rbac:roleName=liqo-ipam output:rbac:stdout | awk -v RS="---\n" 'NR>1{f="./deployments/liqo/files/liqo-ipam-" $$4 ".yaml";printf "%s",$$0 > f; close(f)}' && $(SED_COMMAND) deployments/liqo/files/liqo-ipam-ClusterRole.yaml
$(CONTROLLER_GEN) paths="{./cmd/ipam/...,./pkg/ipam/...}" rbac:roleName=liqo-ipam output:rbac:stdout | awk -v RS="---\n" 'NR>1{f="./deployments/liqo/files/liqo-ipam-" $$4 ".yaml";printf "%s",$$0 > f; close(f)}' && $(SED_COMMAND) deployments/liqo/files/liqo-ipam-ClusterRole.yaml

# Install gci if not available
gci:
Expand Down
16 changes: 9 additions & 7 deletions cmd/ipam/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
"fmt"
"net"
"os"
"time"

"github.com/spf13/cobra"
"google.golang.org/grpc"
Expand All @@ -42,7 +43,7 @@ import (
"github.com/liqotech/liqo/pkg/utils/restcfg"
)

const leaderElectorName = "liqo-ipam-leader-election"
const leaderElectorName = "liqo-ipam-leaderelection"

var (
scheme = runtime.NewScheme()
Expand All @@ -57,7 +58,6 @@ func init() {
// +kubebuilder:rbac:groups=core,resources=events,verbs=get;list;watch;create;update;patch;delete
// +kubebuilder:rbac:groups=apps,resources=deployments,verbs=get;list;watch;
// +kubebuilder:rbac:groups=core,resources=pods,verbs=get;list;watch;update;patch
// +kubebuilder:rbac:groups=ipam.liqo.io,resources=ipamstorages,verbs=get;list;watch;create;update;patch

var options ipam.Options

Expand All @@ -73,15 +73,15 @@ func main() {
cmd.Flags().IntVar(&options.Port, "port", consts.IpamPort, "The port on which to listen for incoming gRPC requests.")
cmd.Flags().BoolVar(&options.EnableLeaderElection, "leader-election", false, "Enable leader election for IPAM. "+
"Enabling this will ensure there is only one active IPAM.")
cmd.Flags().StringVar(&options.LeaderElectionNamespace, "leader-election-namespace", "liqo",
cmd.Flags().StringVar(&options.LeaderElectionNamespace, "leader-election-namespace", consts.DefaultLiqoNamespace,
"The namespace in which the leader election lease will be created.")
cmd.Flags().StringVar(&options.LeaderElectionName, "leader-election-name", leaderElectorName,
"The name of the leader election lease.")
cmd.Flags().DurationVar(&options.LeaseDuration, "lease-duration", 15,
cmd.Flags().DurationVar(&options.LeaseDuration, "lease-duration", 15*time.Second,
"The duration that non-leader candidates will wait to force acquire leadership.")
cmd.Flags().DurationVar(&options.RenewDeadline, "renew-deadline", 10,
cmd.Flags().DurationVar(&options.RenewDeadline, "renew-deadline", 10*time.Second,
"The duration that the acting IPAM will retry refreshing leadership before giving up.")
cmd.Flags().DurationVar(&options.RetryPeriod, "retry-period", 2,
cmd.Flags().DurationVar(&options.RetryPeriod, "retry-period", 5*time.Second,
"The duration the LeaderElector clients should wait between tries of actions.")
cmd.Flags().StringVar(&options.PodName, "pod-name", "",
"The name of the pod running the IPAM service.")
Expand All @@ -103,7 +103,9 @@ func run(cmd *cobra.Command, _ []string) error {
// Get the rest config.
cfg := restcfg.SetRateLimiter(ctrl.GetConfigOrDie())
options.Config = cfg
cl, err := client.New(cfg, client.Options{})
cl, err := client.New(cfg, client.Options{
Scheme: scheme,
})
if err != nil {
return err
}
Expand Down
9 changes: 3 additions & 6 deletions cmd/liqo-controller-manager/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
package main

import (
"context"
"os"
"time"

Expand Down Expand Up @@ -252,15 +251,13 @@ func main() {
var ipamClient ipam.IpamClient
if *ipamServer != "" {
klog.Infof("connecting to the IPAM server %q", *ipamServer)
dialctx, cancel := context.WithTimeout(ctx, 10*time.Second)
connection, err := grpc.DialContext(dialctx, *ipamServer,
grpc.WithTransportCredentials(insecure.NewCredentials()), grpc.WithBlock())
cancel()
conn, err := grpc.NewClient(*ipamServer, grpc.WithTransportCredentials(insecure.NewCredentials()))
if err != nil {
klog.Errorf("failed to establish a connection to the IPAM %q", *ipamServer)
os.Exit(1)
}
ipamClient = ipam.NewIpamClient(connection)
defer conn.Close()
ipamClient = ipam.NewIpamClient(conn)
}

if err := modules.SetupNetworkingModule(ctx, mgr, &modules.NetworkingOption{
Expand Down
2 changes: 1 addition & 1 deletion cmd/telemetry/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ func main() {

telemetryEndpoint := pflag.String("telemetry-endpoint", "https://api.telemetry.liqo.io/v1", "telemetry endpoint")
timeout := pflag.Duration("timeout", 10*time.Second, "timeout for requests")
namespace := pflag.String("namespace", "liqo", "the namespace where liqo is deployed")
namespace := pflag.String("namespace", consts.DefaultLiqoNamespace, "the namespace where liqo is deployed")
liqoVersion := pflag.String("liqo-version", "", "the liqo version")
kubernetesVersion := pflag.String("kubernetes-version", "", "the kubernetes version")
dryRun := pflag.Bool("dry-run", false, "if true, do not send the telemetry item and print it on stdout")
Expand Down
6 changes: 2 additions & 4 deletions deployments/liqo/files/liqo-ipam-ClusterRole.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,9 @@ rules:
- apiGroups:
- ipam.liqo.io
resources:
- ipamstorages
- ips
- networks
verbs:
- create
- get
- list
- patch
- update
- watch
1 change: 1 addition & 0 deletions deployments/liqo/templates/liqo-ipam-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ spec:
- --port=6000
{{- if $ha }}
- --leader-election
- --leader-election-namespace=$(POD_NAMESPACE)
{{- end }}
{{- if .Values.common.extraArgs }}
{{- toYaml .Values.common.extraArgs | nindent 12 }}
Expand Down
25 changes: 25 additions & 0 deletions pkg/ipam/ipam.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,3 +63,28 @@ func New(ctx context.Context, opts *Options) (*LiqoIPAM, error) {
opts.HealthServer.SetServingStatus(IPAM_ServiceDesc.ServiceName, grpc_health_v1.HealthCheckResponse_SERVING)
return lipam, nil
}

// IPAcquire acquires a free IP from a given CIDR.
func (lipam *LiqoIPAM) IPAcquire(_ context.Context, _ *IPAcquireRequest) (*IPAcquireResponse, error) {
panic("implement me")
}

// IPRelease releases an IP from a given CIDR.
func (lipam *LiqoIPAM) IPRelease(_ context.Context, _ *IPReleaseRequest) (*IPReleaseResponse, error) {
panic("implement me")
}

// NetworkAcquire acquires a network. If it is already reserved, it allocates and reserves a new free one with the same prefix length.
func (lipam *LiqoIPAM) NetworkAcquire(_ context.Context, _ *NetworkAcquireRequest) (*NetworkAcquireResponse, error) {
panic("implement me")
}

// NetworkRelease releases a network.
func (lipam *LiqoIPAM) NetworkRelease(_ context.Context, _ *NetworkReleaseRequest) (*NetworkReleaseResponse, error) {
panic("implement me")
}

// NetworkIsAvailable checks if a network is available.
func (lipam *LiqoIPAM) NetworkIsAvailable(_ context.Context, _ *NetworkAvailableRequest) (*NetworkAvailableResponse, error) {
panic("implement me")
}