Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

updating how concurrency gets set on kubekite #2

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
4 changes: 3 additions & 1 deletion cmd/kubekite/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ func main() {
var kubeNamespace string
var jobTemplateYaml string
var kubeTimeout int
var concurrency int

var format = logging.MustStringFormatter(
`%{color}%{time:15:04:05.000} %{shortfile} ▶ %{level:.4s} %{id:03x}%{color:reset} %{message}`,
Expand All @@ -45,6 +46,7 @@ func main() {
flag.StringVar(&kubeNamespace, "kube-namespace", "default", "Kubernetes namespace to run jobs in")
flag.StringVar(&jobTemplateYaml, "job-template", "job.yaml", "Path to your job template YAML file")
flag.IntVar(&kubeTimeout, "kube-timeout", 15, "Timeout (in seconds) for Kubernetes API requests. Set to 0 for no timeout. Default: 15")
flag.IntVar(&concurrency, "concurrency", 25, "Number of concurrent jobs the job watcher is able to create. Default: 25")

flag.Parse()

Expand Down Expand Up @@ -82,7 +84,7 @@ func main() {
log.Fatal("Error starting Buildkite API client:", err)
}

jobChan := buildkite.StartBuildkiteWatcher(ctx, wg, bkc, bkOrg, bkPipeline)
jobChan := buildkite.StartBuildkiteWatcher(ctx, wg, bkc, bkOrg, bkPipeline, concurrency)

go func(cancel context.CancelFunc) {
// If we get a SIGINT or SIGTERM, cancel the context and unblock 'done'
Expand Down
4 changes: 2 additions & 2 deletions pkg/buildkite/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ func NewBuildkiteClient(bkAPIToken string, debug bool) (*buildkite.Client, error
}

// StartBuildkiteWatcher starts a watcher that monitors a pipeline for new jobs
func StartBuildkiteWatcher(ctx context.Context, wg *sync.WaitGroup, client *buildkite.Client, org string, pipeline string) chan string {
c := make(chan string, 10)
func StartBuildkiteWatcher(ctx context.Context, wg *sync.WaitGroup, client *buildkite.Client, org string, pipeline string, concurrency int) chan string {
c := make(chan string, concurrency)

go watchBuildkiteJobs(ctx, wg, client, org, pipeline, c)

Expand Down
6 changes: 3 additions & 3 deletions rbac/rbac.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
name: kubekite
namespace: default
namespace: buildkite
rules:
- apiGroups: [""]
resources: ["pods"]
Expand All @@ -20,12 +20,12 @@ apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: kubekite
namespace: default
namespace: buildkite
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: Role
name: kubekite
subjects:
- kind: ServiceAccount
name: kubekite
namespace: default
namespace: buildkite