Skip to content

Commit

Permalink
Merge pull request #11 from kubefirst/unpin-gitlab
Browse files Browse the repository at this point in the history
Unpin gitlab
  • Loading branch information
johndietz authored Aug 17, 2021
2 parents 02f6be8 + fbf8a1e commit 17607a2
Show file tree
Hide file tree
Showing 9 changed files with 66 additions and 32 deletions.
36 changes: 36 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,39 @@ The Kubefirst Open Source Starter Plan repository
- [getting familar](https://docs.kubefirst.com/starter/getting-familiar/)
- [teardown](https://docs.kubefirst.com/starter/teardown/)
- [faq](https://docs.kubefirst.com/starter/faq/)

---

# contributor guide

The docs above are tailored to our end user experience. However things are a little different if you're contributing the nebulous itself. If you're **contributing** to nebulous, the docs below are for you.

### step 1 - setup nebulous.env

This step is actually no different than the guidance to our end users, you need to set up a `kubefirst.env` in the nebulous repo's root directory. You can create the file template by running this from your terminal, editing with your values for these 5 settings.

```
cat << EOF > kubefirst.env
AWS_ACCESS_KEY_ID=YOUR_ADMIN_AWS_ACCESS_KEY_ID
AWS_SECRET_ACCESS_KEY=YOUR_ADMIN_AWS_SECRET_ACCESS_KEY
AWS_HOSTED_ZONE_ID=YOUR_AWS_HOSTED_ZONE_ID
AWS_DEFAULT_REGION=YOUR_AWS_REGION
EMAIL_ADDRESS=YOUR_EMAIL_ADDRESS
EOF
```

### step 2 - build nebulous locally

Come up with local tag name for your nebulous image. We'll use `foo` as our example local tag name in these docs. To build the `foo` tag of nebulous run the following from your local nebulous repo root directory.

```bash
nebulous docker build . -t nebulous:foo
```

### step 3 - running nebulous

Once you have built the `nebulous:foo` image as shown above, you can kickoff the automated init script by running

```
nebulous docker run --env-file=kubefirst.env -v $PWD/terraform:/terraform --entrypoint /scripts/nebulous/init.sh nebulous:foo
```
1 change: 1 addition & 0 deletions scripts/nebulous/init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ export TF_VAR_gitlab_url=$GITLAB_URL
export TF_VAR_email_domain=$EMAIL_DOMAIN
export TF_VAR_region=$AWS_DEFAULT_REGION
export TF_VAR_iam_user_arn=$IAM_USER_ARN
export TF_VAR_gitlab_bot_root_password=$GITLAB_BOT_ROOT_PASSWORD

HZ_LIVENESS_FAIL_COUNT=0
HZ_IS_LIVE=0
Expand Down
3 changes: 1 addition & 2 deletions terraform/cypress/cypress.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
"env": {
"gitlab_bot_username_before": "root",
"gitlab_bot_username_before000": "gitlab-bot"
"gitlab_bot_username_before": "root"
}
}
25 changes: 5 additions & 20 deletions terraform/cypress/cypress/integration/gitlab-init.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,6 @@ context('Window', () => {
before(() => {
cy.visit('/')
})
it('establishes the root password', () => {
cy.get('#user_password').type(Cypress.env('gitlab_bot_password'))
cy.get('#user_password_confirmation')
.type(Cypress.env('gitlab_bot_password')).type('{enter}')
})

it('logs in with root user', () => {
cy.get('#user_login')
Expand All @@ -19,12 +14,12 @@ context('Window', () => {
})

it('sets up a personal access token', () => {
cy.visit('/profile/personal_access_tokens')
cy.visit('/-/profile/personal_access_tokens')
cy.get('#personal_access_token_name').type('kubefirst')
cy.get('#personal_access_token_scopes_api').check()
cy.get('#personal_access_token_scopes_write_repository').check()
cy.get('#personal_access_token_scopes_write_registry').check()
cy.get('.gl-mt-3 > .btn').click()
cy.get('#new_personal_access_token > .gl-mt-3 > .gl-button').click()
cy.get('#created-personal-access-token').then(elem => {
// elem is the underlying Javascript object targeted by the .get() command.
const token = Cypress.$(elem).val();
Expand All @@ -34,22 +29,12 @@ context('Window', () => {

it('gets the runner registration token', () => {
cy.visit('/admin/runners')
cy.get('#registration_token').then(elem => {
cy.get('[data-testid=eye-icon] > use').click()
cy.get('[data-testid=registration-token] > span').then(elem => {
// elem is the underlying Javascript object targeted by the .get() command.
const token = Cypress.$(elem).text();
cy.writeFile('../.gitlab-runner-registration-token', token)
cy.writeFile('../.gitlab-runner-registration-token', token.trim())
})
})

// existing user for testing an established gitlab
it.skip('logs in with root user', () => {
cy.get('#user_login')
.clear().type(Cypress.env('gitlab_bot_username_before'))
cy.get('#user_password')
.clear().type(Cypress.env('gitlab_bot_password'))
cy.get('.gl-button')
.click()
cy.contains('Projects')
})

})
5 changes: 3 additions & 2 deletions terraform/ec2/gitlab-vm.tf
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,9 @@ data "aws_ami_ids" "ubuntu" {
data "template_file" "gitlab_install_script" {
template = file("${path.module}/scripts/install_gitlab.sh")
vars = {
EMAIL_DOMAIN = var.email_domain
GITLAB_URL = var.gitlab_url
EMAIL_DOMAIN = var.email_domain
GITLAB_URL = var.gitlab_url
GITLAB_BOT_ROOT_PASSWORD = var.gitlab_bot_root_password
}
}

Expand Down
2 changes: 1 addition & 1 deletion terraform/ec2/scripts/install_gitlab.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ sudo apt-get install --assume-yes postfix
curl https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.deb.sh | sudo bash

sudo EXTERNAL_URL="https://${GITLAB_URL}" apt-get install gitlab-ce=13.12.9-ce.0
sudo EXTERNAL_URL="https://${GITLAB_URL}" GITLAB_ROOT_PASSWORD="${GITLAB_BOT_ROOT_PASSWORD}" apt-get install gitlab-ce
5 changes: 5 additions & 0 deletions terraform/ec2/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,18 @@ variable "region" {
type = string
}

variable "gitlab_bot_root_password" {
type = string
}

variable "gitlab_url" {
type = string
}

variable "email_domain" {
type = string
}

variable "hosted_zone_id" {
type = string
}
15 changes: 8 additions & 7 deletions terraform/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,14 @@ data "aws_route53_zone" "hosted_zone" {
module "ec2" {
source = "./ec2"

region = var.region
vpc_default_sg_id = module.eks.preprod_vpc_default_sg
vpc_public_subnet = module.eks.preprod_vpc_public_subnets[0]
gitlab_sg_id = module.security-groups.gitlab_sg_id
gitlab_url = var.gitlab_url
hosted_zone_id = data.aws_route53_zone.hosted_zone.zone_id
email_domain = var.email_domain
region = var.region
vpc_default_sg_id = module.eks.preprod_vpc_default_sg
vpc_public_subnet = module.eks.preprod_vpc_public_subnets[0]
gitlab_sg_id = module.security-groups.gitlab_sg_id
gitlab_url = var.gitlab_url
gitlab_bot_root_password = var.gitlab_bot_root_password
hosted_zone_id = data.aws_route53_zone.hosted_zone.zone_id
email_domain = var.email_domain
}

module "security-groups" {
Expand Down
6 changes: 6 additions & 0 deletions terraform/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,15 @@ variable "region" {
variable "aws_account_id" {
type = string
}

variable "gitlab_url" {
type = string
}

variable "gitlab_bot_root_password" {
type = string
}

variable "hosted_zone_name" {
type = string
}
Expand Down

0 comments on commit 17607a2

Please sign in to comment.