Skip to content

Commit

Permalink
Issue #19 - Add repo-server into installer (#22)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexmt authored Mar 7, 2018
1 parent 405b47f commit 3a7c9c7
Show file tree
Hide file tree
Showing 10 changed files with 53 additions and 6 deletions.
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
# a user's workspace, and are only building off of what is locked by dep.
vendor
Dockerfile-argocd
dist
2 changes: 1 addition & 1 deletion cmd/argocd-application-controller/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +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.")
command.Flags().StringVar(&repoServerAddress, "repo-server", "localhost:8081", "Repo server address.")
return &command
}

Expand Down
6 changes: 3 additions & 3 deletions cmd/argocd-repo-server/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import (

const (
// CLIName is the name of the CLI
cliName = "argocd-manifest-server"
cliName = "argocd-repo-server"
port = 8081
)

Expand Down Expand Up @@ -52,10 +52,10 @@ func newCommand() *cobra.Command {
nativeGitClient, err := git.NewNativeGitClient()
errors.CheckError(err)
grpc := server.CreateGRPC(nativeGitClient)
listener, err := net.Listen("tcp", fmt.Sprintf("127.0.0.1:%d", port))
listener, err := net.Listen("tcp", fmt.Sprintf("0.0.0.0:%d", port))
errors.CheckError(err)

log.Infof("argocd-repo-server %s serving on port %d (namespace: %s)", argocd.GetVersion(), port, namespace)
log.Infof("argocd-repo-server %s serving on %s (namespace: %s)", argocd.GetVersion(), listener.Addr(), namespace)
err = grpc.Serve(listener)
errors.CheckError(err)
return nil
Expand Down
1 change: 1 addition & 0 deletions cmd/argocd/commands/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ func NewInstallCommand() *cobra.Command {
command.Flags().StringVar(&installOpts.ControllerImage, "controller-image", DefaultControllerImage, "use a specified controller image")
command.Flags().StringVar(&installOpts.ServerImage, "server-image", DefaultServerImage, "use a specified api server image")
command.Flags().StringVar(&installOpts.UIImage, "ui-image", DefaultUiImage, "use a specified ui image")
command.Flags().StringVar(&installOpts.RepoServerImage, "repo-server-image", DefaultServerImage, "use a specified repo server image")
command.Flags().StringVar(&installOpts.ImagePullPolicy, "image-pull-policy", "", "set the image pull policy of the pod specs")
clientConfig = cli.AddKubectlFlagsToCmd(command)
return command
Expand Down
1 change: 1 addition & 0 deletions controller/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ func (ctrl *ApplicationController) tryRefreshAppStatus(app *appv1.Application) (
Environment: app.Spec.Source.Environment,
})
if err != nil {
log.Errorf("Failed to load application manifest %v", err)
return nil, err
}
targetObjs := make([]*unstructured.Unstructured, len(manifestInfo.Manifests))
Expand Down
13 changes: 13 additions & 0 deletions install/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ type InstallOptions struct {
ControllerImage string
UIImage string
ServerImage string
RepoServerImage string
ImagePullPolicy string
}

Expand Down Expand Up @@ -75,6 +76,7 @@ func (i *Installer) Install() {
i.InstallApplicationCRD()
i.InstallApplicationController()
i.InstallArgoCDServer()
i.InstallArgoCDRepoServer()
}

func (i *Installer) InstallNamespace() {
Expand Down Expand Up @@ -129,6 +131,17 @@ func (i *Installer) InstallArgoCDServer() {
i.MustInstallResource(kube.MustToUnstructured(&argoCDServerService))
}

func (i *Installer) InstallArgoCDRepoServer() {
var argoCDRepoServerControllerDeployment appsv1beta2.Deployment
var argoCDRepoServerService apiv1.Service
i.unmarshalManifest("04a_argocd-repo-server-deployment.yaml", &argoCDRepoServerControllerDeployment)
i.unmarshalManifest("04b_argocd-repo-server-service.yaml", &argoCDRepoServerService)
argoCDRepoServerControllerDeployment.Spec.Template.Spec.Containers[0].Image = i.RepoServerImage
argoCDRepoServerControllerDeployment.Spec.Template.Spec.Containers[0].ImagePullPolicy = apiv1.PullPolicy(i.ImagePullPolicy)
i.MustInstallResource(kube.MustToUnstructured(&argoCDRepoServerControllerDeployment))
i.MustInstallResource(kube.MustToUnstructured(&argoCDRepoServerService))
}

func (i *Installer) unmarshalManifest(fileName string, obj interface{}) {
yamlBytes, err := i.box.MustBytes(fileName)
errors.CheckError(err)
Expand Down
3 changes: 1 addition & 2 deletions install/manifests/02d_application-controller-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ spec:
app: application-controller
spec:
containers:
- command:
- /argocd-application-controller
- command: [/argocd-application-controller, --repo-server, 'argocd-repo-server:8081']
image: argoproj/argocd-application-controller:latest
name: application-controller
serviceAccountName: application-controller
20 changes: 20 additions & 0 deletions install/manifests/04a_argocd-repo-server-deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
apiVersion: apps/v1beta2
kind: Deployment
metadata:
name: argocd-repo-server
namespace: argocd
spec:
selector:
matchLabels:
app: argocd-repo-server
template:
metadata:
labels:
app: argocd-repo-server
spec:
containers:
- command: [/argocd-repo-server]
image: argoproj/argocd-repo-server:latest
name: argocd-repo-server
ports:
- containerPort: 8081
10 changes: 10 additions & 0 deletions install/manifests/04b_argocd-repo-server-service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
apiVersion: v1
kind: Service
metadata:
name: argocd-repo-server
namespace: argocd
spec:
ports:
- port: 8081
selector:
app: argocd-repo-server
2 changes: 2 additions & 0 deletions reposerver/clientset.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package reposerver
import (
"github.com/argoproj/argo-cd/reposerver/repository"
"github.com/argoproj/argo-cd/util"
log "github.com/sirupsen/logrus"
"google.golang.org/grpc"
)

Expand All @@ -18,6 +19,7 @@ type clientSet struct {
func (c *clientSet) NewRepositoryClient() (util.Closer, repository.RepositoryServiceClient, error) {
conn, err := grpc.Dial(c.address, grpc.WithInsecure())
if err != nil {
log.Errorf("Unable to connect to repository service with address %s", c.address)
return nil, nil, err
}
return conn, repository.NewRepositoryServiceClient(conn), nil
Expand Down

0 comments on commit 3a7c9c7

Please sign in to comment.