Issue #4: Supplement README with build instructions for new versions.

This commit is contained in:
Jeff Geerling
2019-11-20 10:09:23 -06:00
parent a6b0ce1ff5
commit 5c5a058524
3 changed files with 86 additions and 4 deletions

View File

@@ -36,7 +36,9 @@ After a few minutes, your new Tower instance will be accessible at `http://tower
TODO: See [Issue #4](https://github.com/geerlingguy/tower-operator/issues/4). TODO: See [Issue #4](https://github.com/geerlingguy/tower-operator/issues/4).
## Testing ## Development
### Testing
This Operator includes a [Molecule](https://molecule.readthedocs.io/en/stable/)-based test environment, which can be executed standalone in Docker (e.g. in CI or in a single Docker container anywhere), or inside any kind of Kubernetes cluster (e.g. Minikube). This Operator includes a [Molecule](https://molecule.readthedocs.io/en/stable/)-based test environment, which can be executed standalone in Docker (e.g. in CI or in a single Docker container anywhere), or inside any kind of Kubernetes cluster (e.g. Minikube).
@@ -48,13 +50,13 @@ Running `molecule test` sets up a clean environment, builds the operator, runs a
If you want to actively develop the operator, use `molecule converge`, which does everything but tear down the environment at the end. If you want to actively develop the operator, use `molecule converge`, which does everything but tear down the environment at the end.
### Testing in Docker (standalone) #### Testing in Docker (standalone)
molecule test -s test-local molecule test -s test-local
This environment is meant for headless testing (e.g. in a CI environment, or when making smaller changes which don't need to be verified through a web interface). It is difficult to test things like Tower's web UI or to connect other applications on your local machine to the services running inside the cluster, since it is inside a Docker container with no static IP address. This environment is meant for headless testing (e.g. in a CI environment, or when making smaller changes which don't need to be verified through a web interface). It is difficult to test things like Tower's web UI or to connect other applications on your local machine to the services running inside the cluster, since it is inside a Docker container with no static IP address.
### Testing in Minikube #### Testing in Minikube
minikube start --memory 6g --cpus 2 minikube start --memory 6g --cpus 2
minikube addons enable ingress minikube addons enable ingress
@@ -66,3 +68,44 @@ Once the operator is deployed, you can visit the Tower UI in your browser by fol
1. Make sure you have an entry like `IP_ADDRESS example-tower.test` in your `/etc/hosts` file. (Get the IP address with `minikube ip`.) 1. Make sure you have an entry like `IP_ADDRESS example-tower.test` in your `/etc/hosts` file. (Get the IP address with `minikube ip`.)
2. Visit `http://example-tower.test/` in your browser. 2. Visit `http://example-tower.test/` in your browser.
### Release Process
There are a few moving parts to this project:
1. The Docker image which powers Tower Operator.
2. The `tower-operator.yaml` Kubernetes manifest file which initially deploys the Operator into a cluster.
Each of these must be appropriately built in preparation for a new tag:
#### Build a new release of the Operator for Docker Hub
Run the following command inside this directory:
operator-sdk build geerlingguy/tower-operator:0.1.0
Then push the generated image to Docker Hub:
docker login -u geerlingguy
docker push geerlingguy/tower-operator:0.1.0
#### Build a new version of the `tower-operator.yaml` file
Update the tower-operator version in two places:
1. `deploy/tower-operator.yaml`: in the `ansible` and `operator` container definitions in the `tower-operator` Deployment.
2. `build/chain-operator-files.yml`: the `operator_image` variable.
Once the versions are updated, run the playbook in the `build/` directory:
ansible-playbook chain-operator-files.yml
After it is built, test it on a local cluster:
minikube start
kubectl apply -f deploy/tower-operator.yaml
kubectl apply -f deploy/crds/tower_v1alpha1_tower_cr_awx.yaml
<test everything>
minikube delete
If everything works, commit the updated version, then tag a new repository release with the same tag as the Docker image pushed earlier.

View File

@@ -1,4 +1,4 @@
FROM quay.io/operator-framework/ansible-operator:v0.10.0 FROM quay.io/operator-framework/ansible-operator:v0.12.0
# Install kubectl. # Install kubectl.
COPY --from=lachlanevenson/k8s-kubectl:v1.16.2 /usr/local/bin/kubectl /usr/local/bin/kubectl COPY --from=lachlanevenson/k8s-kubectl:v1.16.2 /usr/local/bin/kubectl /usr/local/bin/kubectl

View File

@@ -0,0 +1,39 @@
---
# To run: `ansible-playbook chain-operator-files.yml`
- name: Chain operator files together for easy deployment.
hosts: localhost
connection: local
gather_facts: false
vars:
operator_image: geerlingguy/tower-operator:0.1.0
pull_policy: Always
operator_file_path: "../deploy/tower-operator.yaml"
operator_template: "../deploy/operator.yaml"
tasks:
- name: Clear out current contents of tower-operator.yml
copy:
dest: "{{ operator_file_path }}"
content: ''
force: true
- name: Concatenate operator files into tower-operator.yml
blockinfile:
path: "{{ operator_file_path }}"
block: "{{ item }}"
marker: "---"
marker_begin: ""
marker_end: ""
insertafter: "EOF"
with_file:
- "../deploy/crds/tower_v1alpha1_tower_crd.yaml"
- "../deploy/role.yaml"
- "../deploy/role_binding.yaml"
- "../deploy/service_account.yaml"
- "../deploy/operator.yaml"
- name: Template the tower-operator.yaml file into tower-operator.yml
template:
src: "{{ operator_file_path }}"
dest: "{{ operator_file_path }}"