Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
35 changes: 18 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@

1. Install package `composer require shopsys/deployment`

2. Copy [deploy-project.sh](./docs/deploy-project.sh) into your project to `deploy/deploy-project.sh`
2. Copy [deploy-project.sh](https://github.com/shopsys/project-base/blob/HEAD/app/deploy/deploy-project.sh) into your project to `app/deploy/deploy-project.sh`

3. Create or [copy](./docs/basicHttpAuth) htpasswd file with login credentials to `deploy/basicHttpAuth`
3. Create or [copy](https://github.com/shopsys/project-base/blob/HEAD/app/deploy/basicHttpAuth) htpasswd file with login credentials to `app/deploy/basicHttpAuth`
> Default login for basicHttpAuth is `username/password`
For info about how change http auth credentials see [Change HTTP auth](#change-http-auth)

4. Update your `gitlab-ci.yml`
4. Copy [nginx.yaml](https://github.com/shopsys/project-base/blob/HEAD/app/orchestration/kubernetes/configmap/nginx.yaml) into your project to `app/orchestration/kubernetes/configmap/nginx.yaml`
5. Update your `gitlab-ci.yml`
- create new stage with name deploy:
```diff
stages:
Expand Down Expand Up @@ -77,9 +78,9 @@
url: https://${DOMAIN_HOSTNAME_1}
```

5. Set Environment variables to in Gitlab (Settings -> CI/CD -> Variables)
6. Set Environment variables to in Gitlab (Settings -> CI/CD -> Variables)

6. Push changes and have fun
7. Push changes and have fun

## Environment Variables

Expand Down Expand Up @@ -111,11 +112,11 @@ If you want to define your custom variables see [Define custom variables](#defin

*1) Credentials can be generated in Gitlab (Settings -> Repository -> Deploy Tokens) with `read_registry` scope only

You can add your custom variables. *Do not forget to edit [deploy-project.sh](./docs/deploy-project.sh)*
You can add your custom variables. *Do not forget to edit your `deploy-project.sh` file*

## Customize deployment

You can override kubernetes manifests by place your custom manifest into `orchestration/kubernetes/` path in your project
You can override Kubernetes manifests by placing your custom manifests into `app/orchestration/kubernetes/` in your project.

*You need to mirror folders to be able to override manifests*

Expand All @@ -131,7 +132,7 @@ You can override kubernetes manifests by place your custom manifest into `orches
</exec>
</target>
```
2. Declare new cron to your deploy configuration file [deploy-project.sh](./docs/deploy-project.sh):
2. Declare new cron to your deploy configuration file (`deploy-project.sh`):

As a key there is used phing target that you created in step 1. and value represents [crontab timer](https://crontab.guru/#*/5_*_*_*_*)
```diff
Expand All @@ -155,7 +156,7 @@ You can override kubernetes manifests by place your custom manifest into `orches
| DOMAIN_HOSTNAME_2 | sk.mydomain.prod.shopsys.cloud |
| DOMAIN_HOSTNAME_3 | en.mydomain.prod.shopsys.cloud |

2. Edit [deploy-project.sh](./docs/deploy-project.sh)
2. Edit your `deploy-project.sh` file:
```diff
...
function deploy() {
Expand All @@ -170,7 +171,7 @@ You can override kubernetes manifests by place your custom manifest into `orches
### Define custom variables

1. Create Environment variable
2. Edit [deploy-project.sh](./docs/deploy-project.sh)
2. Edit your `deploy-project.sh` file:
```diff
...
declare -A ENVIRONMENT_VARIABLES=(
Expand All @@ -184,7 +185,7 @@ You can override kubernetes manifests by place your custom manifest into `orches

### Set custom Redis version

Add new variable to `deploy/deploy-project.sh` and specify your redis version
Add new variable to `deploy-project.sh` and specify your redis version

```diff
...
Expand All @@ -198,7 +199,7 @@ Add new variable to `deploy/deploy-project.sh` and specify your redis version

### Enable Horizontal pod autoscaling

Add new variables to `deploy/deploy-project.sh` to enable pod autoscaling:
Add new variables to `deploy-project.sh` to enable pod autoscaling:

- Enable this functionality:
```diff
Expand All @@ -219,7 +220,7 @@ Add new variables to `deploy/deploy-project.sh` to enable pod autoscaling:
- `MAX_STOREFRONT_REPLICAS`

### How to launch only some domains
Add to `deploy/deploy-project.sh` new array `FORCE_HTTP_AUTH_IN_PRODUCTION` with domains which should be not accessible without HTTP auth:
Add to `deploy-project.sh` new array `FORCE_HTTP_AUTH_IN_PRODUCTION` with domains which should be not accessible without HTTP auth:

```diff
...
Expand All @@ -237,8 +238,8 @@ Add new variables to `deploy/deploy-project.sh` to enable pod autoscaling:
### Change HTTP auth

1. Generate new HTTP auth string (for example [here](https://www.web2generators.com/apache-tools/htpasswd-generator)), or by command `htpasswd -nb username password`
2. Replace or add new HTTP auth string to `deploy/basicHttpAuth`
3. Set new credentials to variable in `deploy/deploy-project.sh`
2. Replace or add new HTTP auth string to `basicHttpAuth`
3. Set new credentials to variable in `deploy-project.sh`
```diff
...
function deploy() {
Expand All @@ -263,9 +264,9 @@ You can set sensitive whitelisted IPs in your env variable like this:
WHITELIST_IPS="8.8.8.8, 217.23.44.23, 93.111.234.111"
```

#### `DEFAULT_WHITELIST_IPS` env variable in `deploy/deploy-project.sh`
#### `DEFAULT_WHITELIST_IPS` env variable in `deploy-project.sh`

For non-sensitive IPs, that you want to share between all environments you can use `DEFAULT_WHITELIST_IPS` in `deploy/deploy-project.sh` like this:
For non-sensitive IPs, that you want to share between all environments you can use `DEFAULT_WHITELIST_IPS` in `deploy-project.sh` like this:

```shell
# Some IP Another IP Some service
Expand Down
5 changes: 5 additions & 0 deletions UPGRADE.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@
2. Run `composer update shopsys/deployment`
3. Check files in mentioned pull requests and if you have any of them extended in your project, apply changes manually

## Upgrade from v4.6.1 to v5.0.0

- remove files that are already part of project-base by default ([#66](https://github.com/shopsys/deployment/pull/66))
- if your project does not include `nginx.yaml` file for Kubernetes deployment, you need to copy-paste the [file](https://github.com/shopsys/project-base/blob/HEAD/app/orchestration/kubernetes/configmap/nginx.yaml) from project-base repository into `app/orchestration/kubernetes/configmap/nginx.yaml` in your project

## Upgrade from v4.6.0 to v4.6.1

- fix redirects within imageResizer ([#68](https://github.com/shopsys/deployment/pull/68))
Expand Down
1 change: 0 additions & 1 deletion docs/basicHttpAuth

This file was deleted.

89 changes: 0 additions & 89 deletions docs/deploy-project.sh

This file was deleted.

3 changes: 3 additions & 0 deletions tests/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ Using `--user "$(id -u):$(id -g)"` ensures generated files are owned by your loc
```
tests/
├── run-tests.sh # Main test runner
├── fixtures/ # Shared project-level overrides copied to tmp test project
├── lib/
│ ├── test-helpers.sh # Helper functions
│ └── default-env.sh # Shared default environment variables
Expand All @@ -67,3 +68,5 @@ tests/
3. Runs scenario's `deploy-project.sh generate`
4. Builds kustomize outputs
5. Compares with expected files

`tests/fixtures/orchestration/kubernetes/configmap/nginx.yaml` is intentionally tracked because the deployment package no longer ships `kubernetes/configmap/nginx.yaml`, but test scenarios still need a project-level override to build webserver manifests.
6 changes: 6 additions & 0 deletions tests/run-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,12 @@ setup_test_environment() {
ln -s "${PROJECT_ROOT}/kubernetes" "${test_tmp}/vendor/shopsys/deployment/kubernetes"
ln -s "${PROJECT_ROOT}/deploy" "${test_tmp}/vendor/shopsys/deployment/deploy"

# Provide required project-level overrides that are no longer shipped by deployment package.
local fixtures_orchestration_path="${PROJECT_ROOT}/tests/fixtures/orchestration"
if [ -d "${fixtures_orchestration_path}" ]; then
cp -R "${fixtures_orchestration_path}/." "${test_tmp}/orchestration/"
fi

# Create domains_urls.yaml.dist dynamically based on domain count
echo "domains_urls:" > "${test_tmp}/config/domains_urls.yaml.dist"
for i in $(seq 1 ${domain_count}); do
Expand Down
Loading