Skip to content

Commit

Permalink
operator: move Azure-specific operator flags
Browse files Browse the repository at this point in the history
Split out all cilium-operator options which are specific to Azure
the github.com/cilium/cilium/operator/option package.

Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
  • Loading branch information
tklauser authored and qmonnet committed Apr 28, 2020
1 parent d16af4a commit 88d1d93
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 21 deletions.
8 changes: 4 additions & 4 deletions operator/flags.go
Expand Up @@ -44,11 +44,11 @@ func init() {
flags.Float64(operatorOption.IPAMAPIQPSLimit, defaults.IPAMAPIQPSLimit, "Queries per second limit when accessing external IPAM APIs")
option.BindEnv(operatorOption.IPAMAPIQPSLimit)

flags.String(option.AzureSubscriptionID, "", "Subscription ID to access Azure API")
option.BindEnvWithLegacyEnvFallback(option.AzureSubscriptionID, "AZURE_SUBSCRIPTION_ID")
flags.String(operatorOption.AzureSubscriptionID, "", "Subscription ID to access Azure API")
option.BindEnvWithLegacyEnvFallback(operatorOption.AzureSubscriptionID, "AZURE_SUBSCRIPTION_ID")

flags.String(option.AzureResourceGroup, "", "Resource group to use for Azure IPAM")
option.BindEnvWithLegacyEnvFallback(option.AzureResourceGroup, "AZURE_RESOURCE_GROUP")
flags.String(operatorOption.AzureResourceGroup, "", "Resource group to use for Azure IPAM")
option.BindEnvWithLegacyEnvFallback(operatorOption.AzureResourceGroup, "AZURE_RESOURCE_GROUP")

flags.Var(option.NewNamedMapOptions(operatorOption.AWSInstanceLimitMapping, &operatorOption.Config.AWSInstanceLimitMapping, nil),
operatorOption.AWSInstanceLimitMapping,
Expand Down
21 changes: 21 additions & 0 deletions operator/option/config.go
Expand Up @@ -126,6 +126,14 @@ const (
// UpdateEC2AdapterLimitViaAPI configures the operator to use the EC2
// API to fill out the instnacetype to adapter limit mapping.
UpdateEC2AdapterLimitViaAPI = "update-ec2-apdater-limit-via-api"

// Azure options

// AzureSubscriptionID is the subscription ID to use when accessing the Azure API
AzureSubscriptionID = "azure-subscription-id"

// AzureResourceGroup is the resource group of the nodes used for the cluster
AzureResourceGroup = "azure-resource-group"
)

// OperatorConfig is the configuration used by the operator.
Expand Down Expand Up @@ -218,6 +226,14 @@ type OperatorConfig struct {

// UpdateEC2AdapterLimitViaAPI configures the operator to use the EC2 API to fill out the instnacetype to adapter limit mapping
UpdateEC2AdapterLimitViaAPI bool

// Azure options

// AzureSubscriptionID is the subscription ID to use when accessing the Azure API
AzureSubscriptionID string

// AzureResourceGroup is the resource group of the nodes used for the cluster
AzureResourceGroup string
}

func (c *OperatorConfig) Populate() {
Expand All @@ -242,6 +258,11 @@ func (c *OperatorConfig) Populate() {
c.AWSReleaseExcessIPs = viper.GetBool(AWSReleaseExcessIPs)
c.UpdateEC2AdapterLimitViaAPI = viper.GetBool(UpdateEC2AdapterLimitViaAPI)

// Azure options

c.AzureSubscriptionID = viper.GetString(AzureSubscriptionID)
c.AzureResourceGroup = viper.GetString(AzureResourceGroup)

// Deprecated options

if val := viper.GetInt(AWSClientBurstDeprecated); val != 0 {
Expand Down
5 changes: 2 additions & 3 deletions pkg/ipam/allocator/azure/azure.go
Expand Up @@ -27,7 +27,6 @@ import (
ipamMetrics "github.com/cilium/cilium/pkg/ipam/metrics"
"github.com/cilium/cilium/pkg/logging"
"github.com/cilium/cilium/pkg/logging/logfields"
"github.com/cilium/cilium/pkg/option"
"github.com/pkg/errors"
)

Expand All @@ -49,7 +48,7 @@ func (*AllocatorAzure) Start(getterUpdater ipam.CiliumNodeGetterUpdater) (*ipam.

log.Info("Starting Azure IP allocator...")

subscriptionID := option.Config.AzureSubscriptionID
subscriptionID := operatorOption.Config.AzureSubscriptionID
if subscriptionID == "" {
log.Debug("SubscriptionID was not specified via CLI, retrieving it via Azure IMS")
subID, err := azureAPI.GetSubscriptionID(context.TODO())
Expand All @@ -60,7 +59,7 @@ func (*AllocatorAzure) Start(getterUpdater ipam.CiliumNodeGetterUpdater) (*ipam.
log.WithField("subscriptionID", subscriptionID).Debug("Detected subscriptionID via Azure IMS")
}

resourceGroupName := option.Config.AzureResourceGroup
resourceGroupName := operatorOption.Config.AzureResourceGroup
if resourceGroupName == "" {
log.Debug("ResourceGroupName was not specified via CLI, retrieving it via Azure IMS")
rgName, err := azureAPI.GetResourceGroupName(context.TODO())
Expand Down
14 changes: 0 additions & 14 deletions pkg/option/config.go
Expand Up @@ -701,12 +701,6 @@ const (
// EnableRemoteNodeIdentity enables use of the remote-node identity
EnableRemoteNodeIdentity = "enable-remote-node-identity"

// AzureSubscriptionID is the subscription ID to use when accessing the Azure API
AzureSubscriptionID = "azure-subscription-id"

// AzureResourceGroup is the resource group of the nodes used for the cluster
AzureResourceGroup = "azure-resource-group"

// PolicyAuditModeArg argument enables policy audit mode.
PolicyAuditModeArg = "policy-audit-mode"

Expand Down Expand Up @@ -1698,12 +1692,6 @@ type DaemonConfig struct {

// Azure options

// AzureSubscriptionID is the subscription ID to use when accessing the Azure API
AzureSubscriptionID string

// AzureResourceGroup is the resource group of the nodes used for the cluster
AzureResourceGroup string

// PolicyAuditMode enables non-drop mode for installed policies. In
// audit mode packets affected by policies will not be dropped.
// Policy related decisions can be checked via the poicy verdict messages.
Expand Down Expand Up @@ -2108,8 +2096,6 @@ func (c *DaemonConfig) Populate() {
c.AllowLocalhost = viper.GetString(AllowLocalhost)
c.AnnotateK8sNode = viper.GetBool(AnnotateK8sNode)
c.AutoCreateCiliumNodeResource = viper.GetBool(AutoCreateCiliumNodeResource)
c.AzureSubscriptionID = viper.GetString(AzureSubscriptionID)
c.AzureResourceGroup = viper.GetString(AzureResourceGroup)
c.BPFCompilationDebug = viper.GetBool(BPFCompileDebugName)
c.BPFRoot = viper.GetString(BPFRoot)
c.CertDirectory = viper.GetString(CertsDirectory)
Expand Down

0 comments on commit 88d1d93

Please sign in to comment.