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

[WIP]create deployments commands #455

Merged
merged 78 commits into from
Nov 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
78 commits
Select commit Hold shift + click to select a range
9126421
create deployments commands
zreigz Sep 26, 2023
c997481
add repositories commands
zreigz Sep 26, 2023
d646408
update client auth
maciaszczykm Sep 26, 2023
c067440
add deployments repositories create command
maciaszczykm Sep 26, 2023
5fe3abc
add deployments repositories list command
maciaszczykm Sep 26, 2023
60ebff6
refactor
maciaszczykm Sep 26, 2023
e594ca3
bump go client
zreigz Sep 26, 2023
93c676a
fix list deployments
zreigz Sep 26, 2023
8177ef4
use go client model
zreigz Sep 27, 2023
78ff8cd
create and update service deployment
zreigz Sep 27, 2023
d3cb5da
Small style tweaks and show repository health in `repositories list` …
michaeljguarino Sep 27, 2023
7dec831
describe service
zreigz Sep 28, 2023
2735aff
install agent helm method
zreigz Sep 28, 2023
5012e3a
create agent namespace
zreigz Sep 28, 2023
8940f4c
enable CAPI feature flag for e2e
zreigz Sep 28, 2023
f36610a
add services delete command
floreks Sep 28, 2023
a3dba51
Extend clusters list display (#460)
michaeljguarino Sep 29, 2023
00aaece
describe cluster + code refacor
zreigz Sep 29, 2023
3267680
add flag validation
zreigz Oct 2, 2023
77a7e5b
support handle for plural deployments services list/describe
zreigz Oct 3, 2023
ec148f3
add required flags
zreigz Oct 3, 2023
a1b32b7
add handle for create CD service
zreigz Oct 4, 2023
bcdfd14
add wait flag for agent installation
zreigz Oct 4, 2023
e0d5a59
update services by handle
zreigz Oct 4, 2023
39bc93f
add console client mocks
zreigz Oct 9, 2023
4bfb8b7
improve describe cluster and service
zreigz Oct 10, 2023
00ebe42
read kubeconfig from env var if present
michaeljguarino Oct 11, 2023
3413453
respect KUBECONFIG env var in plural kube client too
michaeljguarino Oct 11, 2023
a581756
force update helm repos on install to prevent stale chart installations
michaeljguarino Oct 11, 2023
10908cf
use correct release name
michaeljguarino Oct 11, 2023
ec8a8ca
don't swallow helm errors
michaeljguarino Oct 11, 2023
9925c52
extend update cluster for kubeconfig
zreigz Oct 12, 2023
535eb3c
add plural cd providers list command
zreigz Oct 12, 2023
8a3f19b
create/delete provider credentials
zreigz Oct 13, 2023
ec7fc5e
pipeline create command
michaeljguarino Oct 23, 2023
83f9c72
fix some repositories commands
michaeljguarino Oct 24, 2023
7cb22f6
add deployments clusters get-credentials command (#467)
maciaszczykm Oct 28, 2023
4e37801
Add a persistent config file for console logins on cli
michaeljguarino Oct 29, 2023
15ab2f7
Implement `plural cd clusters delete` (#468)
michaeljguarino Oct 30, 2023
e1cab58
fix pointer bug on config updates
michaeljguarino Oct 30, 2023
39f29fa
add create cluster command
zreigz Oct 31, 2023
52a093d
create azure cluster
zreigz Oct 31, 2023
2e1b265
fix after schema changes
zreigz Oct 31, 2023
8cc289e
bump console client
zreigz Oct 31, 2023
97b6d06
bump console client
maciaszczykm Oct 31, 2023
144b323
Merge remote-tracking branch 'origin/deployments' into deployments
maciaszczykm Oct 31, 2023
7359c2d
update arg name
maciaszczykm Oct 31, 2023
158b826
refactor cluster commands
maciaszczykm Oct 31, 2023
64d9c91
refactor provider command
maciaszczykm Oct 31, 2023
8beee63
remove provider id param
maciaszczykm Oct 31, 2023
0375802
don't wait in cd install command
michaeljguarino Oct 31, 2023
1636135
add clusters bootstrap command
michaeljguarino Nov 1, 2023
7e1925d
add operator uninstall, cluster tags on bootstrap
michaeljguarino Nov 1, 2023
c680b7c
more tweaks to agent installer
michaeljguarino Nov 2, 2023
51189f3
some more agent install tweaks
michaeljguarino Nov 2, 2023
55df72a
update gcp provider
zreigz Nov 2, 2023
6346146
update provider create
maciaszczykm Nov 2, 2023
47149e5
fix profile list cmd
maciaszczykm Nov 3, 2023
6189d80
filter out existing providers
zreigz Nov 3, 2023
2147209
remove gcp credenitials b64 encode logic
floreks Nov 3, 2023
fc6df10
BYOK installer for plural console
michaeljguarino Nov 5, 2023
0759497
wrap up console installer
michaeljguarino Nov 5, 2023
a85ec3d
fix linter
zreigz Nov 6, 2023
d063d2e
refactor cd structure
zreigz Nov 6, 2023
695aaaf
fix unit tests
zreigz Nov 6, 2023
958e8bc
Merge remote-tracking branch 'origin/main' into deployments
maciaszczykm Nov 6, 2023
88a852e
fix cd install command
zreigz Nov 7, 2023
c6728f3
add kustomize support
zreigz Nov 7, 2023
03d6c31
init eject command
floreks Nov 8, 2023
7f35ae6
Merge branch 'deployments' of github.com:pluralsh/plural-cli into dep…
floreks Nov 8, 2023
486f122
fix token name for cd install
zreigz Nov 8, 2023
a97fc58
make cd clusters kubeconfig more robust
michaeljguarino Nov 9, 2023
fbcf43e
add kas_dns to server context
maciaszczykm Nov 10, 2023
dcc779c
Merge remote-tracking branch 'origin/deployments' into deployments
maciaszczykm Nov 10, 2023
a4127f3
add eject command and fix gcp capi provider bootstrapping
floreks Nov 10, 2023
1946b75
Merge branch 'deployments' of github.com:pluralsh/plural-cli into dep…
floreks Nov 10, 2023
80bbcb3
modify control plane installer
michaeljguarino Nov 11, 2023
3320674
add service clone support
michaeljguarino Nov 11, 2023
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
154 changes: 154 additions & 0 deletions cmd/plural/cd.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
package plural

import (
"fmt"
"os"

"github.com/urfave/cli"
apierrors "k8s.io/apimachinery/pkg/api/errors"

"github.com/pluralsh/plural/pkg/cd"
"github.com/pluralsh/plural/pkg/config"
"github.com/pluralsh/plural/pkg/console"
"github.com/pluralsh/plural/pkg/utils"
)

func init() {
consoleToken = ""
consoleURL = ""
}

const (
operatorNamespace = "plrl-deploy-operator"
)

var consoleToken string
var consoleURL string

func (p *Plural) cdCommands() []cli.Command {
return []cli.Command{
p.cdProviders(),
p.cdCredentials(),
p.cdClusters(),
p.cdServices(),
p.cdRepositories(),
p.cdPipelines(),
{
Name: "install",
Action: p.handleInstallDeploymentsOperator,
Usage: "install deployments operator",
Flags: []cli.Flag{
cli.StringFlag{Name: "url", Usage: "console url", Required: true},
cli.StringFlag{Name: "token", Usage: "deployment token", Required: true},
},
},
{
Name: "control-plane",
Action: p.handleInstallControlPlane,
Usage: "sets up the plural console in an existing k8s cluster",
},
{
Name: "uninstall",
Action: p.handleUninstallOperator,
Usage: "uninstalls the deployment operator from the current cluster",
},
{
Name: "login",
Action: p.handleCdLogin,
Usage: "logs into your plural console",
Flags: []cli.Flag{
cli.StringFlag{Name: "url", Usage: "console url", Required: true},
cli.StringFlag{Name: "token", Usage: "console access token"},
},
},
{
Name: "eject",

Check failure on line 65 in cmd/plural/cd.go

View workflow job for this annotation

GitHub Actions / Lint

File is not `gofmt`-ed with `-s` (gofmt)
Action: p.handleEject,
Usage: "ejects cluster scaffolds",
ArgsUsage: "<cluster-id>",
// TODO: enable once logic is finished
Hidden: true,
},
}
}

func (p *Plural) handleInstallDeploymentsOperator(c *cli.Context) error {
return p.doInstallOperator(c.String("url"), c.String("token"))
}

func (p *Plural) handleUninstallOperator(_ *cli.Context) error {
err := p.InitKube()
if err != nil {
return err
}
return console.UninstallAgent(operatorNamespace)
}

func (p *Plural) doInstallOperator(url, token string) error {
err := p.InitKube()
if err != nil {
return err
}
err = p.Kube.CreateNamespace(operatorNamespace)
if err != nil && !apierrors.IsAlreadyExists(err) {
return err
}
err = console.InstallAgent(url, token, operatorNamespace)
if err == nil {
utils.Success("deployment operator installed successfully\n")
}
return err
}

func (p *Plural) handleCdLogin(c *cli.Context) (err error) {
url := c.String("url")
token := c.String("token")
if token == "" {
token, err = utils.ReadPwd("Enter your console access token")
if err != nil {
return
}
}
conf := console.Config{Url: url, Token: token}
return conf.Save()
}

func (p *Plural) handleInstallControlPlane(_ *cli.Context) error {
conf := config.Read()
vals, err := cd.CreateControlPlane(conf)
if err != nil {
return err
}

fmt.Print("\n\n")
utils.Highlight("===> writing values.secret.yaml, you should keep this in a secure location for future helm upgrades\n\n")
if err := os.WriteFile("values.secret.yaml", []byte(vals), 0644); err != nil {
return err
}

fmt.Println("After confirming everything looks correct in values.secret.yaml, run the following command to install:")
utils.Highlight("helm upgrade --install --create-namespace -f values.secret.yaml --repo https://pluralsh.github.io/console console console -n plrl-console")
return nil
}

func (p *Plural) handleEject(c *cli.Context) (err error) {
if !c.Args().Present() {
return fmt.Errorf("clusterid cannot be empty")
}

if err := p.InitConsoleClient(consoleToken, consoleURL); err != nil {
return err
}

clusterId := c.Args().First()
cluster, err := p.ConsoleClient.GetCluster(&clusterId, nil)
if err != nil {
return err
}

if cluster == nil {
return fmt.Errorf("could not find cluster with given id")
}

return cd.Eject(cluster)
}
Loading
Loading