Skip to content

Commit

Permalink
Issue #19 - Move Kubernetes manifest generation into separate service (
Browse files Browse the repository at this point in the history
  • Loading branch information
alexmt authored Mar 7, 2018
1 parent cc232a4 commit 405b47f
Show file tree
Hide file tree
Showing 32 changed files with 681 additions and 357 deletions.
1 change: 1 addition & 0 deletions .argo-ci/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ spec:
withItems:
- make controller-image
- make server-image
- make repo-server-image
- name: test
template: ci-builder
arguments:
Expand Down
11 changes: 10 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ IMAGE_PREFIX=${IMAGE_NAMESPACE}/
endif

.PHONY: all
all: cli server-image controller-image
all: cli server-image controller-image repo-server-image

.PHONY: protogen
protogen:
Expand Down Expand Up @@ -67,6 +67,15 @@ server-image:
docker build --build-arg BINARY=argocd-server --build-arg MAKE_TARGET=server -t $(IMAGE_PREFIX)argocd-server:$(IMAGE_TAG) -f Dockerfile-argocd .
@if [ "$(DOCKER_PUSH)" = "true" ] ; then docker push $(IMAGE_PREFIX)argocd-server:$(IMAGE_TAG) ; fi

.PHONY: repo-server
repo-server:
CGO_ENABLED=0 go build -v -i -ldflags '${LDFLAGS}' -o ${DIST_DIR}/argocd-repo-server ./cmd/argocd-repo-server

.PHONY: repo-server-image
repo-server-image:
docker build --build-arg BINARY=argocd-repo-server --build-arg MAKE_TARGET=repo-server -t $(IMAGE_PREFIX)argocd-repo-server:$(IMAGE_TAG) -f Dockerfile-argocd .
@if [ "$(DOCKER_PUSH)" = "true" ] ; then docker push $(IMAGE_PREFIX)argocd-server:$(IMAGE_TAG) ; fi

.PHONY: controller
controller:
CGO_ENABLED=0 go build -v -i -ldflags '${LDFLAGS}' -o ${DIST_DIR}/argocd-application-controller ./cmd/argocd-application-controller
Expand Down
99 changes: 0 additions & 99 deletions application/manager.go

This file was deleted.

161 changes: 0 additions & 161 deletions application/manager_test.go

This file was deleted.

36 changes: 18 additions & 18 deletions cmd/argocd-application-controller/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,12 @@ import (
"time"

argocd "github.com/argoproj/argo-cd"
"github.com/argoproj/argo-cd/application"
"github.com/argoproj/argo-cd/controller"
"github.com/argoproj/argo-cd/errors"
appclientset "github.com/argoproj/argo-cd/pkg/client/clientset/versioned"
"github.com/argoproj/argo-cd/server/cluster"
"github.com/argoproj/argo-cd/server/repository"
apirepository "github.com/argoproj/argo-cd/server/repository"
"github.com/argoproj/argo-cd/util/cli"
"github.com/argoproj/argo-cd/util/git"
log "github.com/sirupsen/logrus"
"github.com/spf13/cobra"
"k8s.io/client-go/kubernetes"
Expand All @@ -23,20 +21,22 @@ import (
// load the gcp plugin (required to authenticate against GKE clusters).
_ "k8s.io/client-go/plugin/pkg/client/auth/gcp"
// load the oidc plugin (required to authenticate with OpenID Connect).
"github.com/argoproj/argo-cd/reposerver"
_ "k8s.io/client-go/plugin/pkg/client/auth/oidc"
)

const (
// CLIName is the name of the CLI
cliName = "application-controller"
cliName = "argocd-application-controller"
// Default time in seconds for application resync period
defaultAppResyncPeriod = 600
)

func newCommand() *cobra.Command {
var (
clientConfig clientcmd.ClientConfig
appResyncPeriod int64
clientConfig clientcmd.ClientConfig
appResyncPeriod int64
repoServerAddress string
)
var command = cobra.Command{
Use: cliName,
Expand All @@ -45,10 +45,6 @@ func newCommand() *cobra.Command {
config, err := clientConfig.ClientConfig()
errors.CheckError(err)

nativeGitClient, err := git.NewNativeGitClient()
if err != nil {
return err
}
kubeClient := kubernetes.NewForConfigOrDie(config)
appClient := appclientset.NewForConfigOrDie(config)

Expand All @@ -60,16 +56,19 @@ func newCommand() *cobra.Command {
Namespace: namespace,
InstanceID: "",
}
clusterService := cluster.NewServer(namespace, kubeClient, appClient)
resyncDuration := time.Duration(appResyncPeriod) * time.Second
appManager := application.NewAppManager(
nativeGitClient,
repository.NewServer(namespace, kubeClient, appClient),
clusterService,
application.NewKsonnetAppComparator(clusterService),
apiRepoServer := apirepository.NewServer(namespace, kubeClient, appClient)
clusterService := cluster.NewServer(namespace, kubeClient, appClient)
appComparator := controller.NewKsonnetAppComparator(clusterService)

appController := controller.NewApplicationController(
kubeClient,
appClient,
reposerver.NewRepositoryServerClientset(repoServerAddress),
apiRepoServer,
appComparator,
resyncDuration,
)
appController := controller.NewApplicationController(kubeClient, appClient, appManager, resyncDuration, &controllerConfig)
&controllerConfig)

ctx, cancel := context.WithCancel(context.Background())
defer cancel()
Expand All @@ -83,6 +82,7 @@ func newCommand() *cobra.Command {

clientConfig = cli.AddKubectlFlagsToCmd(&command)
command.Flags().Int64Var(&appResyncPeriod, "app-resync", defaultAppResyncPeriod, "Time period in seconds for application resync.")
command.Flags().StringVar(&repoServerAddress, "reposerveraddr", "localhost:8081", "Repo server address.")
return &command
}

Expand Down
Loading

0 comments on commit 405b47f

Please sign in to comment.