-
-
Notifications
You must be signed in to change notification settings - Fork 289
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Alex Ellis (OpenFaaS Ltd) <alexellis2@gmail.com>
- Loading branch information
Showing
44 changed files
with
4,697 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
bazaar | ||
bin/** | ||
kubeconfig | ||
.DS_Store | ||
.idea/ | ||
mc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
Version := $(shell git describe --tags --dirty) | ||
GitCommit := $(shell git rev-parse HEAD) | ||
LDFLAGS := "-s -w -X github.com/alexellis/bazaar/cmd.Version=$(Version) -X github.com/alexellis/bazaar/cmd.GitCommit=$(GitCommit)" | ||
PLATFORM := $(shell ./hack/platform-tag.sh) | ||
|
||
.PHONY: all | ||
|
||
.PHONY: build | ||
build: | ||
go build | ||
|
||
.PHONY: test | ||
test: | ||
CGO_ENABLED=0 go test $(shell go list ./... | grep -v /vendor/|xargs echo) -cover | ||
|
||
.PHONY: dist | ||
dist: | ||
mkdir -p bin | ||
GO111MODULE=on CGO_ENABLED=0 GOOS=linux go build -mod=vendor -ldflags $(LDFLAGS) -a -installsuffix cgo -o bin/bazaar | ||
GO111MODULE=on CGO_ENABLED=0 GOOS=darwin go build -mod=vendor -ldflags $(LDFLAGS) -a -installsuffix cgo -o bin/bazaar-darwin | ||
GO111MODULE=on CGO_ENABLED=0 GOOS=linux GOARCH=arm GOARM=6 go build -mod=vendor -ldflags $(LDFLAGS) -a -installsuffix cgo -o bin/bazaar-armhf | ||
GO111MODULE=on CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -mod=vendor -ldflags $(LDFLAGS) -a -installsuffix cgo -o bin/bazaar-arm64 | ||
GO111MODULE=on CGO_ENABLED=0 GOOS=windows go build -mod=vendor -ldflags $(LDFLAGS) -a -installsuffix cgo -o bin/bazaar.exe |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,79 @@ | ||
# bazaar | ||
Bazaar - a Kubernetes marketplace | ||
# bazaar - get Kubernetes apps, the easy way | ||
|
||
With bazaar, you can install around a dozen of the most popular cloud native tools to Kubernetes including: nginx-ingress, Minio, OpenFaaS, Istio, cert-manager and many more. Save yourself the hassle of traversing dozens of README files, bazaar automates everything for you including the downloading of helm. | ||
|
||
[![Build | ||
Status](https://travis-ci.com/alexellis/bazaar.svg?branch=master)](https://travis-ci.com/alexellis/bazaar) | ||
[![Go Report Card](https://goreportcard.com/badge/github.com/alexellis/bazaar)](https://goreportcard.com/report/github.com/alexellis/bazaar) | ||
[![GoDoc](https://godoc.org/github.com/alexellis/bazaar?status.svg)](https://godoc.org/github.com/alexellis/bazaar) [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) | ||
![GitHub All Releases](https://img.shields.io/github/downloads/alexellis/bazaar/total) | ||
|
||
## Usage | ||
|
||
Here's a few examples of apps you can install, for a complete list run: `[baz]aar install --help`. | ||
|
||
```bash | ||
[baz]aar install openfaas --gateways 2 --load-balancer false | ||
|
||
[baz]aar install cert-manager | ||
|
||
[baz]aar install nginx-ingress | ||
|
||
[baz]aar install inlets-operator --access-token $HOME/digitalocean --region lon1 | ||
``` | ||
|
||
An alias of `baz` is created at installation time. | ||
|
||
Here's how you can get a self-hosted Docker registry with TLS and authentication in just 5 commands on an empty cluster: | ||
|
||
```bash | ||
bazaar install nginx-ingress | ||
bazaar install cert-manager | ||
bazaar install docker-registry | ||
bazaar install docker-registry-ingress \ | ||
--email web@example.com \ | ||
--domain reg.example.com | ||
``` | ||
|
||
The same for OpenFaaS would look like this: | ||
|
||
```bash | ||
bazaar install nginx-ingress | ||
bazaar install cert-manager | ||
bazaar install openfaas | ||
bazaar install openfaas-ingress \ | ||
--email web@example.com \ | ||
--domain reg.example.com | ||
``` | ||
|
||
And if you're running on a private cloud, on-premises or on your laptop, you can simply add the inlets-operator using inlets-pro to get a secure TCP tunnel and a public IP address. | ||
|
||
```bash | ||
[baz]aar install inlets-operator \ | ||
--access-token $HOME/digitalocean \ | ||
--region lon1 \ | ||
--license $(cat $HOME/license.txt) | ||
``` | ||
|
||
## Contributing | ||
|
||
### Suggesting a new app | ||
|
||
To suggest a new app, please check past issues and [raise an issue for it](https://github.com/alexellis/bazaar). | ||
|
||
### Improving the code or fixing an issue | ||
|
||
Before contributing code, please see the [CONTRIBUTING guide](https://github.com/alexellis/inlets/blob/master/CONTRIBUTING.md). Note that bazaar uses the same guide as [inlets.dev](https://inlets.dev/). | ||
|
||
Both Issues and PRs have their own templates. Please fill out the whole template. | ||
|
||
All commits must be signed-off as part of the [Developer Certificate of Origin (DCO)](https://developercertificate.org) | ||
|
||
### k3sup vs. bazaar | ||
|
||
The codebase in this project is derived from `k3sup`. k3sup (ketchup) was developed to automate building of k3s clusters over SSH, then gained the powerful feature to install apps in a single command. The presence of the word "k3s" in the name of the application confused many people, this is why bazaar has come to exist. | ||
|
||
### License | ||
|
||
MIT | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!/bin/sh | ||
|
||
for f in bin/bazaar*; do shasum -a 256 $f > $f.sha256; done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
package cmd | ||
|
||
import ( | ||
"fmt" | ||
"strings" | ||
|
||
"github.com/alexellis/bazaar/cmd/apps" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
func MakeInstall() *cobra.Command { | ||
var command = &cobra.Command{ | ||
Use: "install", | ||
Short: "Install Kubernetes apps from helm charts or YAML files", | ||
Long: `Install Kubernetes apps from helm charts or YAML files using the "install" | ||
command. Helm 2 is used by default unless a --helm3 flag exists and is passed. | ||
You can also find the post-install message for each app with the "info" | ||
command.`, | ||
Example: ` bazaar install | ||
bazaar install openfaas --helm3 --gateways=2 | ||
bazaar app info inlets-operator`, | ||
SilenceUsage: false, | ||
} | ||
|
||
var install = &cobra.Command{ | ||
Use: "install", | ||
Short: "Install a Kubernetes app", | ||
Example: ` bazaar install [APP] | ||
bazaar install openfaas --help | ||
bazaar install inlets-operator --token-file $HOME/do | ||
bazaar install --help`, | ||
SilenceUsage: true, | ||
} | ||
|
||
install.PersistentFlags().String("kubeconfig", "kubeconfig", "Local path for your kubeconfig file") | ||
|
||
install.RunE = func(command *cobra.Command, args []string) error { | ||
|
||
if len(args) == 0 { | ||
fmt.Printf("You can install: %s\n%s\n\n", strings.TrimRight("\n - "+strings.Join(getApps(), "\n - "), "\n - "), | ||
`Run bazaar install NAME --help to see configuration options.`) | ||
return nil | ||
} | ||
|
||
return nil | ||
} | ||
|
||
command.AddCommand(install) | ||
install.AddCommand(apps.MakeInstallOpenFaaS()) | ||
install.AddCommand(apps.MakeInstallMetricsServer()) | ||
install.AddCommand(apps.MakeInstallInletsOperator()) | ||
install.AddCommand(apps.MakeInstallCertManager()) | ||
install.AddCommand(apps.MakeInstallOpenFaaSIngress()) | ||
install.AddCommand(apps.MakeInstallNginx()) | ||
install.AddCommand(apps.MakeInstallChart()) | ||
install.AddCommand(apps.MakeInstallLinkerd()) | ||
install.AddCommand(apps.MakeInstallCronConnector()) | ||
install.AddCommand(apps.MakeInstallKafkaConnector()) | ||
install.AddCommand(apps.MakeInstallMinio()) | ||
install.AddCommand(apps.MakeInstallPostgresql()) | ||
install.AddCommand(apps.MakeInstallKubernetesDashboard()) | ||
install.AddCommand(apps.MakeInstallIstio()) | ||
install.AddCommand(apps.MakeInstallCrossplane()) | ||
install.AddCommand(apps.MakeInstallMongoDB()) | ||
install.AddCommand(apps.MakeInstallRegistry()) | ||
install.AddCommand(apps.MakeInstallRegistryIngress()) | ||
|
||
command.AddCommand(MakeInfo()) | ||
|
||
return command | ||
} | ||
|
||
func getApps() []string { | ||
return []string{"openfaas", | ||
"nginx-ingress", | ||
"cert-manager", | ||
"openfaas-ingress", | ||
"inlets-operator", | ||
"metrics-server", | ||
"chart", | ||
"tiller", | ||
"linkerd", | ||
"cron-connector", | ||
"kafka-connector", | ||
"minio", | ||
"postgresql", | ||
"kubernetes-dashboard", | ||
"istio", | ||
"crosspane", | ||
"mongodb", | ||
"docker-registry", | ||
"docker-registry-ingress", | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,156 @@ | ||
package apps | ||
|
||
import ( | ||
"fmt" | ||
"log" | ||
"os" | ||
"path" | ||
|
||
"github.com/alexellis/bazaar/pkg" | ||
"github.com/alexellis/bazaar/pkg/config" | ||
"github.com/alexellis/bazaar/pkg/env" | ||
"github.com/alexellis/bazaar/pkg/helm" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
func MakeInstallCertManager() *cobra.Command { | ||
var certManager = &cobra.Command{ | ||
Use: "cert-manager", | ||
Short: "Install cert-manager", | ||
Long: "Install cert-manager for obtaining TLS certificates from LetsEncrypt", | ||
Example: "bazaar install cert-manager", | ||
SilenceUsage: true, | ||
} | ||
|
||
certManager.Flags().StringP("namespace", "n", "cert-manager", "The namespace to install cert-manager") | ||
certManager.Flags().Bool("update-repo", true, "Update the helm repo") | ||
certManager.Flags().Bool("helm3", true, "Use helm3, if set to false uses helm2") | ||
|
||
certManager.RunE = func(command *cobra.Command, args []string) error { | ||
kubeConfigPath := getDefaultKubeconfig() | ||
|
||
if command.Flags().Changed("kubeconfig") { | ||
kubeConfigPath, _ = command.Flags().GetString("kubeconfig") | ||
} | ||
|
||
fmt.Printf("Using kubeconfig: %s\n", kubeConfigPath) | ||
helm3, _ := command.Flags().GetBool("helm3") | ||
|
||
if helm3 { | ||
fmt.Println("Using helm3") | ||
} | ||
namespace, _ := command.Flags().GetString("namespace") | ||
|
||
if namespace != "cert-manager" { | ||
return fmt.Errorf(`To override the "cert-manager" namespace, install cert-manager via helm manually`) | ||
} | ||
|
||
userPath, err := config.InitUserDir() | ||
if err != nil { | ||
return err | ||
} | ||
|
||
clientArch, clientOS := env.GetClientArch() | ||
|
||
fmt.Printf("Client: %s, %s\n", clientArch, clientOS) | ||
|
||
log.Printf("User dir established as: %s\n", userPath) | ||
|
||
os.Setenv("HELM_HOME", path.Join(userPath, ".helm")) | ||
|
||
_, err = helm.TryDownloadHelm(userPath, clientArch, clientOS, helm3) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
err = addHelmRepo("jetstack", "https://charts.jetstack.io", helm3) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
updateRepo, _ := certManager.Flags().GetBool("update-repo") | ||
|
||
if updateRepo { | ||
err = updateHelmRepos(helm3) | ||
if err != nil { | ||
return err | ||
} | ||
} | ||
|
||
nsRes, nsErr := kubectlTask("create", "namespace", namespace) | ||
if nsErr != nil { | ||
return nsErr | ||
} | ||
|
||
if nsRes.ExitCode != 0 { | ||
fmt.Printf("[Warning] unable to create namespace %s, may already exist: %s", namespace, nsRes.Stderr) | ||
} | ||
|
||
chartPath := path.Join(os.TempDir(), "charts") | ||
|
||
err = fetchChart(chartPath, "jetstack/cert-manager", helm3) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
log.Printf("Applying CRD\n") | ||
crdsURL := "https://raw.githubusercontent.com/jetstack/cert-manager/release-0.12/deploy/manifests/00-crds.yaml" | ||
res, err := kubectlTask("apply", "--validate=false", "-f", | ||
crdsURL) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
if res.ExitCode > 0 { | ||
return fmt.Errorf("error applying CRD from: %s, error: %s", crdsURL, res.Stderr) | ||
} | ||
|
||
outputPath := path.Join(chartPath, "cert-manager/rendered") | ||
overrides := map[string]string{} | ||
|
||
if helm3 { | ||
outputPath := path.Join(chartPath, "cert-manager") | ||
|
||
err := helm3Upgrade(outputPath, "jetstack/cert-manager", namespace, | ||
"values.yaml", | ||
"v0.12.0", | ||
overrides) | ||
|
||
if err != nil { | ||
return err | ||
} | ||
} else { | ||
err = templateChart(chartPath, "cert-manager", namespace, outputPath, "values.yaml", "v0.12.0", nil) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
applyRes, applyErr := kubectlTask("apply", "-R", "-f", outputPath) | ||
if applyErr != nil { | ||
return applyErr | ||
} | ||
|
||
if applyRes.ExitCode > 0 { | ||
return fmt.Errorf("error applying templated YAML files, error: %s", applyRes.Stderr) | ||
} | ||
} | ||
|
||
fmt.Println(certManagerInstallMsg) | ||
|
||
return nil | ||
} | ||
|
||
return certManager | ||
} | ||
|
||
const CertManagerInfoMsg = `# Get started with cert-manager here: | ||
# https://docs.cert-manager.io/en/latest/tutorials/acme/http-validation.html | ||
# Check cert-manager's logs with: | ||
kubectl logs -n cert-manager deploy/cert-manager -f` | ||
|
||
const certManagerInstallMsg = `======================================================================= | ||
= cert-manager has been installed. = | ||
=======================================================================` + | ||
"\n\n" + CertManagerInfoMsg + "\n\n" + pkg.ThanksForUsing |
Oops, something went wrong.