Skip to content

Commit

Permalink
Merge pull request #132 from invidian/release-0.3.0
Browse files Browse the repository at this point in the history
Release v0.3.0
  • Loading branch information
invidian authored May 24, 2020
2 parents f900fab + 79965a5 commit e3d5042
Show file tree
Hide file tree
Showing 4 changed files with 175 additions and 82 deletions.
36 changes: 34 additions & 2 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
builds:
- env:
- id: terraform-provider-flexkube
env:
- CGO_ENABLED=0
ldflags:
- -extldflags '-static'
Expand All @@ -14,8 +15,24 @@ builds:
- darwin
main: ./cmd/terraform-provider-flexkube
binary: terraform-provider-flexkube_{{.Tag}}_x4
- id: flexkube
env:
- CGO_ENABLED=0
ldflags:
- -extldflags '-static'
- -s
- -w
flags:
- -buildmode=exe
goarch:
- amd64
goos:
- linux
- darwin
main: ./cmd/flexkube
binary: flexkube

project_name: terraform-provider-flexkube
project_name: flexkube

changelog:
skip: true
Expand All @@ -27,5 +44,20 @@ release:
owner: flexkube
name: libflexkube

# Only add binaries to the archive files.
archives:
- id: terraform-provider-flexkube
builds:
- terraform-provider-flexkube
name_template: "terraform-provider-flexkube_v{{ .Version }}_{{ .Os }}_{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}{{ if .Mips }}_{{ .Mips }}{{ end }}"
files:
- none*
- id: flexkube
builds:
- flexkube
name_template: "{{ .Binary }}_v{{ .Version }}_{{ .Os }}_{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}{{ if .Mips }}_{{ .Mips }}{{ end }}"
files:
- none*

signs:
- artifacts: all
33 changes: 33 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,39 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.3.0] - 2020-05-24

### Added

- Added new `flexkube` CLI binary, which allows to manage multiple resources with the same configuration file. It replaces old `etcd-cluster`, `controlplane`, `api-loadbalancers`, `kubelet-pool` and `pki-generator` binaries.
- Added `PKI` resource, which allows generating all certificates required for cluster using Go API, as Terraform `flexkube_pki` resource or using `flexkube pki` command. This replaces [terraform-root-pki](https://github.com/flexkube/terraform-root-pki), [terraform-etcd-pki](https://github.com/flexkube/terraform-etcd-pki) and [terraform-kubernetes-pki](https://github.com/flexkube/terraform-kubernetes-pki) Terraform modules.
- Controlplane, etcd and kubelet-pool resources have now PKI resource integration with extra PKI field, so certificates no longer need to be generated externally and provided in configuration. This should simplify the use of CLI tools and Go API.
- SSH transport method now automatically integrates with `ssh-agent` if `SSH_AUTH_SOCK` environment variable is set. This allows using this transport method without any credentials configured.

### Fixed

- Constant diff in `containers-runner` and `flexkube_containers` resources caused by wrong JSON struct tags.
- When removing containers in `restarting` state, they will also be stopped before removing. Before, restarting containers requires manual stop to be removed.
- Bunch of typos.

### Changed

- Improved error messages when resource has no instances configured.
- Updated all dependencies to latest versions to fix installing using `go get`.
- Updated `sonobuoy` to `0.18.1`.
- State files are now created with `0600` permissions.
- Updated `golangci-lint` to `1.27.0`.
- Kubelet now use structured configuration instead of kubeconfig-like string field for bootstrap and administrator kubeconfig fields.
- `e2e` testing environment now use new PKI resource.
- Terraform provider unit tests no longer requires `tls` provider and all run in parallel, so they should be a bit faster to execute.
- Updated default `etcd` version to `3.4.9`.
- `VolumePluginDir` and `NetworkPlugin` fields now use default values for Kubelet and Controlplane resources, to minimize the default configuration required from the user.
- Release binaries now ship with stripped debug symbols, which makes them smaller.

### Removed

- Removed `etcd-cluster`, `controlplane`, `api-loadbalancers`, `kubelet-pool` and `pki-generator` binaries, replaced by `flexkube`.

## [0.2.2] - 2020-04-19

### Added
Expand Down
175 changes: 108 additions & 67 deletions cli/flexkube/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,42 +6,23 @@ import (
"github.com/urfave/cli/v2"
)

const (
// Version is a version printed by the --version flag.
Version = "v0.3.0"
)

// Run executes flexkube CLI binary with given arguments (usually os.Args).
func Run(args []string) int {
app := &cli.App{
Name: "flexkube",
Version: Version,
Commands: []*cli.Command{
{
Name: "kubelet-pool",
Usage: "executes kubelet pool configuration",
ArgsUsage: "[POOL NAME]",
Action: withResource(kubeletPoolAction),
},
{
Name: "apiloadbalancer-pool",
Usage: "executes API Load Balancer pool configuration",
ArgsUsage: "[POOL NAME]",
Action: withResource(apiLoadBalancerPoolAction),
},
{
Name: "etcd",
Usage: "execute etcd configuration",
Action: withResource(etcdAction),
},
{
Name: "pki",
Usage: "execute PKI configuration",
Action: withResource(pkiAction),
},
{
Name: "controlplane",
Usage: "execute controlplane configuration",
Action: withResource(controlplaneAction),
},
{
Name: "kubeconfig",
Usage: "prints admin kubeconfig for cluster",
Action: withResource(kubeconfigAction),
},
kubeletPoolCommand(),
apiLoadBalancerPoolCommand(),
etcdCommand(),
pkiCommand(),
controlplaneCommand(),
kubeconfigCommand(),
},
}

Expand All @@ -55,60 +36,110 @@ func Run(args []string) int {
return 0
}

// apiLoadBalancerPoolAction implements 'apiloadbalancer-pool' subcommand.
func apiLoadBalancerPoolAction(r *Resource) func(*cli.Context) error {
return func(c *cli.Context) error {
poolName, err := getPoolName(c)
if err != nil {
return err
}

return r.RunAPILoadBalancerPool(poolName)
func kubeletPoolCommand() *cli.Command {
return &cli.Command{
Name: "kubelet-pool",
Usage: "executes kubelet pool configuration",
ArgsUsage: "[POOL NAME]",
Action: func(c *cli.Context) error {
return withResource(c, kubeletPoolAction)
},
}
}

// controlplaneAction implements 'controlplane' subcommand.
func controlplaneAction(r *Resource) func(*cli.Context) error {
return func(c *cli.Context) error {
return r.RunControlplane()
func apiLoadBalancerPoolCommand() *cli.Command {
return &cli.Command{
Name: "apiloadbalancer-pool",
Usage: "executes API Load Balancer pool configuration",
ArgsUsage: "[POOL NAME]",
Action: func(c *cli.Context) error {
return withResource(c, apiLoadBalancerPoolAction)
},
}
}

// etcdAction implements 'etcd' subcommand.
func etcdAction(r *Resource) func(*cli.Context) error {
return func(c *cli.Context) error {
return r.RunEtcd()
func etcdCommand() *cli.Command {
return &cli.Command{
Name: "etcd",
Usage: "execute etcd configuration",
Action: func(c *cli.Context) error {
return withResource(c, etcdAction)
},
}
}

func kubeconfigAction(r *Resource) func(*cli.Context) error {
return func(c *cli.Context) error {
k, err := r.Kubeconfig()
if err != nil {
return fmt.Errorf("failed generating kubeconfig: %w", err)
}
func pkiCommand() *cli.Command {
return &cli.Command{
Name: "pki",
Usage: "execute PKI configuration",
Action: func(c *cli.Context) error {
return withResource(c, pkiAction)
},
}
}

fmt.Println(k)
func controlplaneCommand() *cli.Command {
return &cli.Command{
Name: "controlplane",
Usage: "execute controlplane configuration",
Action: func(c *cli.Context) error {
return withResource(c, controlplaneAction)
},
}
}

return nil
func kubeconfigCommand() *cli.Command {
return &cli.Command{
Name: "kubeconfig",
Usage: "prints admin kubeconfig for cluster",
Action: func(c *cli.Context) error {
return withResource(c, kubeconfigAction)
},
}
}

// apiLoadBalancerPoolAction implements 'apiloadbalancer-pool' subcommand.
func apiLoadBalancerPoolAction(c *cli.Context, r *Resource) error {
poolName, err := getPoolName(c)
if err != nil {
return err
}

return r.RunAPILoadBalancerPool(poolName)
}

// controlplaneAction implements 'controlplane' subcommand.
func controlplaneAction(c *cli.Context, r *Resource) error {
return r.RunControlplane()
}

func kubeletPoolAction(r *Resource) func(*cli.Context) error {
return func(c *cli.Context) error {
poolName, err := getPoolName(c)
if err != nil {
return err
}
// etcdAction implements 'etcd' subcommand.
func etcdAction(c *cli.Context, r *Resource) error {
return r.RunEtcd()
}

return r.RunKubeletPool(poolName)
func kubeconfigAction(c *cli.Context, r *Resource) error {
k, err := r.Kubeconfig()
if err != nil {
return fmt.Errorf("failed generating kubeconfig: %w", err)
}

fmt.Println(k)

return nil
}

func pkiAction(r *Resource) func(*cli.Context) error {
return func(c *cli.Context) error {
return r.RunPKI()
func kubeletPoolAction(c *cli.Context, r *Resource) error {
poolName, err := getPoolName(c)
if err != nil {
return err
}

return r.RunKubeletPool(poolName)
}

func pkiAction(c *cli.Context, r *Resource) error {
return r.RunPKI()
}

func getPoolName(c *cli.Context) (string, error) {
Expand All @@ -123,3 +154,13 @@ func getPoolName(c *cli.Context) (string, error) {

return poolName, nil
}

// withResource is a helper for action functions.
func withResource(c *cli.Context, rf func(*cli.Context, *Resource) error) error {
r, err := LoadResourceFromFiles()
if err != nil {
return fmt.Errorf("reading configuration and state failed: %w", err)
}

return rf(c, r)
}
13 changes: 0 additions & 13 deletions cli/flexkube/resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"fmt"
"io/ioutil"

"github.com/urfave/cli/v2"
"sigs.k8s.io/yaml"

flexcli "github.com/flexkube/libflexkube/cli"
Expand Down Expand Up @@ -295,18 +294,6 @@ func (r *Resource) Kubeconfig() (string, error) {
return k, nil
}

// withResource is a helper for action functions.
func withResource(f func(*Resource) func(c *cli.Context) error) func(c *cli.Context) error {
r, err := LoadResourceFromFiles()
if err != nil {
return func(c *cli.Context) error {
return fmt.Errorf("reading configuration and state failed: %w", err)
}
}

return f(r)
}

// RunAPILoadBalancerPool deploys given API Load Balancer pool.
func (r *Resource) RunAPILoadBalancerPool(name string) error {
p, err := r.getAPILoadBalancerPool(name)
Expand Down

0 comments on commit e3d5042

Please sign in to comment.