ads: Mesh Catalog needs Endpoint Providers
@@ -4,6 +4,10 @@ import (
"context"
"flag"
"fmt"
+ "github.com/deislabs/smc/pkg/constants"
+ "github.com/deislabs/smc/pkg/endpoint"
+ "github.com/deislabs/smc/pkg/providers/azure"
+ "github.com/deislabs/smc/pkg/providers/kube"
"os"
"os/signal"
"strings"
@@ -20,6 +24,7 @@ import (
"github.com/deislabs/smc/pkg/httpserver"
"github.com/deislabs/smc/pkg/log/level"
"github.com/deislabs/smc/pkg/metricsstore"
+ azureResource "github.com/deislabs/smc/pkg/providers/azure/kubernetes"
"github.com/deislabs/smc/pkg/smi"
"github.com/deislabs/smc/pkg/tresor"
"github.com/deislabs/smc/pkg/utils"
@@ -30,9 +35,12 @@ const (
defaultNamespace = "default"
)
+var azureAuthFile string
+
var (
flags = pflag.NewFlagSet(`ads`, pflag.ExitOnError)
kubeConfigFile = flags.String("kubeconfig", "", "Path to Kubernetes config file.")
+ subscriptionID = flags.String("subscriptionID", "", "Azure Subscription")
verbosity = flags.Int("verbosity", int(level.Info), "Set log verbosity level")
port = flags.Int("port", 15128, "Clusters Discovery Service port number.")
namespace = flags.String("namespace", "default", "Kubernetes namespace to watch for SMI Spec.")
@@ -41,6 +49,10 @@ var (
rootCertPem = flags.String("rootcertpem", "", "Full path to the Root Certificate PEM file")
)
+func init() {
+ flags.StringVar(&azureAuthFile, "azureAuthFile", "", "Path to Azure Auth File")
+}
+
func main() {
defer glog.Flush()
parseFlags()
@@ -61,7 +73,17 @@ func main() {
if err != nil {
glog.Fatal("Could not instantiate Certificate Manager: ", err)
}
- meshCatalog := catalog.NewMeshCatalog(meshSpec, certManager, stop)
+
+ endpointsProviders := []endpoint.Provider{
+ kube.NewProvider(kubeConfig, observeNamespaces, stop, constants.KubeProviderName),
+ }
+
+ if azureAuthFile != "" {
+ azureResourceClient := azureResource.NewClient(kubeConfig, observeNamespaces, stop)
+ endpointsProviders = append(endpointsProviders, azure.NewProvider(
+ *subscriptionID, azureAuthFile, stop, meshSpec, azureResourceClient, constants.AzureProviderName))
+ }
+ meshCatalog := catalog.NewMeshCatalog(meshSpec, certManager, stop, endpointsProviders...)
// TODO(draychev): there should be no need to pass meshSpec to the ADS - it is already in meshCatalog
adsServer := ads.NewADSServer(ctx, meshCatalog, meshSpec)
