-
Notifications
You must be signed in to change notification settings - Fork 145
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' of github.com:kubefirst/kubefirst
- Loading branch information
Showing
13 changed files
with
205 additions
and
144 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 |
---|---|---|
|
@@ -7,26 +7,45 @@ | |
Kubefirst CLI is a cloud provisioning tool. With simple setup and few CLI calls, we spin up a full AWS cluster with full | ||
GitOps integration, secrets management, production and development Kubernetes environments ready to be consumed. | ||
|
||
- [Setup](#setup) | ||
- [Environment Variables](#environment-variables) | ||
- [DNS setup](#dns-setup) | ||
- [Start the container](#start-the-container) | ||
- [Initialization](#initialization) | ||
- [Creation](#creation) | ||
- [Access ArgoCD](#access-argocd) | ||
- [Destroy](#destroy) | ||
- [Available Commands]() | ||
- [Available Commands](#available-commands) | ||
|
||
![kubefirst architecture diagram](/images/kubefirst-arch.png) | ||
|
||
## Setup | ||
## Environment Variables | ||
|
||
The setup is extremely simple, create a `.env` file in the root folder, and add the following variables: | ||
|
||
| Variable | example | | ||
|--------------------|------------------| | ||
| AWS_PROFILE | default | | ||
| CLOUD_PROVIDER=aws | aws | | ||
| HOSTED_ZONE_NAME | example.com | | ||
| ADMIN_EMAIL | [email protected] | | ||
| Variable | example | | ||
|-------------|--------------| | ||
| AWS_PROFILE | default | | ||
| AWS_REGION | eu-central-1 | | ||
|
||
## DNS Setup | ||
|
||
In order to install Kubefirst it's required to have a public domain. For root domains, setting the `--hosted-zone-name` | ||
is enough, in case you want to use subdomains, and the domain is hosted on AWS, please follow the | ||
[AWS documentation](https://aws.amazon.com/premiumsupport/knowledge-center/create-subdomain-route-53/). | ||
|
||
Provisioned services on root domain will be hosted as: | ||
``` | ||
argocd.example.com | ||
gitlab.example.com | ||
... | ||
``` | ||
|
||
Provisioned services on subdomains will be hosted as: | ||
``` | ||
argocd.subdomain.example.com | ||
gitlab.subdomain.example.com | ||
... | ||
``` | ||
|
||
## Start the container | ||
|
||
|
@@ -41,8 +60,12 @@ docker-compose up kubefirst-dev | |
Some process requires previous initialization, for that, run: | ||
|
||
```bash | ||
mkdir -p ~/.kubefirst | ||
go run . init --admin-email $ADMIN_EMAIL --cloud $CLOUD_PROVIDER --hosted-zone-name $HOSTED_ZONE_NAME --region $AWS_REGION | ||
go run . init \ | ||
--cloud aws \ | ||
--region eu-central-1 \ | ||
--admin-email [email protected] \ | ||
--cluster-name your_cluster_name \ | ||
--hosted-zone-name domain.example | ||
``` | ||
|
||
## Creation | ||
|
@@ -66,26 +89,23 @@ kubectl -n argocd port-forward svc/argocd-server 8080:80 | |
It will destroy the kubefirst management cluster, and clean up every change made in the cloud. | ||
|
||
```bash | ||
|
||
go run . destroy | ||
rm -rf ~/.kubefirst | ||
rm ~/.flare | ||
``` | ||
|
||
## Available Commands | ||
|
||
Kubefirst provides extra tooling for handling the provisioning work. | ||
|
||
| Command | Description | | ||
|:------------|:-----------------------------------------------------------| | ||
| Command | Description | | ||
|:---------------|:----------------------------------------------------------| | ||
| argocdSync | Request ArgoCD to synchronize applications | | ||
| checktools | use to check compatibility of .kubefirst/tools | | ||
| clean | removes all kubefirst resources locally for new execution | | ||
| cluster create | create a kubefirst management cluster | | ||
| destroy | destroy the kubefirst management cluster | | ||
| info | provides general Kubefirst setup data | | ||
| init | initialize your local machine to execute `create` | | ||
| version | print the version number for kubefirst-cli" | | ||
| destroy | destroy the kubefirst management cluster | | ||
| info | provides general Kubefirst setup data | | ||
| init | initialize your local machine to execute `create` | | ||
| version | print the version number for kubefirst-cli" | | ||
|
||
--- | ||
## The provisioning process | ||
|
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
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,81 @@ | ||
package cmd | ||
|
||
import ( | ||
"fmt" | ||
"github.com/kubefirst/kubefirst/configs" | ||
"github.com/kubefirst/kubefirst/internal/aws" | ||
"github.com/kubefirst/kubefirst/internal/reports" | ||
"github.com/spf13/cobra" | ||
"log" | ||
"os" | ||
) | ||
|
||
var k1state = &cobra.Command{ | ||
Use: "state", | ||
Short: "push and pull Kubefirst configuration to S3 bucket", | ||
Long: `Kubefirst configuration can be handed over to another user by pushing the Kubefirst config files to a S3 bucket.`, | ||
Run: func(cmd *cobra.Command, args []string) { | ||
|
||
push, err := cmd.Flags().GetBool("push") | ||
if err != nil { | ||
log.Println(err) | ||
} | ||
pull, err := cmd.Flags().GetBool("pull") | ||
if err != nil { | ||
log.Println(err) | ||
} | ||
|
||
bucketName, err := cmd.Flags().GetString("bucket-name") | ||
if err != nil { | ||
log.Println(err) | ||
} | ||
|
||
if !push && !pull { | ||
fmt.Println(cmd.Help()) | ||
return | ||
} | ||
|
||
config := configs.ReadConfig() | ||
if push { | ||
err = aws.UploadFile(bucketName, config.KubefirstConfigFileName, config.KubefirstConfigFilePath) | ||
if err != nil { | ||
fmt.Println(err) | ||
return | ||
} | ||
finalMsg := fmt.Sprintf("Kubefirst configuration file was upload to AWS S3 at %q bucket name", bucketName) | ||
|
||
log.Printf(finalMsg) | ||
fmt.Println(reports.StyleMessage(finalMsg)) | ||
} | ||
|
||
if pull { | ||
err := aws.DownloadS3File(bucketName, config.KubefirstConfigFileName) | ||
if err != nil { | ||
fmt.Println(err) | ||
return | ||
} | ||
currentFolder, err := os.Getwd() | ||
finalMsg := fmt.Sprintf("Kubefirst configuration file was downloaded to %q/, and is now available to be copied to %q/", | ||
currentFolder, | ||
config.K1FolderPath, | ||
) | ||
|
||
log.Printf(finalMsg) | ||
fmt.Println(reports.StyleMessage(finalMsg)) | ||
} | ||
}, | ||
} | ||
|
||
func init() { | ||
rootCmd.AddCommand(k1state) | ||
|
||
k1state.Flags().Bool("push", false, "push Kubefirst config file to the S3 bucket") | ||
k1state.Flags().Bool("pull", false, "pull Kubefirst config file to the S3 bucket") | ||
k1state.Flags().String("bucket-name", "", "set the bucket name to store the Kubefirst config file") | ||
err := k1state.MarkFlagRequired("bucket-name") | ||
if err != nil { | ||
log.Println(err) | ||
return | ||
} | ||
|
||
} |
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
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
Oops, something went wrong.