mirror of
https://github.com/ansible/awx-operator.git
synced 2026-03-27 05:43:11 +00:00
Compare commits
116 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f35bd7cf83 | ||
|
|
95a1fc082b | ||
|
|
dbd1e59a55 | ||
|
|
61f45147f6 | ||
|
|
c20f9b4128 | ||
|
|
15568fe564 | ||
|
|
1baf417504 | ||
|
|
7fbf1c42aa | ||
|
|
a5e21b56ae | ||
|
|
1399504142 | ||
|
|
e5896d15ed | ||
|
|
6b01ff09ce | ||
|
|
c708cef4dc | ||
|
|
1cf466def2 | ||
|
|
0fc145b6aa | ||
|
|
e30d26cf7b | ||
|
|
7c4a731995 | ||
|
|
d2efea08e6 | ||
|
|
23e94f82c0 | ||
|
|
de2e58f222 | ||
|
|
1c7c89efb3 | ||
|
|
096fe100f7 | ||
|
|
58ee2f0c74 | ||
|
|
93f7484f38 | ||
|
|
225c47dbbc | ||
|
|
2daf8a1320 | ||
|
|
5772c706d3 | ||
|
|
ae0a74bea3 | ||
|
|
97cd7a9b7a | ||
|
|
0975663a52 | ||
|
|
efdbd61860 | ||
|
|
13b45cbb12 | ||
|
|
d3ca9c57c9 | ||
|
|
9b1b5e676d | ||
|
|
17eb9cf8e8 | ||
|
|
ed7e2b2a28 | ||
|
|
5b7589accd | ||
|
|
a1e289e189 | ||
|
|
0611f3efaa | ||
|
|
a94a6f045d | ||
|
|
1892b8f0ea | ||
|
|
57b5795aab | ||
|
|
e8096a5f33 | ||
|
|
271bce48bd | ||
|
|
d64c34f8a4 | ||
|
|
1bddb98476 | ||
|
|
5f183999d0 | ||
|
|
3769897131 | ||
|
|
7f86231009 | ||
|
|
f59dac829a | ||
|
|
edecf4d2fe | ||
|
|
4120b5e2b0 | ||
|
|
8dabca5418 | ||
|
|
1d341a21d0 | ||
|
|
f8719db954 | ||
|
|
89425826e8 | ||
|
|
5c572a9ba6 | ||
|
|
b7bbfd432d | ||
|
|
b17cd16fb7 | ||
|
|
dc6cbab501 | ||
|
|
a81be586db | ||
|
|
f2a9e967cc | ||
|
|
9f017d03e6 | ||
|
|
7d2d1b3c5e | ||
|
|
5d0ebd0121 | ||
|
|
f368a539a9 | ||
|
|
0aef4cc35f | ||
|
|
e3701dd3db | ||
|
|
cf98edc282 | ||
|
|
58a4778c89 | ||
|
|
8e50bdde9b | ||
|
|
60386bc928 | ||
|
|
f1df88dc53 | ||
|
|
8de6179ac7 | ||
|
|
8a3c8e727a | ||
|
|
c230016819 | ||
|
|
bea05c97ee | ||
|
|
3a6040e0cd | ||
|
|
24f3f440f1 | ||
|
|
87b0511997 | ||
|
|
fde4a47a14 | ||
|
|
af2e681f1e | ||
|
|
82ffa3d348 | ||
|
|
db6a5b53ed | ||
|
|
0be17476cd | ||
|
|
f4a781ccc5 | ||
|
|
fcd2c4c023 | ||
|
|
8e30a17a77 | ||
|
|
b3037c1067 | ||
|
|
f7ff132a2e | ||
|
|
5f06e90906 | ||
|
|
36355b6a15 | ||
|
|
bc08c4bbbe | ||
|
|
7697825944 | ||
|
|
8a325293b1 | ||
|
|
dd53a1d415 | ||
|
|
c5db0e7104 | ||
|
|
59036fc373 | ||
|
|
c45a7bd4d7 | ||
|
|
34b6354001 | ||
|
|
801f392447 | ||
|
|
779572e8ff | ||
|
|
e7e48f92a0 | ||
|
|
3cd9ddd8c6 | ||
|
|
4e6be0a82c | ||
|
|
05943687fe | ||
|
|
9676ebc008 | ||
|
|
8352237260 | ||
|
|
35d4954027 | ||
|
|
4d6a491766 | ||
|
|
fa9eb53f92 | ||
|
|
00c9f5fbd1 | ||
|
|
fe82e9259e | ||
|
|
635d530dc9 | ||
|
|
8b3a297086 | ||
|
|
ba3b6f5436 |
26
.github/PULL_REQUEST_TEMPLATE.md
vendored
Normal file
26
.github/PULL_REQUEST_TEMPLATE.md
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
##### SUMMARY
|
||||
<!--- Describe the change, including rationale and design decisions -->
|
||||
|
||||
<!---
|
||||
If you are fixing an existing issue, please include "fixes #nnn" in your
|
||||
commit message and your description; but you should still explain what
|
||||
the change does.
|
||||
-->
|
||||
|
||||
##### ISSUE TYPE
|
||||
<!--- Pick one below and delete the rest: -->
|
||||
- Breaking Change
|
||||
- New or Enhanced Feature
|
||||
- Bug, Docs Fix or other nominal change
|
||||
|
||||
##### ADDITIONAL INFORMATION
|
||||
<!---
|
||||
Include additional information to help people understand the change here.
|
||||
For bugs that don't have a linked bug report, a step-by-step reproduction
|
||||
of the problem is helpful.
|
||||
-->
|
||||
|
||||
<!--- Paste verbatim command output below, e.g. before and after your change -->
|
||||
```
|
||||
|
||||
```
|
||||
37
.github/workflows/ci.yaml
vendored
37
.github/workflows/ci.yaml
vendored
@@ -60,7 +60,40 @@ jobs:
|
||||
kustomize edit add patch --path ../testing/pull_policy/Never.yaml
|
||||
working-directory: config/default
|
||||
|
||||
- name: Build and install helm chart
|
||||
- name: Build and lint helm chart
|
||||
run: |
|
||||
IMG=awx-operator-ci make helm-chart
|
||||
helm install --wait my-awx-operator ./charts/awx-operator
|
||||
helm lint ./charts/awx-operator
|
||||
|
||||
- name: Install kubeval
|
||||
run: |
|
||||
mkdir tmp && cd tmp
|
||||
wget https://github.com/instrumenta/kubeval/releases/latest/download/kubeval-linux-amd64.tar.gz
|
||||
tar xf kubeval-linux-amd64.tar.gz
|
||||
sudo cp kubeval /usr/local/bin
|
||||
working-directory: ./charts
|
||||
|
||||
- name: Run kubeval
|
||||
run: |
|
||||
helm template -n awx awx-operator > tmp/test.yaml
|
||||
kubeval --strict --force-color --ignore-missing-schemas tmp/test.yaml
|
||||
working-directory: ./charts
|
||||
|
||||
- name: Install helm chart
|
||||
run: |
|
||||
helm install --wait my-awx-operator --namespace awx --create-namespace ./charts/awx-operator
|
||||
no-log:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout sources
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: Check no_log statements
|
||||
run: |
|
||||
set +e
|
||||
no_log=$(grep -nr ' no_log:' roles | grep -v '"{{ no_log }}"')
|
||||
if [ -n "${no_log}" ]; then
|
||||
echo 'Please update the following no_log statement(s) with the "{{ no_log }}" value'
|
||||
echo "${no_log}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
54
.github/workflows/label_issue.yml
vendored
Normal file
54
.github/workflows/label_issue.yml
vendored
Normal file
@@ -0,0 +1,54 @@
|
||||
---
|
||||
name: Label Issues
|
||||
|
||||
on:
|
||||
issues:
|
||||
types:
|
||||
- opened
|
||||
- reopened
|
||||
|
||||
jobs:
|
||||
triage:
|
||||
runs-on: ubuntu-latest
|
||||
name: Label
|
||||
|
||||
steps:
|
||||
- name: Label Issue - Needs Triage
|
||||
uses: github/issue-labeler@v2.4.1
|
||||
with:
|
||||
repo-token: "${{ secrets.GITHUB_TOKEN }}"
|
||||
not-before: 2021-12-07T07:00:00Z
|
||||
configuration-path: .github/issue_labeler.yml
|
||||
enable-versioned-regex: 0
|
||||
if: github.event_name == 'issues'
|
||||
|
||||
community:
|
||||
runs-on: ubuntu-latest
|
||||
name: Label Issue - Community
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/setup-python@v4
|
||||
- name: Install python requests
|
||||
run: pip install requests
|
||||
- name: Check if user is a member of Ansible org
|
||||
uses: jannekem/run-python-script-action@v1
|
||||
id: check_user
|
||||
with:
|
||||
script: |
|
||||
import requests
|
||||
headers = {'Accept': 'application/vnd.github+json', 'Authorization': 'token ${{ secrets.GITHUB_TOKEN }}'}
|
||||
response = requests.get('${{ fromJson(toJson(github.event.issue.user.url)) }}/orgs?per_page=100', headers=headers)
|
||||
is_member = False
|
||||
for org in response.json():
|
||||
if org['login'] == 'ansible':
|
||||
is_member = True
|
||||
if is_member:
|
||||
print("User is member")
|
||||
else:
|
||||
print("User is community")
|
||||
- name: Add community label if not a member
|
||||
if: contains(steps.check_user.outputs.stdout, 'community')
|
||||
uses: andymckay/labeler@e6c4322d0397f3240f0e7e30a33b5c5df2d39e90
|
||||
with:
|
||||
add-labels: "community"
|
||||
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
40
.github/workflows/label_pr.yml
vendored
Normal file
40
.github/workflows/label_pr.yml
vendored
Normal file
@@ -0,0 +1,40 @@
|
||||
name: Label PR
|
||||
|
||||
on:
|
||||
pull_request_target:
|
||||
types:
|
||||
- opened
|
||||
- reopened
|
||||
- synchronize
|
||||
|
||||
jobs:
|
||||
community:
|
||||
runs-on: ubuntu-latest
|
||||
name: Label PR - Community
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/setup-python@v4
|
||||
- name: Install python requests
|
||||
run: pip install requests
|
||||
- name: Check if user is a member of Ansible org
|
||||
uses: jannekem/run-python-script-action@v1
|
||||
id: check_user
|
||||
with:
|
||||
script: |
|
||||
import requests
|
||||
headers = {'Accept': 'application/vnd.github+json', 'Authorization': 'token ${{ secrets.GITHUB_TOKEN }}'}
|
||||
response = requests.get('${{ fromJson(toJson(github.event.pull_request.user.url)) }}/orgs?per_page=100', headers=headers)
|
||||
is_member = False
|
||||
for org in response.json():
|
||||
if org['login'] == 'ansible':
|
||||
is_member = True
|
||||
if is_member:
|
||||
print("User is member")
|
||||
else:
|
||||
print("User is community")
|
||||
- name: Add community label if not a member
|
||||
if: contains(steps.check_user.outputs.stdout, 'community')
|
||||
uses: andymckay/labeler@e6c4322d0397f3240f0e7e30a33b5c5df2d39e90
|
||||
with:
|
||||
add-labels: "community"
|
||||
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
45
.github/workflows/pr_body_check.yml
vendored
Normal file
45
.github/workflows/pr_body_check.yml
vendored
Normal file
@@ -0,0 +1,45 @@
|
||||
---
|
||||
name: PR Check
|
||||
env:
|
||||
BRANCH: ${{ github.base_ref || 'devel' }}
|
||||
on:
|
||||
pull_request:
|
||||
types: [opened, edited, reopened, synchronize]
|
||||
jobs:
|
||||
pr-check:
|
||||
name: Scan PR description for semantic versioning keywords
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
packages: write
|
||||
contents: read
|
||||
steps:
|
||||
- name: Write PR body to a file
|
||||
run: |
|
||||
cat >> pr.body << __SOME_RANDOM_PR_EOF__
|
||||
${{ github.event.pull_request.body }}
|
||||
__SOME_RANDOM_PR_EOF__
|
||||
|
||||
- name: Display the received body for troubleshooting
|
||||
run: cat pr.body
|
||||
|
||||
# We want to write these out individually just incase the options were joined on a single line
|
||||
- name: Check for each of the lines
|
||||
run: |
|
||||
grep "Bug, Docs Fix or other nominal change" pr.body > Z
|
||||
grep "New or Enhanced Feature" pr.body > Y
|
||||
grep "Breaking Change" pr.body > X
|
||||
exit 0
|
||||
# We exit 0 and set the shell to prevent the returns from the greps from failing this step
|
||||
# See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#exit-codes-and-error-action-preference
|
||||
shell: bash {0}
|
||||
|
||||
- name: Check for exactly one item
|
||||
run: |
|
||||
if [ $(cat X Y Z | wc -l) != 1 ] ; then
|
||||
echo "The PR body must contain exactly one of [ 'Bug, Docs Fix or other nominal change', 'New or Enhanced Feature', 'Breaking Change' ]"
|
||||
echo "We counted $(cat X Y Z | wc -l)"
|
||||
echo "See the default PR body for examples"
|
||||
exit 255;
|
||||
else
|
||||
exit 0;
|
||||
fi
|
||||
22
.github/workflows/triage_new.yml
vendored
22
.github/workflows/triage_new.yml
vendored
@@ -1,22 +0,0 @@
|
||||
---
|
||||
name: Triage
|
||||
|
||||
on:
|
||||
issues:
|
||||
types:
|
||||
- opened
|
||||
|
||||
jobs:
|
||||
triage:
|
||||
runs-on: ubuntu-latest
|
||||
name: Label
|
||||
|
||||
steps:
|
||||
- name: Label issues
|
||||
uses: github/issue-labeler@v2.4.1
|
||||
with:
|
||||
repo-token: "${{ secrets.GITHUB_TOKEN }}"
|
||||
not-before: 2021-12-07T07:00:00Z
|
||||
configuration-path: .github/issue_labeler.yml
|
||||
enable-versioned-regex: 0
|
||||
if: github.event_name == 'issues'
|
||||
2
.gitignore
vendored
2
.gitignore
vendored
@@ -6,3 +6,5 @@
|
||||
/bundle.Dockerfile
|
||||
/charts
|
||||
/.cr-release-packages
|
||||
.vscode/
|
||||
__pycache__
|
||||
|
||||
56
.helm/starter/README.md
Normal file
56
.helm/starter/README.md
Normal file
@@ -0,0 +1,56 @@
|
||||
# AWX Operator Helm Chart
|
||||
|
||||
This chart installs the AWX Operator resources configured in [this](https://github.com/ansible/awx-operator) repository.
|
||||
|
||||
## Getting Started
|
||||
To configure your AWX resource using this chart, create your own `yaml` values file. The name is up to personal preference since it will explicitly be passed into the helm chart. Helm will merge whatever values you specify in your file with the default `values.yaml`, overriding any settings you've changed while allowing you to fall back on defaults. Because of this functionality, `values.yaml` should not be edited directly.
|
||||
|
||||
In your values config, enable `AWX.enabled` and add `AWX.spec` values based on the awx operator's [documentation](https://github.com/ansible/awx-operator/blob/devel/README.md). Consult the docs below for additional functionality.
|
||||
|
||||
### Installing
|
||||
The operator's [helm install](https://github.com/ansible/awx-operator/blob/devel/README.md#helm-install-on-existing-cluster) guide provides key installation instructions.
|
||||
|
||||
Example:
|
||||
```
|
||||
helm install my-awx-operator awx-operator/awx-operator -n awx --create-namespace -f myvalues.yaml
|
||||
```
|
||||
|
||||
Argument breakdown:
|
||||
* `-f` passes in the file with your custom values
|
||||
* `-n` sets the namespace to be installed in
|
||||
* This value is accessed by `{{ $.Release.Namespace }}` in the templates
|
||||
* Acts as the default namespace for all unspecified resources
|
||||
* `--create-namespace` specifies that helm should create the namespace before installing
|
||||
|
||||
To update an existing installation, use `helm upgrade` instead of `install`. The rest of the syntax remains the same.
|
||||
|
||||
## Configuration
|
||||
The goal of adding helm configurations is to abstract out and simplify the creation of multi-resource configs. The `AWX.spec` field maps directly to the spec configs of the `AWX` resource that the operator provides, which are detailed in the [main README](https://github.com/ansible/awx-operator/blob/devel/README.md). Other sub-config can be added with the goal of simplifying more involved setups that require additional resources to be specified.
|
||||
|
||||
These sub-headers aim to be a more intuitive entrypoint into customizing your deployment, and are easier to manage in the long-term. By design, the helm templates will defer to the manually defined specs to avoid configuration conflicts. For example, if `AWX.spec.postgres_configuration_secret` is being used, the `AWX.postgres` settings will not be applied, even if enabled.
|
||||
|
||||
### External Postgres
|
||||
The `AWX.postgres` section simplifies the creation of the external postgres secret. If enabled, the configs provided will automatically be placed in a `postgres-config` secret and linked to the `AWX` resource. For proper secret management, the `AWX.postgres.password` value, and any other sensitive values, can be passed in at the command line rather than specified in code. Use the `--set` argument with `helm install`.
|
||||
|
||||
|
||||
## Values Summary
|
||||
|
||||
### AWX
|
||||
| Value | Description | Default |
|
||||
|---|---|---|
|
||||
| `AWX.enabled` | Enable this AWX resource configuration | `false` |
|
||||
| `AWX.name` | The name of the AWX resource and default prefix for other resources | `"awx"` |
|
||||
| `AWX.spec` | specs to directly configure the AWX resource | `{}` |
|
||||
| `AWX.postgres` | configurations for the external postgres secret | - |
|
||||
|
||||
|
||||
# Contributing
|
||||
|
||||
## Adding abstracted sections
|
||||
Where possible, defer to `AWX.spec` configs before applying the abstracted configs to avoid collision. This can be facilitated by the `(hasKey .spec what_i_will_abstract)` check.
|
||||
|
||||
## Building and Testing
|
||||
This chart is built using the Makefile in the [awx-operator repo](https://github.com/ansible/awx-operator). Clone the repo and run `make helm-chart`. This will create the awx-operator chart in the `charts/awx-operator` directory. In this process, the contents of the `.helm/starter` directory will be added to the chart.
|
||||
|
||||
## Future Goals
|
||||
All values under the `AWX` header are focused on configurations that use the operator. Configurations that relate to the Operator itself could be placed under an `Operator` heading, but that may add a layer of complication over current development.
|
||||
6
.helm/starter/templates/_helpers.tpl
Normal file
6
.helm/starter/templates/_helpers.tpl
Normal file
@@ -0,0 +1,6 @@
|
||||
{{/*
|
||||
Generate the name of the postgres secret, expects AWX context passed in
|
||||
*/}}
|
||||
{{- define "postgres.secretName" -}}
|
||||
{{ default (printf "%s-postgres-configuration" .Values.AWX.name) .Values.AWX.postgres.secretName }}
|
||||
{{- end }}
|
||||
24
.helm/starter/templates/awx-deploy.yaml
Normal file
24
.helm/starter/templates/awx-deploy.yaml
Normal file
@@ -0,0 +1,24 @@
|
||||
{{- if $.Values.AWX.enabled }}
|
||||
{{- with .Values.AWX }}
|
||||
apiVersion: awx.ansible.com/v1beta1
|
||||
kind: AWX
|
||||
metadata:
|
||||
name: {{ .name }}
|
||||
namespace: {{ $.Release.Namespace }}
|
||||
spec:
|
||||
{{- /* Include raw map from the values file spec */}}
|
||||
{{ .spec | toYaml | indent 2 }}
|
||||
{{- /* Provide security context defaults */}}
|
||||
{{- if not (hasKey .spec "security_context_settings") }}
|
||||
security_context_settings:
|
||||
runAsGroup: 0
|
||||
runAsUser: 0
|
||||
fsGroup: 0
|
||||
fsGroupChangePolicy: OnRootMismatch
|
||||
{{- end }}
|
||||
{{- /* Postgres configs if enabled and not already present */}}
|
||||
{{- if and .postgres.enabled (not (hasKey .spec "postgres_configuration_secret")) }}
|
||||
postgres_configuration_secret: {{ include "postgres.secretName" $ }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
18
.helm/starter/templates/postgres-config.yaml
Normal file
18
.helm/starter/templates/postgres-config.yaml
Normal file
@@ -0,0 +1,18 @@
|
||||
{{- if and $.Values.AWX.enabled $.Values.AWX.postgres.enabled }}
|
||||
apiVersion: v1
|
||||
kind: Secret
|
||||
metadata:
|
||||
name: {{ include "postgres.secretName" . }}
|
||||
namespace: {{ $.Release.Namespace }}
|
||||
{{- with $.Values.AWX.postgres }}
|
||||
stringData:
|
||||
host: {{ .host }}
|
||||
port: {{ .port | quote }}
|
||||
database: {{ .dbName }}
|
||||
username: {{ .username }}
|
||||
password: {{ .password }}
|
||||
sslmode: {{ .sslmode }}
|
||||
type: {{ .type }}
|
||||
type: Opaque
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
@@ -0,0 +1,19 @@
|
||||
AWX:
|
||||
# enable use of awx-deploy template
|
||||
enabled: false
|
||||
name: awx
|
||||
spec:
|
||||
admin_user: admin
|
||||
|
||||
# configurations for external postgres instance
|
||||
postgres:
|
||||
enabled: false
|
||||
host: Unset
|
||||
port: 5678
|
||||
dbName: Unset
|
||||
username: admin
|
||||
# for secret management, pass in the password independently of this file
|
||||
# at the command line, use --set AWX.postgres.password
|
||||
password: Unset
|
||||
sslmode: prefer
|
||||
type: unmanaged
|
||||
|
||||
@@ -6,8 +6,14 @@ ignore: |
|
||||
kustomization.yaml
|
||||
awx-operator.clusterserviceversion.yaml
|
||||
bundle
|
||||
.helm/starter
|
||||
|
||||
rules:
|
||||
truthy: disable
|
||||
line-length:
|
||||
max: 170
|
||||
document-start: disable
|
||||
comments-indentation: disable
|
||||
indentation:
|
||||
level: warning
|
||||
indent-sequences: consistent
|
||||
|
||||
13
Dockerfile
13
Dockerfile
@@ -1,4 +1,10 @@
|
||||
FROM quay.io/operator-framework/ansible-operator:v1.12.0
|
||||
FROM quay.io/operator-framework/ansible-operator:v1.23.0
|
||||
|
||||
USER 0
|
||||
|
||||
RUN dnf install -y openssl
|
||||
|
||||
USER 1001
|
||||
|
||||
ARG DEFAULT_AWX_VERSION
|
||||
ARG OPERATOR_VERSION
|
||||
@@ -12,3 +18,8 @@ RUN ansible-galaxy collection install -r ${HOME}/requirements.yml \
|
||||
COPY watches.yaml ${HOME}/watches.yaml
|
||||
COPY roles/ ${HOME}/roles/
|
||||
COPY playbooks/ ${HOME}/playbooks/
|
||||
|
||||
ENTRYPOINT ["/tini", "--", "/usr/local/bin/ansible-operator", "run", \
|
||||
"--watches-file=./watches.yaml", \
|
||||
"--reconcile-period=0s" \
|
||||
]
|
||||
|
||||
101
Makefile
101
Makefile
@@ -44,6 +44,17 @@ IMAGE_TAG_BASE ?= quay.io/ansible/awx-operator
|
||||
# You can use it as an arg. (E.g make bundle-build BUNDLE_IMG=<some-registry>/<project-name-bundle>:<tag>)
|
||||
BUNDLE_IMG ?= $(IMAGE_TAG_BASE)-bundle:v$(VERSION)
|
||||
|
||||
# BUNDLE_GEN_FLAGS are the flags passed to the operator-sdk generate bundle command
|
||||
BUNDLE_GEN_FLAGS ?= -q --overwrite --version $(VERSION) $(BUNDLE_METADATA_OPTS)
|
||||
|
||||
# USE_IMAGE_DIGESTS defines if images are resolved via tags or digests
|
||||
# You can enable this value if you would like to use SHA Based Digests
|
||||
# To enable set flag to true
|
||||
USE_IMAGE_DIGESTS ?= false
|
||||
ifeq ($(USE_IMAGE_DIGESTS), true)
|
||||
BUNDLE_GEN_FLAGS += --use-image-digests
|
||||
endif
|
||||
|
||||
# Image URL to use all building/pushing image targets
|
||||
IMG ?= $(IMAGE_TAG_BASE):$(VERSION)
|
||||
NAMESPACE ?= awx
|
||||
@@ -56,6 +67,7 @@ CHART_REPO ?= awx-operator
|
||||
CHART_BRANCH ?= gh-pages
|
||||
CHART_INDEX ?= index.yaml
|
||||
|
||||
.PHONY: all
|
||||
all: docker-build
|
||||
|
||||
##@ General
|
||||
@@ -71,38 +83,47 @@ all: docker-build
|
||||
# More info on the awk command:
|
||||
# http://linuxcommand.org/lc3_adv_awk.php
|
||||
|
||||
.PHONY: help
|
||||
help: ## Display this help.
|
||||
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m<target>\033[0m\n"} /^[a-zA-Z_0-9-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST)
|
||||
|
||||
##@ Build
|
||||
|
||||
.PHONY: run
|
||||
run: ansible-operator ## Run against the configured Kubernetes cluster in ~/.kube/config
|
||||
ANSIBLE_ROLES_PATH="$(ANSIBLE_ROLES_PATH):$(shell pwd)/roles" $(ANSIBLE_OPERATOR) run
|
||||
|
||||
.PHONY: docker-build
|
||||
docker-build: ## Build docker image with the manager.
|
||||
${CONTAINER_CMD} build $(BUILD_ARGS) -t ${IMG} .
|
||||
|
||||
.PHONY: docker-push
|
||||
docker-push: ## Push docker image with the manager.
|
||||
${CONTAINER_CMD} push ${IMG}
|
||||
|
||||
##@ Deployment
|
||||
|
||||
.PHONY: install
|
||||
install: kustomize ## Install CRDs into the K8s cluster specified in ~/.kube/config.
|
||||
$(KUSTOMIZE) build config/crd | kubectl apply -f -
|
||||
|
||||
.PHONY: uninstall
|
||||
uninstall: kustomize ## Uninstall CRDs from the K8s cluster specified in ~/.kube/config.
|
||||
$(KUSTOMIZE) build config/crd | kubectl delete -f -
|
||||
|
||||
.PHONY: gen-resources
|
||||
gen-resources: kustomize ## Generate resources for controller and print to stdout
|
||||
@cd config/manager && $(KUSTOMIZE) edit set image controller=${IMG}
|
||||
@cd config/default && $(KUSTOMIZE) edit set namespace ${NAMESPACE}
|
||||
@$(KUSTOMIZE) build config/default
|
||||
|
||||
.PHONY: deploy
|
||||
deploy: kustomize ## Deploy controller to the K8s cluster specified in ~/.kube/config.
|
||||
@cd config/manager && $(KUSTOMIZE) edit set image controller=${IMG}
|
||||
@cd config/default && $(KUSTOMIZE) edit set namespace ${NAMESPACE}
|
||||
@$(KUSTOMIZE) build config/default | kubectl apply -f -
|
||||
|
||||
.PHONY: undeploy
|
||||
undeploy: ## Undeploy controller from the K8s cluster specified in ~/.kube/config.
|
||||
@cd config/default && $(KUSTOMIZE) edit set namespace ${NAMESPACE}
|
||||
$(KUSTOMIZE) build config/default | kubectl delete -f -
|
||||
@@ -119,7 +140,7 @@ ifeq (,$(shell which kustomize 2>/dev/null))
|
||||
@{ \
|
||||
set -e ;\
|
||||
mkdir -p $(dir $(KUSTOMIZE)) ;\
|
||||
curl -sSLo - https://github.com/kubernetes-sigs/kustomize/releases/download/kustomize/v4.5.2/kustomize_v4.5.2_$(OS)_$(ARCHA).tar.gz | \
|
||||
curl -sSLo - https://github.com/kubernetes-sigs/kustomize/releases/download/kustomize/v4.5.5/kustomize_v4.5.5_$(OS)_$(ARCHA).tar.gz | \
|
||||
tar xzf - -C bin/ ;\
|
||||
}
|
||||
else
|
||||
@@ -135,7 +156,7 @@ ifeq (,$(shell which ansible-operator 2>/dev/null))
|
||||
@{ \
|
||||
set -e ;\
|
||||
mkdir -p $(dir $(ANSIBLE_OPERATOR)) ;\
|
||||
curl -sSLo $(ANSIBLE_OPERATOR) https://github.com/operator-framework/operator-sdk/releases/download/v1.12.0/ansible-operator_$(OS)_$(ARCHA) ;\
|
||||
curl -sSLo $(ANSIBLE_OPERATOR) https://github.com/operator-framework/operator-sdk/releases/download/v1.23.0/ansible-operator_$(OS)_$(ARCHA) ;\
|
||||
chmod +x $(ANSIBLE_OPERATOR) ;\
|
||||
}
|
||||
else
|
||||
@@ -166,7 +187,7 @@ ifeq (,$(shell which opm 2>/dev/null))
|
||||
@{ \
|
||||
set -e ;\
|
||||
mkdir -p $(dir $(OPM)) ;\
|
||||
curl -sSLo $(OPM) https://github.com/operator-framework/operator-registry/releases/download/v1.15.1/$(OS)-$(ARCHA)-opm ;\
|
||||
curl -sSLo $(OPM) https://github.com/operator-framework/operator-registry/releases/download/v1.23.0/$(OS)-$(ARCHA)-opm ;\
|
||||
chmod +x $(OPM) ;\
|
||||
}
|
||||
else
|
||||
@@ -269,30 +290,63 @@ charts:
|
||||
mkdir -p $@
|
||||
|
||||
.PHONY: helm-chart
|
||||
helm-chart: kustomize helm kubectl-slice yq charts
|
||||
@echo "== KUSTOMIZE (image and namespace) =="
|
||||
cd config/manager && $(KUSTOMIZE) edit set image controller=${IMG}
|
||||
cd config/default && $(KUSTOMIZE) edit set namespace ${NAMESPACE}
|
||||
helm-chart: helm-chart-generate
|
||||
|
||||
@echo "== HELM =="
|
||||
.PHONY: helm-chart-generate
|
||||
helm-chart-generate: kustomize helm kubectl-slice yq charts
|
||||
@echo "== KUSTOMIZE: Set image and chart label =="
|
||||
cd config/manager && $(KUSTOMIZE) edit set image controller=${IMG}
|
||||
cd config/manager && $(KUSTOMIZE) edit set label helm.sh/chart:$(CHART_NAME)
|
||||
cd config/default && $(KUSTOMIZE) edit set label helm.sh/chart:$(CHART_NAME)
|
||||
|
||||
@echo "== Gather Helm Chart Metadata =="
|
||||
# remove the existing chart if it exists
|
||||
rm -rf charts/$(CHART_NAME)
|
||||
# create new chart metadata in Chart.yaml
|
||||
cd charts && \
|
||||
$(HELM) create awx-operator --starter $(shell pwd)/.helm/starter ;\
|
||||
$(YQ) -i '.version = "$(VERSION)"' $(CHART_NAME)/Chart.yaml ;\
|
||||
$(YQ) -i '.appVersion = "$(VERSION)" | .appVersion style="double"' $(CHART_NAME)/Chart.yaml ;\
|
||||
$(YQ) -i '.description = "$(CHART_DESCRIPTION)"' $(CHART_NAME)/Chart.yaml ;\
|
||||
|
||||
@echo "Generated chart metadata:"
|
||||
@cat charts/$(CHART_NAME)/Chart.yaml
|
||||
|
||||
@echo "== KUSTOMIZE (annotation) =="
|
||||
cd config/manager && $(KUSTOMIZE) edit set annotation helm.sh/chart:$(CHART_NAME)-$(VERSION)
|
||||
cd config/default && $(KUSTOMIZE) edit set annotation helm.sh/chart:$(CHART_NAME)-$(VERSION)
|
||||
|
||||
@echo "== SLICE =="
|
||||
@echo "== KUSTOMIZE: Generate resources and slice into templates =="
|
||||
# place in raw-files directory so they can be modified while they are valid yaml - as soon as they are in templates/,
|
||||
# wild cards pick up the actual templates, which are not real yaml and can't have yq run on them.
|
||||
$(KUSTOMIZE) build --load-restrictor LoadRestrictionsNone config/default | \
|
||||
$(KUBECTL_SLICE) --input-file=- \
|
||||
--output-dir=charts/$(CHART_NAME)/templates \
|
||||
--output-dir=charts/$(CHART_NAME)/raw-files \
|
||||
--sort-by-kind
|
||||
@echo "Helm Chart $(VERSION)" > charts/$(CHART_NAME)/templates/NOTES.txt
|
||||
|
||||
@echo "== GIT: Reset kustomize configs =="
|
||||
# reset kustomize configs following kustomize build
|
||||
git checkout -f config/.
|
||||
|
||||
@echo "== Build Templates and CRDS =="
|
||||
# Delete metadata.namespace, release namespace will be automatically inserted by helm
|
||||
for file in charts/$(CHART_NAME)/raw-files/*; do\
|
||||
$(YQ) -i 'del(.metadata.namespace)' $${file};\
|
||||
done
|
||||
# Correct namespace for rolebinding to be release namespace, this must be explicit
|
||||
for file in charts/$(CHART_NAME)/raw-files/*rolebinding*; do\
|
||||
$(YQ) -i '.subjects[0].namespace = "{{ .Release.Namespace }}"' $${file};\
|
||||
done
|
||||
# move all custom resource definitions to crds folder
|
||||
mkdir charts/$(CHART_NAME)/crds
|
||||
mv charts/$(CHART_NAME)/raw-files/customresourcedefinition*.yaml charts/$(CHART_NAME)/crds/.
|
||||
# remove any namespace definitions
|
||||
rm -f charts/$(CHART_NAME)/raw-files/namespace*.yaml
|
||||
# move remaining resources to helm templates
|
||||
mv charts/$(CHART_NAME)/raw-files/* charts/$(CHART_NAME)/templates/.
|
||||
# remove the raw-files folder
|
||||
rm -rf charts/$(CHART_NAME)/raw-files
|
||||
|
||||
# create and populate NOTES.txt
|
||||
@echo "AWX Operator installed with Helm Chart version $(VERSION)" > charts/$(CHART_NAME)/templates/NOTES.txt
|
||||
|
||||
@echo "Helm chart successfully configured for $(CHART_NAME) version $(VERSION)"
|
||||
|
||||
|
||||
.PHONY: helm-package
|
||||
@@ -300,6 +354,9 @@ helm-package: cr helm-chart
|
||||
@echo "== CHART RELEASER (package) =="
|
||||
$(CR) package ./charts/awx-operator
|
||||
|
||||
# List all tags oldest to newest.
|
||||
TAGS := $(shell git ls-remote --tags --sort=version:refname --refs -q | cut -d/ -f3)
|
||||
|
||||
# The actual release happens in ansible/helm-release.yml
|
||||
# until https://github.com/helm/chart-releaser/issues/122 happens
|
||||
.PHONY: helm-index
|
||||
@@ -308,6 +365,20 @@ helm-index: cr helm-chart
|
||||
git remote add httpsorigin "https://github.com/$(CHART_OWNER)/$(CHART_REPO).git"
|
||||
git fetch httpsorigin
|
||||
|
||||
# This step to workaround issues with old releases being dropped.
|
||||
# Until https://github.com/helm/chart-releaser/issues/133 happens
|
||||
@echo "== CHART FETCH previous releases =="
|
||||
# Download all old releases
|
||||
cd .cr-release-packages;\
|
||||
for tag in $(TAGS); do\
|
||||
dl_url="https://github.com/$${CHART_OWNER}/$${CHART_REPO}/releases/download/$${tag}/$${CHART_REPO}-$${tag}.tgz";\
|
||||
curl -RLOs -z "$${CHART_REPO}-$${tag}.tgz" --fail $${dl_url};\
|
||||
result=$$?;\
|
||||
if [ $${result} -eq 0 ]; then\
|
||||
echo "Downloaded $$dl_url";\
|
||||
fi;\
|
||||
done
|
||||
|
||||
@echo "== CHART RELEASER (index) =="
|
||||
$(CR) index \
|
||||
--owner "$(CHART_OWNER)" \
|
||||
|
||||
14
PROJECT
14
PROJECT
@@ -13,4 +13,18 @@ resources:
|
||||
group: awx
|
||||
kind: AWX
|
||||
version: v1beta1
|
||||
- api:
|
||||
crdVersion: v1
|
||||
namespaced: true
|
||||
domain: ansible.com
|
||||
group: awx
|
||||
kind: AWXBackup
|
||||
version: v1beta1
|
||||
- api:
|
||||
crdVersion: v1
|
||||
namespaced: true
|
||||
domain: ansible.com
|
||||
group: awx
|
||||
kind: AWXRestore
|
||||
version: v1beta1
|
||||
version: "3"
|
||||
|
||||
173
README.md
173
README.md
@@ -45,13 +45,18 @@ An [Ansible AWX](https://github.com/ansible/awx) operator for Kubernetes built w
|
||||
* [Session Cookie Secure Setting](#session-cookie-secure-setting)
|
||||
* [Extra Settings](#extra-settings)
|
||||
* [Configure no_log](#no-log)
|
||||
* [Auto Upgrade](#auto-upgrade)
|
||||
* [Upgrade of instances without auto upgrade](#upgrade-of-instances-without-auto-upgrade)
|
||||
* [Service Account](#service-account)
|
||||
* [Uninstall](#uninstall)
|
||||
* [Upgrading](#upgrading)
|
||||
* [Backup](#backup)
|
||||
* [v0.14.0](#v0140)
|
||||
* [Cluster-scope to Namespace-scope considerations](#cluster-scope-to-namespace-scope-considerations)
|
||||
* [Project is now based on v1.x of the operator-sdk project](#project-is-now-based-on-v1x-of-the-operator-sdk-project)
|
||||
* [Steps to upgrade](#steps-to-upgrade)
|
||||
* [Add Execution Nodes](#adding-execution-nodes)
|
||||
* [Custom Receptor CA](#custom-receptor-ca)
|
||||
* [Contributing](#contributing)
|
||||
* [Release Process](#release-process)
|
||||
* [Author](#author)
|
||||
@@ -192,8 +197,12 @@ metadata:
|
||||
name: awx-demo
|
||||
spec:
|
||||
service_type: nodeport
|
||||
# default nodeport_port is 30080
|
||||
nodeport_port: <nodeport_port>
|
||||
```
|
||||
|
||||
> It may make sense to create and specify your own secret key for your deployment so that if the k8s secret gets deleted, it can be re-created if needed. If it is not provided, one will be auto-generated, but cannot be recovered if lost. Read more [here](#secret-key-configuration).
|
||||
|
||||
Make sure to add this new file to the list of "resources" in your `kustomization.yaml` file:
|
||||
|
||||
```yaml
|
||||
@@ -234,13 +243,13 @@ awx-demo-service NodePort 10.109.40.38 <none> 80:31006/TCP 3m56
|
||||
Once deployed, the AWX instance will be accessible by running:
|
||||
|
||||
```
|
||||
$ minikube service awx-demo-service --url -n $NAMESPACE
|
||||
$ minikube service awx-demo-service --url
|
||||
```
|
||||
|
||||
By default, the admin user is `admin` and the password is available in the `<resourcename>-admin-password` secret. To retrieve the admin password, run:
|
||||
|
||||
```
|
||||
$ kubectl get secret awx-demo-admin-password -o jsonpath="{.data.password}" | base64 --decode
|
||||
$ kubectl get secret awx-demo-admin-password -o jsonpath="{.data.password}" | base64 --decode ; echo
|
||||
yDL2Cx5Za94g9MvBP6B73nzVLlmfgPjR
|
||||
```
|
||||
|
||||
@@ -253,6 +262,8 @@ For an example using the Nginx Controller in Minukube, don't miss our [demo vide
|
||||
|
||||
For those that wish to use [Helm](https://helm.sh/) to install the awx-operator to an existing K8s cluster:
|
||||
|
||||
The helm chart is generated from the `helm-chart` Makefile section using the starter files in `.helm/starter`. Consult [the documentation](.helm/starter/README.md) on how to customize the AWX resource with your own values.
|
||||
|
||||
```bash
|
||||
$ helm repo add awx-operator https://ansible.github.io/awx-operator/
|
||||
"awx-operator" has been added to your repositories
|
||||
@@ -266,7 +277,7 @@ $ helm search repo awx-operator
|
||||
NAME CHART VERSION APP VERSION DESCRIPTION
|
||||
awx-operator/awx-operator 0.17.1 0.17.1 A Helm chart for the AWX Operator
|
||||
|
||||
$ helm install my-awx-operator awx-operator/awx-operator
|
||||
$ helm install -n awx --create-namespace my-awx-operator awx-operator/awx-operator
|
||||
NAME: my-awx-operator
|
||||
LAST DEPLOYED: Thu Feb 17 22:09:05 2022
|
||||
NAMESPACE: default
|
||||
@@ -292,7 +303,7 @@ There are three variables that are customizable for the admin user account creat
|
||||
|
||||
If `admin_password_secret` is not provided, the operator will look for a secret named `<resourcename>-admin-password` for the admin password. If it is not present, the operator will generate a password and create a Secret from it named `<resourcename>-admin-password`.
|
||||
|
||||
To retrieve the admin password, run `kubectl get secret <resourcename>-admin-password -o jsonpath="{.data.password}" | base64 --decode`
|
||||
To retrieve the admin password, run `kubectl get secret <resourcename>-admin-password -o jsonpath="{.data.password}" | base64 --decode ; echo`
|
||||
|
||||
The secret that is expected to be passed should be formatted as follow:
|
||||
|
||||
@@ -308,6 +319,41 @@ stringData:
|
||||
```
|
||||
|
||||
|
||||
### Secret Key Configuration
|
||||
|
||||
This key is used to encrypt sensitive data in the database.
|
||||
|
||||
| Name | Description | Default |
|
||||
| ----------------- | ----------------------------------------------------- | ---------------- |
|
||||
| secret_key_secret | Secret that contains the symmetric key for encryption | Generated |
|
||||
|
||||
|
||||
> :warning: **secret_key_secret must be a Kubernetes secret and not your text clear secret value**.
|
||||
|
||||
If `secret_key_secret` is not provided, the operator will look for a secret named `<resourcename>-secret-key` for the secret key. If it is not present, the operator will generate a password and create a Secret from it named `<resourcename>-secret-key`. It is important to not delete this secret as it will be needed for upgrades and if the pods get scaled down at any point. If you are using a GitOps flow, you will want to pass a secret key secret.
|
||||
|
||||
The secret should be formatted as follow:
|
||||
|
||||
```yaml
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: Secret
|
||||
metadata:
|
||||
name: custom-awx-secret-key
|
||||
namespace: <target namespace>
|
||||
stringData:
|
||||
secret_key: supersecuresecretkey
|
||||
```
|
||||
|
||||
Then specify the secret name on the AWX spec:
|
||||
|
||||
```yaml
|
||||
---
|
||||
spec:
|
||||
...
|
||||
secret_key_secret: custom-awx-secret-key
|
||||
```
|
||||
|
||||
### Network and TLS Configuration
|
||||
|
||||
#### Service Type
|
||||
@@ -398,6 +444,7 @@ The following variables are customizable when `ingress_type=ingress`. The `ingre
|
||||
| ------------------- | ---------------------------------------- | --------------------------- |
|
||||
| ingress_annotations | Ingress annotations | Empty string |
|
||||
| ingress_tls_secret | Secret that contains the TLS information | Empty string |
|
||||
| ingress_class_name | Define the ingress class name | Cluster default |
|
||||
| hostname | Define the FQDN | {{ meta.name }}.example.com |
|
||||
| ingress_path | Define the ingress path to the service | / |
|
||||
| ingress_path_type | Define the type of the path (for LBs) | Prefix |
|
||||
@@ -434,6 +481,12 @@ spec:
|
||||
|
||||
### Database Configuration
|
||||
|
||||
#### Postgres Version
|
||||
|
||||
The default Postgres version for the version of AWX bundled with the latest version of the awx-operator is Postgres 13. You can find this default for a given version by at the default value for [_postgres_image_version](./roles/installer/defaults/main.yml#L138).
|
||||
|
||||
We only have coverage for the default version of Postgres. Newer versions of Postgres (14+) will likely work, but should only be configured as an external database. If your database is managed by the awx-operator (default if you don't specify a `postgres_configuration_secret`), then you should not override the default version as this may cause issues when awx-operator tries to upgrade your postgresql pod.
|
||||
|
||||
#### External PostgreSQL Service
|
||||
|
||||
To configure AWX to use an external database, the Custom Resource needs to know about the connection details. To do this, create a k8s secret with those connection details and specify the name of the secret as `postgres_configuration_secret` at the CR spec level.
|
||||
@@ -459,7 +512,7 @@ stringData:
|
||||
type: Opaque
|
||||
```
|
||||
|
||||
> Please ensure that the value for the variable `password` should _not_ contain single or double quotes (`'`, `"`) or backslashes (`\`) to avoid any issues during deployment, backup or restoration.
|
||||
> Please ensure that the value for the variable `password` should _not_ contain single or double quotes (`'`, `"`) or backslashes (`\`) to avoid any issues during deployment, [backup](https://github.com/ansible/awx-operator/tree/devel/roles/backup) or [restoration](https://github.com/ansible/awx-operator/tree/devel/roles/restore).
|
||||
|
||||
> It is possible to set a specific username, password, port, or database, but still have the database managed by the operator. In this case, when creating the postgres-configuration secret, the `type: managed` field should be added.
|
||||
|
||||
@@ -655,8 +708,8 @@ The ability to specify topologySpreadConstraints is also allowed through `topolo
|
||||
|
||||
| Name | Description | Default |
|
||||
| --------------------------- | ----------------------------------- | ------- |
|
||||
| postgres_image | Path of the image to pull | 12 |
|
||||
| postgres_image_version | Image version to pull | 12 |
|
||||
| postgres_image | Path of the image to pull | postgres |
|
||||
| postgres_image_version | Image version to pull | 13 |
|
||||
| node_selector | AWX pods' nodeSelector | '' |
|
||||
| topology_spread_constraints | AWX pods' topologySpreadConstraints | '' |
|
||||
| tolerations | AWX pods' tolerations | '' |
|
||||
@@ -741,7 +794,9 @@ To create the secrets, you can use the commands below:
|
||||
|
||||
#### Enabling LDAP Integration at AWX bootstrap
|
||||
|
||||
A sample of extra settings can be found as below:
|
||||
A sample of extra settings can be found as below. All possible options can be found here: https://django-auth-ldap.readthedocs.io/en/latest/reference.html#settings
|
||||
|
||||
> **NOTE:** These values are inserted into a Python file, so pay close attention to which values need quotes and which do not.
|
||||
|
||||
```yaml
|
||||
- setting: AUTH_LDAP_SERVER_URI
|
||||
@@ -758,6 +813,9 @@ A sample of extra settings can be found as below:
|
||||
- setting: AUTH_LDAP_GROUP_SEARCH
|
||||
value: 'LDAPSearch("OU=Groups,DC=abc,DC=com",ldap.SCOPE_SUBTREE,"(objectClass=group)",)'
|
||||
|
||||
- setting: AUTH_LDAP_GROUP_TYPE
|
||||
value: 'GroupOfNamesType(name_attr="cn")'
|
||||
|
||||
- setting: AUTH_LDAP_USER_ATTR_MAP
|
||||
value: '{"first_name": "givenName","last_name": "sn","email": "mail"}'
|
||||
|
||||
@@ -903,7 +961,7 @@ Example spec file for volumes and volume mounts
|
||||
|
||||
In order to register default execution environments from private registries, the Custom Resource needs to know about the pull credentials. Those credentials should be stored as a secret and either specified as `ee_pull_credentials_secret` at the CR spec level, or simply be present on the namespace under the name `<resourcename>-ee-pull-credentials` . Instance initialization will register a `Container registry` type credential on the deployed instance and assign it to the registered default execution environments.
|
||||
|
||||
The secret should be formated as follows:
|
||||
The secret should be formatted as follows:
|
||||
|
||||
```yaml
|
||||
---
|
||||
@@ -927,7 +985,7 @@ You can create `image_pull_secret`
|
||||
```
|
||||
kubectl create secret <resoucename>-cp-pull-credentials regcred --docker-server=<your-registry-server> --docker-username=<your-name> --docker-password=<your-pword> --docker-email=<your-email>
|
||||
```
|
||||
If you need more control (for example, to set a namespace or a label on the new secret) then you can customise the Secret before storing it
|
||||
If you need more control (for example, to set a namespace or a label on the new secret) then you can customize the Secret before storing it
|
||||
|
||||
Example spec file extra-config
|
||||
|
||||
@@ -1018,8 +1076,14 @@ Example configuration of `extra_settings` parameter
|
||||
|
||||
- setting: AUTH_LDAP_BIND_DN
|
||||
value: "cn=admin,dc=example,dc=com"
|
||||
|
||||
- setting: LOG_AGGREGATOR_LEVEL
|
||||
value: "'DEBUG'"
|
||||
```
|
||||
|
||||
Note for some settings, such as `LOG_AGGREGATOR_LEVEL`, the value may need double quotes.
|
||||
|
||||
```yaml
|
||||
#### No Log
|
||||
Configure no_log for tasks with no_log
|
||||
|
||||
@@ -1031,9 +1095,45 @@ Example configuration of `no_log` parameter
|
||||
|
||||
```yaml
|
||||
spec:
|
||||
no_log: 'true'
|
||||
no_log: true
|
||||
```
|
||||
|
||||
#### Auto upgrade
|
||||
With this parameter you can influence the behavior during an operator upgrade.
|
||||
If set to `true`, the operator will upgrade the specific instance directly.
|
||||
When the value is set to `false`, and we have a running deployment, the operator will not update the AWX instance.
|
||||
This can be useful when you have multiple AWX instances which you want to upgrade step by step instead of all at once.
|
||||
|
||||
|
||||
| Name | Description | Default |
|
||||
| -------------| ---------------------------------- | ------- |
|
||||
| auto_upgrade | Automatic upgrade of AWX instances | true |
|
||||
|
||||
Example configuration of `auto_upgrade` parameter
|
||||
|
||||
```yaml
|
||||
spec:
|
||||
auto_upgrade: true
|
||||
```
|
||||
|
||||
##### Upgrade of instances without auto upgrade
|
||||
|
||||
There are two ways to upgrade instances which are marked with the 'auto_upgrade: false' flag.
|
||||
|
||||
Changing flags:
|
||||
|
||||
- change the auto_upgrade flag on your AWX object to true
|
||||
- wait until the upgrade process of that instance is finished
|
||||
- change the auto_upgrade flag on your AWX object back to false
|
||||
|
||||
Delete the deployment:
|
||||
|
||||
- delete the deployment object of your AWX instance
|
||||
```
|
||||
$ kubectl -n awx delete deployment <yourInstanceName>
|
||||
```
|
||||
- wait until the instance gets redeployed
|
||||
|
||||
|
||||
#### Service Account
|
||||
|
||||
@@ -1063,12 +1163,31 @@ awx.awx.ansible.com "awx-demo" deleted
|
||||
|
||||
Deleting an AWX instance will remove all related deployments and statefulsets, however, persistent volumes and secrets will remain. To enforce secrets also getting removed, you can use `garbage_collect_secrets: true`.
|
||||
|
||||
**Note**: If you ever intend to recover an AWX from an existing database you will need a copy of the secrets in order to perform a successful recovery.
|
||||
|
||||
### Upgrading
|
||||
|
||||
To upgrade AWX, it is recommended to upgrade the awx-operator to the version that maps to the desired version of AWX. To find the version of AWX that will be installed by the awx-operator by default, check the version specified in the `image_version` variable in `roles/installer/defaults/main.yml` for that particular release.
|
||||
|
||||
Apply the awx-operator.yml for that release to upgrade the operator, and in turn also upgrade your AWX deployment.
|
||||
|
||||
#### Backup
|
||||
|
||||
The first part of any upgrade should be a backup. Note, there are secrets in the pod which work in conjunction with the database. Having just a database backup without the required secrets will not be sufficient for recovering from an issue when upgrading to a new version. See the [backup role documentation](https://github.com/ansible/awx-operator/tree/devel/roles/backup) for information on how to backup your database and secrets. In the event you need to recover the backup see the [restore role documentation](https://github.com/ansible/awx-operator/tree/devel/roles/restore).
|
||||
|
||||
#### PostgreSQL Upgrade Considerations
|
||||
|
||||
If there is a PostgreSQL major version upgrade, after the data directory on the PVC is migrated to the new version, the old PVC is kept by default.
|
||||
This provides the ability to roll back if needed, but can take up extra storage space in your cluster unnecessarily. You can configure it to be deleted automatically
|
||||
after a successful upgrade by setting the following variable on the AWX spec.
|
||||
|
||||
|
||||
```yaml
|
||||
spec:
|
||||
postgres_keep_pvc_after_upgrade: False
|
||||
```
|
||||
|
||||
|
||||
#### v0.14.0
|
||||
|
||||
##### Cluster-scope to Namespace-scope considerations
|
||||
@@ -1095,6 +1214,33 @@ Then install the new AWX Operator by following the instructions in [Basic Instal
|
||||
|
||||
Once the new AWX Operator is up and running, your AWX deployment will also be upgraded.
|
||||
|
||||
### Adding Execution Nodes
|
||||
Starting with AWX Operator v0.30.0 and AWX v21.7.0, standalone execution nodes can be added to your deployments.
|
||||
See [AWX execution nodes docs](https://github.com/ansible/awx/blob/devel/docs/execution_nodes.md) for information about this feature.
|
||||
|
||||
#### Custom Receptor CA
|
||||
The control nodes on the K8S cluster will communicate with execution nodes via mutual TLS TCP connections, running via Receptor.
|
||||
Execution nodes will verify incoming connections by ensuring the x509 certificate was issued by a trusted Certificate Authority (CA).
|
||||
|
||||
A user may wish to provide their own CA for this validation. If no CA is provided, AWX Operator will automatically generate one using OpenSSL.
|
||||
|
||||
Given custom `ca.crt` and `ca.key` stored locally, run the following,
|
||||
|
||||
```bash
|
||||
kubectl create secret tls awx-demo-receptor-ca \
|
||||
--cert=/path/to/ca.crt --key=/path/to/ca.key
|
||||
```
|
||||
|
||||
The secret should be named `{AWX Custom Resource name}-receptor-ca`. In the above the AWX CR name is "awx-demo". Please replace "awx-demo" with your AWX Custom Resource name.
|
||||
|
||||
If this secret is created after AWX is deployed, run the following to restart the deployment,
|
||||
|
||||
```bash
|
||||
kubectl rollout restart deployment awx-demo
|
||||
```
|
||||
|
||||
**Important Note**, changing the receptor CA will break connections to any existing execution nodes. These nodes will enter an `unavailable` state, and jobs will not be able to run on them. Users will need to download and re-run the install bundle for each execution node. This will replace the TLS certificate files with those signed by the new CA. The execution nodes should then appear in a `ready` state after a few minutes.
|
||||
|
||||
## Contributing
|
||||
|
||||
Please visit [our contributing guidelines](https://github.com/ansible/awx-operator/blob/devel/CONTRIBUTING.md).
|
||||
@@ -1102,7 +1248,7 @@ Please visit [our contributing guidelines](https://github.com/ansible/awx-operat
|
||||
|
||||
## Release Process
|
||||
|
||||
The first step is to create a draft release. Typically this will happen in the [Stage Release](https://github.com/ansible/awx/blob/devel/.github/workflows/stage.yml) workflow for AWX and you dont need to do it as a separate step.
|
||||
The first step is to create a draft release. Typically this will happen in the [Stage Release](https://github.com/ansible/awx/blob/devel/.github/workflows/stage.yml) workflow for AWX and you don't need to do it as a separate step.
|
||||
|
||||
If you need to do an independent release of the operator, you can run the [Stage Release](https://github.com/ansible/awx-operator/blob/devel/.github/workflows/stage.yml) in the awx-operator repo. Both of these workflows will run smoke tests, so there is no need to do this manually.
|
||||
|
||||
@@ -1121,8 +1267,7 @@ We ask all of our community members and contributors to adhere to the [Ansible c
|
||||
|
||||
## Get Involved
|
||||
|
||||
We welcome your feedback and ideas. The AWX operator uses the same mailing list and IRC chanel as AWX itself. Here's how to reach us with feedback and questions:
|
||||
We welcome your feedback and ideas. The AWX operator uses the same mailing list and IRC channel as AWX itself. Here's how to reach us with feedback and questions:
|
||||
|
||||
- Join the `#ansible-awx` channel on irc.libera.chat
|
||||
- Join the [mailing list](https://groups.google.com/forum/#!forum/awx-project)
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
- name: Build and package helm chart
|
||||
command: |
|
||||
make helm-chart helm-package
|
||||
make helm-package
|
||||
environment:
|
||||
VERSION: "{{ tag }}"
|
||||
IMAGE_TAG_BASE: "{{ operator_image }}"
|
||||
|
||||
121
config/crd/bases/awx.ansible.com_awxbackups.yaml
Normal file
121
config/crd/bases/awx.ansible.com_awxbackups.yaml
Normal file
@@ -0,0 +1,121 @@
|
||||
---
|
||||
apiVersion: apiextensions.k8s.io/v1
|
||||
kind: CustomResourceDefinition
|
||||
metadata:
|
||||
name: awxbackups.awx.ansible.com
|
||||
spec:
|
||||
group: awx.ansible.com
|
||||
names:
|
||||
kind: AWXBackup
|
||||
listKind: AWXBackupList
|
||||
plural: awxbackups
|
||||
singular: awxbackup
|
||||
scope: Namespaced
|
||||
versions:
|
||||
- name: v1beta1
|
||||
served: true
|
||||
storage: true
|
||||
subresources:
|
||||
status: {}
|
||||
schema:
|
||||
openAPIV3Schema:
|
||||
type: object
|
||||
description: Schema validation for the AWXBackup CRD
|
||||
properties:
|
||||
apiVersion:
|
||||
description: 'APIVersion defines the versioned schema of this representation
|
||||
of an object. Servers should convert recognized schemas to the latest
|
||||
internal value, and may reject unrecognized values.
|
||||
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
|
||||
type: string
|
||||
kind:
|
||||
description: 'Kind is a string value representing the REST resource this
|
||||
object represents. Servers may infer this from the endpoint the client
|
||||
submits requests to. Cannot be updated. In CamelCase.
|
||||
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
|
||||
type: string
|
||||
metadata:
|
||||
type: object
|
||||
spec:
|
||||
type: object
|
||||
x-kubernetes-preserve-unknown-fields: true
|
||||
required:
|
||||
- deployment_name
|
||||
properties:
|
||||
deployment_name:
|
||||
description: Name of the deployment to be backed up
|
||||
type: string
|
||||
backup_pvc:
|
||||
description: Name of the backup PVC
|
||||
type: string
|
||||
backup_pvc_namespace:
|
||||
description: (Deprecated) Namespace the PVC is in
|
||||
type: string
|
||||
backup_storage_requirements:
|
||||
description: Storage requirements for backup PVC (may be similar to existing postgres PVC backing up from)
|
||||
type: string
|
||||
backup_resource_requirements:
|
||||
description: Resource requirements for the management pod used to create a backup
|
||||
properties:
|
||||
requests:
|
||||
properties:
|
||||
cpu:
|
||||
type: string
|
||||
memory:
|
||||
type: string
|
||||
type: object
|
||||
limits:
|
||||
properties:
|
||||
cpu:
|
||||
type: string
|
||||
memory:
|
||||
type: string
|
||||
type: object
|
||||
type: object
|
||||
backup_storage_class:
|
||||
description: Storage class to use when creating PVC for backup
|
||||
type: string
|
||||
clean_backup_on_delete:
|
||||
description: Flag to indicate if backup should be deleted on PVC if AWXBackup object is deleted
|
||||
type: boolean
|
||||
postgres_label_selector:
|
||||
description: Label selector used to identify postgres pod for backing up data
|
||||
type: string
|
||||
postgres_image:
|
||||
description: Registry path to the PostgreSQL container to use
|
||||
type: string
|
||||
postgres_image_version:
|
||||
description: PostgreSQL container image version to use
|
||||
type: string
|
||||
no_log:
|
||||
description: Configure no_log for no_log tasks
|
||||
type: boolean
|
||||
default: true
|
||||
set_self_labels:
|
||||
description: Maintain some of the recommended `app.kubernetes.io/*` labels on the resource (self)
|
||||
type: boolean
|
||||
default: true
|
||||
status:
|
||||
type: object
|
||||
x-kubernetes-preserve-unknown-fields: true
|
||||
properties:
|
||||
conditions:
|
||||
description: The resulting conditions when a Service Telemetry is instantiated
|
||||
items:
|
||||
properties:
|
||||
lastTransitionTime:
|
||||
type: string
|
||||
reason:
|
||||
type: string
|
||||
status:
|
||||
type: string
|
||||
type:
|
||||
type: string
|
||||
type: object
|
||||
type: array
|
||||
backupDirectory:
|
||||
description: Backup directory name on the specified pvc
|
||||
type: string
|
||||
backupClaim:
|
||||
description: Backup persistent volume claim
|
||||
type: string
|
||||
123
config/crd/bases/awx.ansible.com_awxrestores.yaml
Normal file
123
config/crd/bases/awx.ansible.com_awxrestores.yaml
Normal file
@@ -0,0 +1,123 @@
|
||||
---
|
||||
apiVersion: apiextensions.k8s.io/v1
|
||||
kind: CustomResourceDefinition
|
||||
metadata:
|
||||
name: awxrestores.awx.ansible.com
|
||||
spec:
|
||||
group: awx.ansible.com
|
||||
names:
|
||||
kind: AWXRestore
|
||||
listKind: AWXRestoreList
|
||||
plural: awxrestores
|
||||
singular: awxrestore
|
||||
scope: Namespaced
|
||||
versions:
|
||||
- name: v1beta1
|
||||
served: true
|
||||
storage: true
|
||||
subresources:
|
||||
status: {}
|
||||
schema:
|
||||
openAPIV3Schema:
|
||||
type: object
|
||||
description: Schema validation for the AWXRestore CRD
|
||||
properties:
|
||||
apiVersion:
|
||||
description: 'APIVersion defines the versioned schema of this representation
|
||||
of an object. Servers should convert recognized schemas to the latest
|
||||
internal value, and may reject unrecognized values.
|
||||
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
|
||||
type: string
|
||||
kind:
|
||||
description: 'Kind is a string value representing the REST resource this
|
||||
object represents. Servers may infer this from the endpoint the client
|
||||
submits requests to. Cannot be updated. In CamelCase.
|
||||
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
|
||||
type: string
|
||||
metadata:
|
||||
type: object
|
||||
spec:
|
||||
type: object
|
||||
x-kubernetes-preserve-unknown-fields: true
|
||||
properties:
|
||||
backup_source:
|
||||
description: Backup source
|
||||
type: string
|
||||
enum:
|
||||
- CR
|
||||
- PVC
|
||||
deployment_name:
|
||||
description: Name of the restored deployment. This should be different from the original deployment name
|
||||
if the original deployment still exists.
|
||||
type: string
|
||||
cluster_name:
|
||||
description: Cluster name
|
||||
type: string
|
||||
backup_name:
|
||||
description: AWXBackup object name
|
||||
type: string
|
||||
backup_pvc:
|
||||
description: Name of the PVC to be restored from, set as a status found on the awxbackup object (backupClaim)
|
||||
type: string
|
||||
backup_pvc_namespace:
|
||||
description: (Deprecated) Namespace the PVC is in
|
||||
type: string
|
||||
backup_dir:
|
||||
description: Backup directory name, set as a status found on the awxbackup object (backupDirectory)
|
||||
type: string
|
||||
restore_resource_requirements:
|
||||
description: Resource requirements for the management pod that restores AWX from a backup
|
||||
properties:
|
||||
requests:
|
||||
properties:
|
||||
cpu:
|
||||
type: string
|
||||
memory:
|
||||
type: string
|
||||
type: object
|
||||
limits:
|
||||
properties:
|
||||
cpu:
|
||||
type: string
|
||||
memory:
|
||||
type: string
|
||||
type: object
|
||||
type: object
|
||||
postgres_label_selector:
|
||||
description: Label selector used to identify postgres pod for backing up data
|
||||
type: string
|
||||
postgres_image:
|
||||
description: Registry path to the PostgreSQL container to use
|
||||
type: string
|
||||
postgres_image_version:
|
||||
description: PostgreSQL container image version to use
|
||||
type: string
|
||||
no_log:
|
||||
description: Configure no_log for no_log tasks
|
||||
type: boolean
|
||||
default: true
|
||||
set_self_labels:
|
||||
description: Maintain some of the recommended `app.kubernetes.io/*` labels on the resource (self)
|
||||
type: boolean
|
||||
default: true
|
||||
status:
|
||||
type: object
|
||||
x-kubernetes-preserve-unknown-fields: true
|
||||
properties:
|
||||
conditions:
|
||||
description: The resulting conditions when a Service Telemetry is instantiated
|
||||
items:
|
||||
properties:
|
||||
lastTransitionTime:
|
||||
type: string
|
||||
reason:
|
||||
type: string
|
||||
status:
|
||||
type: string
|
||||
type:
|
||||
type: string
|
||||
type: object
|
||||
type: array
|
||||
restoreComplete:
|
||||
description: Restore process complete
|
||||
type: boolean
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,80 +0,0 @@
|
||||
---
|
||||
apiVersion: apiextensions.k8s.io/v1
|
||||
kind: CustomResourceDefinition
|
||||
metadata:
|
||||
name: awxbackups.awx.ansible.com
|
||||
spec:
|
||||
group: awx.ansible.com
|
||||
names:
|
||||
kind: AWXBackup
|
||||
listKind: AWXBackupList
|
||||
plural: awxbackups
|
||||
singular: awxbackup
|
||||
scope: Namespaced
|
||||
versions:
|
||||
- name: v1beta1
|
||||
served: true
|
||||
storage: true
|
||||
subresources:
|
||||
status: {}
|
||||
schema:
|
||||
openAPIV3Schema:
|
||||
type: object
|
||||
x-kubernetes-preserve-unknown-fields: true
|
||||
description: Schema validation for the AWXBackup CRD
|
||||
properties:
|
||||
spec:
|
||||
type: object
|
||||
required:
|
||||
- deployment_name
|
||||
properties:
|
||||
deployment_name:
|
||||
description: Name of the deployment to be backed up
|
||||
type: string
|
||||
backup_pvc:
|
||||
description: Name of the PVC to be used for storing the backup
|
||||
type: string
|
||||
backup_pvc_namespace:
|
||||
description: Namespace the PVC is in
|
||||
type: string
|
||||
backup_storage_requirements:
|
||||
description: Storage requirements for the PostgreSQL container
|
||||
type: string
|
||||
backup_storage_class:
|
||||
description: Storage class to use when creating PVC for backup
|
||||
type: string
|
||||
postgres_label_selector:
|
||||
description: Label selector used to identify postgres pod for backing up data
|
||||
type: string
|
||||
postgres_image:
|
||||
description: Registry path to the PostgreSQL container to use
|
||||
type: string
|
||||
postgres_image_version:
|
||||
description: PostgreSQL container image version to use
|
||||
type: string
|
||||
no_log:
|
||||
description: Configure no_log for no_log tasks
|
||||
type: string
|
||||
status:
|
||||
type: object
|
||||
properties:
|
||||
conditions:
|
||||
description: The resulting conditions when a Service Telemetry is instantiated
|
||||
items:
|
||||
properties:
|
||||
lastTransitionTime:
|
||||
type: string
|
||||
reason:
|
||||
type: string
|
||||
status:
|
||||
type: string
|
||||
type:
|
||||
type: string
|
||||
type: object
|
||||
type: array
|
||||
backupDirectory:
|
||||
description: Backup directory name on the specified pvc
|
||||
type: string
|
||||
backupClaim:
|
||||
description: Backup persistent volume claim
|
||||
type: string
|
||||
@@ -1,81 +0,0 @@
|
||||
---
|
||||
apiVersion: apiextensions.k8s.io/v1
|
||||
kind: CustomResourceDefinition
|
||||
metadata:
|
||||
name: awxrestores.awx.ansible.com
|
||||
spec:
|
||||
group: awx.ansible.com
|
||||
names:
|
||||
kind: AWXRestore
|
||||
listKind: AWXRestoreList
|
||||
plural: awxrestores
|
||||
singular: awxrestore
|
||||
scope: Namespaced
|
||||
versions:
|
||||
- name: v1beta1
|
||||
served: true
|
||||
storage: true
|
||||
subresources:
|
||||
status: {}
|
||||
schema:
|
||||
openAPIV3Schema:
|
||||
type: object
|
||||
x-kubernetes-preserve-unknown-fields: true
|
||||
description: Schema validation for the AWXRestore CRD
|
||||
properties:
|
||||
spec:
|
||||
type: object
|
||||
properties:
|
||||
backup_source:
|
||||
description: Backup source
|
||||
type: string
|
||||
enum:
|
||||
- CR
|
||||
- PVC
|
||||
deployment_name:
|
||||
description: Name of the deployment to be restored to
|
||||
type: string
|
||||
backup_name:
|
||||
description: AWXBackup object name
|
||||
type: string
|
||||
backup_pvc:
|
||||
description: Name of the PVC to be restored from, set as a status found on the awxbackup object (backupClaim)
|
||||
type: string
|
||||
backup_pvc_namespace:
|
||||
description: Namespace the PVC is in
|
||||
type: string
|
||||
backup_dir:
|
||||
description: Backup directory name, set as a status found on the awxbackup object (backupDirectory)
|
||||
type: string
|
||||
postgres_label_selector:
|
||||
description: Label selector used to identify postgres pod for backing up data
|
||||
type: string
|
||||
postgres_image:
|
||||
description: Registry path to the PostgreSQL container to use
|
||||
type: string
|
||||
postgres_image_version:
|
||||
description: PostgreSQL container image version to use
|
||||
type: string
|
||||
no_log:
|
||||
description: Configure no_log for no_log tasks
|
||||
type: string
|
||||
status:
|
||||
type: object
|
||||
properties:
|
||||
conditions:
|
||||
description: The resulting conditions when a Service Telemetry is instantiated
|
||||
items:
|
||||
properties:
|
||||
lastTransitionTime:
|
||||
type: string
|
||||
reason:
|
||||
type: string
|
||||
status:
|
||||
type: string
|
||||
type:
|
||||
type: string
|
||||
type: object
|
||||
type: array
|
||||
restoreComplete:
|
||||
description: Restore process complete
|
||||
type: boolean
|
||||
@@ -1,9 +1,8 @@
|
||||
---
|
||||
# This kustomization.yaml is not intended to be run by itself,
|
||||
# since it depends on service name and namespace that are out of this kustomize package.
|
||||
# It should be run by config/default
|
||||
resources:
|
||||
- bases/awx.ansible.com_awxs.yaml
|
||||
- bases/awxbackup.ansible.com_awxbackups.yaml
|
||||
- bases/awxrestore.ansible.com_awxrestores.yaml
|
||||
# +kubebuilder:scaffold:crdkustomizeresource
|
||||
- bases/awx.ansible.com_awxs.yaml
|
||||
- bases/awx.ansible.com_awxbackups.yaml
|
||||
- bases/awx.ansible.com_awxrestores.yaml
|
||||
#+kubebuilder:scaffold:crdkustomizeresource
|
||||
|
||||
@@ -1,24 +1,32 @@
|
||||
# Adds namespace to all resources.
|
||||
namespace: awx
|
||||
|
||||
# Value of this field is prepended to the
|
||||
# names of all resources, e.g. a deployment named
|
||||
# "wordpress" becomes "alices-wordpress".
|
||||
# Note that it should also match with the prefix (text before '-') of the namespace
|
||||
# field above.
|
||||
namePrefix: awx-operator-
|
||||
|
||||
# Labels to add to all resources and selectors.
|
||||
# commonLabels:
|
||||
# someName: someValue
|
||||
# [PROMETHEUS] To enable prometheus monitor, uncomment all sections with 'PROMETHEUS'.
|
||||
# - ../prometheus
|
||||
# Protect the /metrics endpoint by putting it behind auth.
|
||||
# If you want your controller-manager to expose the /metrics
|
||||
# endpoint w/o any authn/z, please comment the following line.
|
||||
patchesStrategicMerge:
|
||||
- manager_auth_proxy_patch.yaml
|
||||
apiVersion: kustomize.config.k8s.io/v1beta1
|
||||
kind: Kustomization
|
||||
#labels:
|
||||
#- includeSelectors: true
|
||||
# pairs:
|
||||
# someName: someValue
|
||||
|
||||
resources:
|
||||
- ../crd
|
||||
- ../rbac
|
||||
- ../manager
|
||||
# [PROMETHEUS] To enable prometheus monitor, uncomment all sections with 'PROMETHEUS'.
|
||||
#- ../prometheus
|
||||
|
||||
patchesStrategicMerge:
|
||||
# Protect the /metrics endpoint by putting it behind auth.
|
||||
# If you want your controller-manager to expose the /metrics
|
||||
# endpoint w/o any authn/z, please comment the following line.
|
||||
- manager_auth_proxy_patch.yaml
|
||||
|
||||
# Mount the controller config file for loading manager configurations
|
||||
# through a ComponentConfig type
|
||||
#- manager_config_patch.yaml
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
---
|
||||
# This patch inject a sidecar container which is a HTTP proxy for the
|
||||
# controller manager, it performs RBAC authorization against the Kubernetes API using SubjectAccessReviews.
|
||||
apiVersion: apps/v1
|
||||
@@ -10,20 +9,33 @@ spec:
|
||||
template:
|
||||
spec:
|
||||
containers:
|
||||
- name: kube-rbac-proxy
|
||||
image: gcr.io/kubebuilder/kube-rbac-proxy:v0.8.0
|
||||
args:
|
||||
- "--secure-listen-address=0.0.0.0:8443"
|
||||
- "--upstream=http://127.0.0.1:8080/"
|
||||
- "--logtostderr=true"
|
||||
- "--v=10"
|
||||
ports:
|
||||
- containerPort: 8443
|
||||
protocol: TCP
|
||||
name: https
|
||||
- name: awx-manager
|
||||
args:
|
||||
- "--health-probe-bind-address=:6789"
|
||||
- "--metrics-bind-address=127.0.0.1:8080"
|
||||
- "--leader-elect"
|
||||
- "--leader-election-id=awx-operator"
|
||||
- name: kube-rbac-proxy
|
||||
securityContext:
|
||||
allowPrivilegeEscalation: false
|
||||
# TODO(user): uncomment for common cases that do not require escalating privileges
|
||||
# capabilities:
|
||||
# drop:
|
||||
# - "ALL"
|
||||
image: gcr.io/kubebuilder/kube-rbac-proxy:v0.13.0
|
||||
args:
|
||||
- "--secure-listen-address=0.0.0.0:8443"
|
||||
- "--upstream=http://127.0.0.1:8080/"
|
||||
- "--logtostderr=true"
|
||||
- "--v=0"
|
||||
ports:
|
||||
- containerPort: 8443
|
||||
protocol: TCP
|
||||
name: https
|
||||
resources:
|
||||
limits:
|
||||
cpu: 500m
|
||||
memory: 128Mi
|
||||
requests:
|
||||
cpu: 5m
|
||||
memory: 64Mi
|
||||
- name: awx-manager
|
||||
args:
|
||||
- "--health-probe-bind-address=:6789"
|
||||
- "--metrics-bind-address=127.0.0.1:8080"
|
||||
- "--leader-elect"
|
||||
- "--leader-election-id=awx-operator"
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
---
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
@@ -8,14 +7,14 @@ spec:
|
||||
template:
|
||||
spec:
|
||||
containers:
|
||||
- name: awx-manager
|
||||
args:
|
||||
- "--config=controller_manager_config.yaml"
|
||||
volumeMounts:
|
||||
- name: awx-manager-config
|
||||
mountPath: /controller_manager_config.yaml
|
||||
subPath: controller_manager_config.yaml
|
||||
volumes:
|
||||
- name: awx-manager
|
||||
args:
|
||||
- "--config=controller_manager_config.yaml"
|
||||
volumeMounts:
|
||||
- name: awx-manager-config
|
||||
configMap:
|
||||
name: awx-manager-config
|
||||
mountPath: /controller_manager_config.yaml
|
||||
subPath: controller_manager_config.yaml
|
||||
volumes:
|
||||
- name: awx-manager-config
|
||||
configMap:
|
||||
name: awx-manager-config
|
||||
|
||||
@@ -1,10 +1,20 @@
|
||||
---
|
||||
apiVersion: controller-runtime.sigs.k8s.io/v1beta1
|
||||
apiVersion: controller-runtime.sigs.k8s.io/v1alpha1
|
||||
kind: ControllerManagerConfig
|
||||
health:
|
||||
healthProbeBindAddress: :6789
|
||||
metrics:
|
||||
bindAddress: 127.0.0.1:8080
|
||||
|
||||
leaderElection:
|
||||
leaderElect: true
|
||||
resourceName: 811c9dc5.ansible.com
|
||||
# leaderElectionReleaseOnCancel defines if the leader should step down volume
|
||||
# when the Manager ends. This requires the binary to immediately end when the
|
||||
# Manager is stopped, otherwise, this setting is unsafe. Setting this significantly
|
||||
# speeds up voluntary leader transitions as the new leader don't have to wait
|
||||
# LeaseDuration time first.
|
||||
# In the default scaffold provided, the program ends immediately after
|
||||
# the manager stops, so would be fine to enable this option. However,
|
||||
# if you are doing or is intended to do any operation such as perform cleanups
|
||||
# after the manager stops then its usage might be unsafe.
|
||||
# leaderElectionReleaseOnCancel: true
|
||||
|
||||
@@ -1,11 +1,14 @@
|
||||
resources:
|
||||
- manager.yaml
|
||||
|
||||
generatorOptions:
|
||||
disableNameSuffixHash: true
|
||||
|
||||
configMapGenerator:
|
||||
- files:
|
||||
- name: awx-manager-config
|
||||
files:
|
||||
- controller_manager_config.yaml
|
||||
name: awx-manager-config
|
||||
|
||||
apiVersion: kustomize.config.k8s.io/v1beta1
|
||||
kind: Kustomization
|
||||
images:
|
||||
|
||||
@@ -20,41 +20,62 @@ spec:
|
||||
replicas: 1
|
||||
template:
|
||||
metadata:
|
||||
annotations:
|
||||
kubectl.kubernetes.io/default-container: awx-manager
|
||||
labels:
|
||||
control-plane: controller-manager
|
||||
spec:
|
||||
securityContext:
|
||||
runAsNonRoot: true
|
||||
# For common cases that do not require escalating privileges
|
||||
# it is recommended to ensure that all your Pods/Containers are restrictive.
|
||||
# More info: https://kubernetes.io/docs/concepts/security/pod-security-standards/#restricted
|
||||
# Please uncomment the following code if your project does NOT have to work on old Kubernetes
|
||||
# versions < 1.19 or on vendors versions which do NOT support this field by default (i.e. Openshift < 4.11 ).
|
||||
# seccompProfile:
|
||||
# type: RuntimeDefault
|
||||
containers:
|
||||
- args:
|
||||
- --leader-elect
|
||||
- --leader-election-id=awx-operator
|
||||
image: controller:latest
|
||||
name: awx-manager
|
||||
env:
|
||||
- name: ANSIBLE_GATHERING
|
||||
value: explicit
|
||||
- name: ANSIBLE_DEBUG_LOGS
|
||||
value: 'false'
|
||||
- name: WATCH_NAMESPACE
|
||||
valueFrom:
|
||||
fieldRef:
|
||||
fieldPath: metadata.namespace
|
||||
securityContext:
|
||||
allowPrivilegeEscalation: false
|
||||
livenessProbe:
|
||||
httpGet:
|
||||
path: /healthz
|
||||
port: 6789
|
||||
initialDelaySeconds: 15
|
||||
periodSeconds: 20
|
||||
readinessProbe:
|
||||
httpGet:
|
||||
path: /readyz
|
||||
port: 6789
|
||||
initialDelaySeconds: 5
|
||||
periodSeconds: 10
|
||||
- args:
|
||||
- --leader-elect
|
||||
- --leader-election-id=awx-operator
|
||||
image: controller:latest
|
||||
name: awx-manager
|
||||
env:
|
||||
- name: ANSIBLE_GATHERING
|
||||
value: explicit
|
||||
- name: ANSIBLE_DEBUG_LOGS
|
||||
value: 'false'
|
||||
- name: WATCH_NAMESPACE
|
||||
valueFrom:
|
||||
fieldRef:
|
||||
fieldPath: metadata.namespace
|
||||
securityContext:
|
||||
allowPrivilegeEscalation: false
|
||||
# TODO(user): uncomment for common cases that do not require escalating privileges
|
||||
capabilities:
|
||||
drop:
|
||||
- "ALL"
|
||||
livenessProbe:
|
||||
httpGet:
|
||||
path: /healthz
|
||||
port: 6789
|
||||
initialDelaySeconds: 15
|
||||
periodSeconds: 20
|
||||
readinessProbe:
|
||||
httpGet:
|
||||
path: /readyz
|
||||
port: 6789
|
||||
initialDelaySeconds: 5
|
||||
periodSeconds: 10
|
||||
# More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/
|
||||
resources:
|
||||
requests:
|
||||
memory: "32Mi"
|
||||
cpu: "50m"
|
||||
limits:
|
||||
memory: "4096Mi"
|
||||
cpu: "2000m"
|
||||
serviceAccountName: controller-manager
|
||||
imagePullSecrets:
|
||||
- name: redhat-operators-pull-secret
|
||||
- name: redhat-operators-pull-secret
|
||||
terminationGracePeriodSeconds: 10
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -1,8 +1,7 @@
|
||||
---
|
||||
# These resources constitute the fully configured set of manifests
|
||||
# used to generate the 'manifests/' directory in a bundle.
|
||||
resources:
|
||||
- bases/awx-operator.clusterserviceversion.yaml
|
||||
- ../default
|
||||
- ../samples
|
||||
- ../scorecard
|
||||
- bases/awx-operator.clusterserviceversion.yaml
|
||||
- ../default
|
||||
- ../samples
|
||||
- ../scorecard
|
||||
|
||||
@@ -1,3 +1,2 @@
|
||||
---
|
||||
resources:
|
||||
- monitor.yaml
|
||||
- monitor.yaml
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
---
|
||||
# Prometheus Monitor Service (Metrics)
|
||||
apiVersion: monitoring.coreos.com/v1
|
||||
kind: ServiceMonitor
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
---
|
||||
apiVersion: rbac.authorization.k8s.io/v1
|
||||
kind: ClusterRole
|
||||
metadata:
|
||||
name: metrics-reader
|
||||
rules:
|
||||
- nonResourceURLs:
|
||||
- "/metrics"
|
||||
verbs:
|
||||
- get
|
||||
- nonResourceURLs:
|
||||
- "/metrics"
|
||||
verbs:
|
||||
- get
|
||||
|
||||
@@ -1,18 +1,17 @@
|
||||
---
|
||||
apiVersion: rbac.authorization.k8s.io/v1
|
||||
kind: ClusterRole
|
||||
metadata:
|
||||
name: proxy-role
|
||||
rules:
|
||||
- apiGroups:
|
||||
- authentication.k8s.io
|
||||
resources:
|
||||
- tokenreviews
|
||||
verbs:
|
||||
- create
|
||||
- apiGroups:
|
||||
- authorization.k8s.io
|
||||
resources:
|
||||
- subjectaccessreviews
|
||||
verbs:
|
||||
- create
|
||||
- apiGroups:
|
||||
- authentication.k8s.io
|
||||
resources:
|
||||
- tokenreviews
|
||||
verbs:
|
||||
- create
|
||||
- apiGroups:
|
||||
- authorization.k8s.io
|
||||
resources:
|
||||
- subjectaccessreviews
|
||||
verbs:
|
||||
- create
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
---
|
||||
apiVersion: rbac.authorization.k8s.io/v1
|
||||
kind: ClusterRoleBinding
|
||||
metadata:
|
||||
@@ -8,6 +7,6 @@ roleRef:
|
||||
kind: ClusterRole
|
||||
name: proxy-role
|
||||
subjects:
|
||||
- kind: ServiceAccount
|
||||
name: controller-manager
|
||||
namespace: system
|
||||
- kind: ServiceAccount
|
||||
name: controller-manager
|
||||
namespace: system
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
@@ -8,9 +7,9 @@ metadata:
|
||||
namespace: system
|
||||
spec:
|
||||
ports:
|
||||
- name: https
|
||||
port: 8443
|
||||
protocol: TCP
|
||||
targetPort: https
|
||||
- name: https
|
||||
port: 8443
|
||||
protocol: TCP
|
||||
targetPort: https
|
||||
selector:
|
||||
control-plane: controller-manager
|
||||
|
||||
@@ -1,25 +1,24 @@
|
||||
---
|
||||
# permissions for end users to edit awxs.
|
||||
apiVersion: rbac.authorization.k8s.io/v1
|
||||
kind: ClusterRole
|
||||
metadata:
|
||||
name: awx-editor-role
|
||||
rules:
|
||||
- apiGroups:
|
||||
- awx.ansible.com
|
||||
resources:
|
||||
- awxs
|
||||
verbs:
|
||||
- create
|
||||
- delete
|
||||
- get
|
||||
- list
|
||||
- patch
|
||||
- update
|
||||
- watch
|
||||
- apiGroups:
|
||||
- awx.ansible.com
|
||||
resources:
|
||||
- awxs/status
|
||||
verbs:
|
||||
- get
|
||||
- apiGroups:
|
||||
- awx.ansible.com
|
||||
resources:
|
||||
- awxs
|
||||
verbs:
|
||||
- create
|
||||
- delete
|
||||
- get
|
||||
- list
|
||||
- patch
|
||||
- update
|
||||
- watch
|
||||
- apiGroups:
|
||||
- awx.ansible.com
|
||||
resources:
|
||||
- awxs/status
|
||||
verbs:
|
||||
- get
|
||||
|
||||
@@ -1,21 +1,20 @@
|
||||
---
|
||||
# permissions for end users to view awxs.
|
||||
apiVersion: rbac.authorization.k8s.io/v1
|
||||
kind: ClusterRole
|
||||
metadata:
|
||||
name: awx-viewer-role
|
||||
rules:
|
||||
- apiGroups:
|
||||
- awx.ansible.com
|
||||
resources:
|
||||
- awxs
|
||||
verbs:
|
||||
- get
|
||||
- list
|
||||
- watch
|
||||
- apiGroups:
|
||||
- awx.ansible.com
|
||||
resources:
|
||||
- awxs/status
|
||||
verbs:
|
||||
- get
|
||||
- apiGroups:
|
||||
- awx.ansible.com
|
||||
resources:
|
||||
- awxs
|
||||
verbs:
|
||||
- get
|
||||
- list
|
||||
- watch
|
||||
- apiGroups:
|
||||
- awx.ansible.com
|
||||
resources:
|
||||
- awxs/status
|
||||
verbs:
|
||||
- get
|
||||
|
||||
24
config/rbac/awxbackup_editor_role.yaml
Normal file
24
config/rbac/awxbackup_editor_role.yaml
Normal file
@@ -0,0 +1,24 @@
|
||||
# permissions for end users to edit awxbackups.
|
||||
apiVersion: rbac.authorization.k8s.io/v1
|
||||
kind: ClusterRole
|
||||
metadata:
|
||||
name: awxbackup-editor-role
|
||||
rules:
|
||||
- apiGroups:
|
||||
- awx.ansible.com
|
||||
resources:
|
||||
- awxbackups
|
||||
verbs:
|
||||
- create
|
||||
- delete
|
||||
- get
|
||||
- list
|
||||
- patch
|
||||
- update
|
||||
- watch
|
||||
- apiGroups:
|
||||
- awx.ansible.com
|
||||
resources:
|
||||
- awxbackups/status
|
||||
verbs:
|
||||
- get
|
||||
20
config/rbac/awxbackup_viewer_role.yaml
Normal file
20
config/rbac/awxbackup_viewer_role.yaml
Normal file
@@ -0,0 +1,20 @@
|
||||
# permissions for end users to view awxbackups.
|
||||
apiVersion: rbac.authorization.k8s.io/v1
|
||||
kind: ClusterRole
|
||||
metadata:
|
||||
name: awxbackup-viewer-role
|
||||
rules:
|
||||
- apiGroups:
|
||||
- awx.ansible.com
|
||||
resources:
|
||||
- awxbackups
|
||||
verbs:
|
||||
- get
|
||||
- list
|
||||
- watch
|
||||
- apiGroups:
|
||||
- awx.ansible.com
|
||||
resources:
|
||||
- awxbackups/status
|
||||
verbs:
|
||||
- get
|
||||
24
config/rbac/awxrestore_editor_role.yaml
Normal file
24
config/rbac/awxrestore_editor_role.yaml
Normal file
@@ -0,0 +1,24 @@
|
||||
# permissions for end users to edit awxrestores.
|
||||
apiVersion: rbac.authorization.k8s.io/v1
|
||||
kind: ClusterRole
|
||||
metadata:
|
||||
name: awxrestore-editor-role
|
||||
rules:
|
||||
- apiGroups:
|
||||
- awx.ansible.com
|
||||
resources:
|
||||
- awxrestores
|
||||
verbs:
|
||||
- create
|
||||
- delete
|
||||
- get
|
||||
- list
|
||||
- patch
|
||||
- update
|
||||
- watch
|
||||
- apiGroups:
|
||||
- awx.ansible.com
|
||||
resources:
|
||||
- awxrestores/status
|
||||
verbs:
|
||||
- get
|
||||
20
config/rbac/awxrestore_viewer_role.yaml
Normal file
20
config/rbac/awxrestore_viewer_role.yaml
Normal file
@@ -0,0 +1,20 @@
|
||||
# permissions for end users to view awxrestores.
|
||||
apiVersion: rbac.authorization.k8s.io/v1
|
||||
kind: ClusterRole
|
||||
metadata:
|
||||
name: awxrestore-viewer-role
|
||||
rules:
|
||||
- apiGroups:
|
||||
- awx.ansible.com
|
||||
resources:
|
||||
- awxrestores
|
||||
verbs:
|
||||
- get
|
||||
- list
|
||||
- watch
|
||||
- apiGroups:
|
||||
- awx.ansible.com
|
||||
resources:
|
||||
- awxrestores/status
|
||||
verbs:
|
||||
- get
|
||||
@@ -1,19 +1,18 @@
|
||||
---
|
||||
resources:
|
||||
# All RBAC will be applied under this service account in
|
||||
# the deployment namespace. You may comment out this resource
|
||||
# if your manager will use a service account that exists at
|
||||
# runtime. Be sure to update RoleBinding and ClusterRoleBinding
|
||||
# subjects if changing service account names.
|
||||
- service_account.yaml
|
||||
- role.yaml
|
||||
- role_binding.yaml
|
||||
- leader_election_role.yaml
|
||||
- leader_election_role_binding.yaml
|
||||
# Comment the following 4 lines if you want to disable
|
||||
# the auth proxy (https://github.com/brancz/kube-rbac-proxy)
|
||||
# which protects your /metrics endpoint.
|
||||
- auth_proxy_service.yaml
|
||||
- auth_proxy_role.yaml
|
||||
- auth_proxy_role_binding.yaml
|
||||
- auth_proxy_client_clusterrole.yaml
|
||||
# All RBAC will be applied under this service account in
|
||||
# the deployment namespace. You may comment out this resource
|
||||
# if your manager will use a service account that exists at
|
||||
# runtime. Be sure to update RoleBinding and ClusterRoleBinding
|
||||
# subjects if changing service account names.
|
||||
- service_account.yaml
|
||||
- role.yaml
|
||||
- role_binding.yaml
|
||||
- leader_election_role.yaml
|
||||
- leader_election_role_binding.yaml
|
||||
# Comment the following 4 lines if you want to disable
|
||||
# the auth proxy (https://github.com/brancz/kube-rbac-proxy)
|
||||
# which protects your /metrics endpoint.
|
||||
- auth_proxy_service.yaml
|
||||
- auth_proxy_role.yaml
|
||||
- auth_proxy_role_binding.yaml
|
||||
- auth_proxy_client_clusterrole.yaml
|
||||
|
||||
@@ -1,38 +1,37 @@
|
||||
---
|
||||
# permissions to do leader election.
|
||||
apiVersion: rbac.authorization.k8s.io/v1
|
||||
kind: Role
|
||||
metadata:
|
||||
name: leader-election-role
|
||||
rules:
|
||||
- apiGroups:
|
||||
- ""
|
||||
resources:
|
||||
- configmaps
|
||||
verbs:
|
||||
- get
|
||||
- list
|
||||
- watch
|
||||
- create
|
||||
- update
|
||||
- patch
|
||||
- delete
|
||||
- apiGroups:
|
||||
- coordination.k8s.io
|
||||
resources:
|
||||
- leases
|
||||
verbs:
|
||||
- get
|
||||
- list
|
||||
- watch
|
||||
- create
|
||||
- update
|
||||
- patch
|
||||
- delete
|
||||
- apiGroups:
|
||||
- ""
|
||||
resources:
|
||||
- events
|
||||
verbs:
|
||||
- create
|
||||
- patch
|
||||
- apiGroups:
|
||||
- ""
|
||||
resources:
|
||||
- configmaps
|
||||
verbs:
|
||||
- get
|
||||
- list
|
||||
- watch
|
||||
- create
|
||||
- update
|
||||
- patch
|
||||
- delete
|
||||
- apiGroups:
|
||||
- coordination.k8s.io
|
||||
resources:
|
||||
- leases
|
||||
verbs:
|
||||
- get
|
||||
- list
|
||||
- watch
|
||||
- create
|
||||
- update
|
||||
- patch
|
||||
- delete
|
||||
- apiGroups:
|
||||
- ""
|
||||
resources:
|
||||
- events
|
||||
verbs:
|
||||
- create
|
||||
- patch
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
---
|
||||
apiVersion: rbac.authorization.k8s.io/v1
|
||||
kind: RoleBinding
|
||||
metadata:
|
||||
@@ -8,6 +7,6 @@ roleRef:
|
||||
kind: Role
|
||||
name: leader-election-role
|
||||
subjects:
|
||||
- kind: ServiceAccount
|
||||
name: controller-manager
|
||||
namespace: system
|
||||
- kind: ServiceAccount
|
||||
name: controller-manager
|
||||
namespace: system
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: ServiceAccount
|
||||
metadata:
|
||||
|
||||
13
config/samples/awx_v1beta1_awxbackup.yaml
Normal file
13
config/samples/awx_v1beta1_awxbackup.yaml
Normal file
@@ -0,0 +1,13 @@
|
||||
apiVersion: awx.ansible.com/v1beta1
|
||||
kind: AWXBackup
|
||||
metadata:
|
||||
name: example-awx-backup
|
||||
spec:
|
||||
deployment_name: example-awx
|
||||
backup_resource_requirements:
|
||||
limits:
|
||||
cpu: "1000m"
|
||||
memory: "4096Mi"
|
||||
requests:
|
||||
cpu: "25m"
|
||||
memory: "32Mi"
|
||||
14
config/samples/awx_v1beta1_awxrestore.yaml
Normal file
14
config/samples/awx_v1beta1_awxrestore.yaml
Normal file
@@ -0,0 +1,14 @@
|
||||
apiVersion: awx.ansible.com/v1beta1
|
||||
kind: AWXRestore
|
||||
metadata:
|
||||
name: awxrestore-sample
|
||||
spec:
|
||||
deployment_name: example-awx-2
|
||||
backup_name: example-awx-backup
|
||||
restore_resource_requirements:
|
||||
limits:
|
||||
cpu: "1000m"
|
||||
memory: "4096Mi"
|
||||
requests:
|
||||
cpu: "25m"
|
||||
memory: "32Mi"
|
||||
@@ -1,5 +1,6 @@
|
||||
---
|
||||
## Append samples you want in your CSV to this file as resources ##
|
||||
resources:
|
||||
- awx_v1beta1_awx.yaml
|
||||
# +kubebuilder:scaffold:manifestskustomizesamples
|
||||
- awx_v1beta1_awx.yaml
|
||||
- awx_v1beta1_awxbackup.yaml
|
||||
- awx_v1beta1_awxrestore.yaml
|
||||
#+kubebuilder:scaffold:manifestskustomizesamples
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
---
|
||||
apiVersion: scorecard.operatorframework.io/v1alpha3
|
||||
kind: Configuration
|
||||
metadata:
|
||||
name: config
|
||||
stages:
|
||||
- parallel: true
|
||||
tests: []
|
||||
- parallel: true
|
||||
tests: []
|
||||
|
||||
@@ -1,17 +1,16 @@
|
||||
---
|
||||
resources:
|
||||
- bases/config.yaml
|
||||
- bases/config.yaml
|
||||
patchesJson6902:
|
||||
- path: patches/basic.config.yaml
|
||||
target:
|
||||
group: scorecard.operatorframework.io
|
||||
version: v1alpha3
|
||||
kind: Configuration
|
||||
name: config
|
||||
- path: patches/olm.config.yaml
|
||||
target:
|
||||
group: scorecard.operatorframework.io
|
||||
version: v1alpha3
|
||||
kind: Configuration
|
||||
name: config
|
||||
# +kubebuilder:scaffold:patchesJson6902
|
||||
- path: patches/basic.config.yaml
|
||||
target:
|
||||
group: scorecard.operatorframework.io
|
||||
version: v1alpha3
|
||||
kind: Configuration
|
||||
name: config
|
||||
- path: patches/olm.config.yaml
|
||||
target:
|
||||
group: scorecard.operatorframework.io
|
||||
version: v1alpha3
|
||||
kind: Configuration
|
||||
name: config
|
||||
#+kubebuilder:scaffold:patchesJson6902
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
---
|
||||
- op: add
|
||||
path: /stages/0/tests/-
|
||||
value:
|
||||
entrypoint:
|
||||
- scorecard-test
|
||||
- basic-check-spec
|
||||
image: quay.io/operator-framework/scorecard-test:v1.12.0
|
||||
- scorecard-test
|
||||
- basic-check-spec
|
||||
image: quay.io/operator-framework/scorecard-test:v1.23.0
|
||||
labels:
|
||||
suite: basic
|
||||
test: basic-check-spec-test
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
---
|
||||
- op: add
|
||||
path: /stages/0/tests/-
|
||||
value:
|
||||
entrypoint:
|
||||
- scorecard-test
|
||||
- olm-bundle-validation
|
||||
image: quay.io/operator-framework/scorecard-test:v1.12.0
|
||||
- scorecard-test
|
||||
- olm-bundle-validation
|
||||
image: quay.io/operator-framework/scorecard-test:v1.23.0
|
||||
labels:
|
||||
suite: olm
|
||||
test: olm-bundle-validation-test
|
||||
@@ -13,9 +12,9 @@
|
||||
path: /stages/0/tests/-
|
||||
value:
|
||||
entrypoint:
|
||||
- scorecard-test
|
||||
- olm-crds-have-validation
|
||||
image: quay.io/operator-framework/scorecard-test:v1.12.0
|
||||
- scorecard-test
|
||||
- olm-crds-have-validation
|
||||
image: quay.io/operator-framework/scorecard-test:v1.23.0
|
||||
labels:
|
||||
suite: olm
|
||||
test: olm-crds-have-validation-test
|
||||
@@ -23,9 +22,9 @@
|
||||
path: /stages/0/tests/-
|
||||
value:
|
||||
entrypoint:
|
||||
- scorecard-test
|
||||
- olm-crds-have-resources
|
||||
image: quay.io/operator-framework/scorecard-test:v1.12.0
|
||||
- scorecard-test
|
||||
- olm-crds-have-resources
|
||||
image: quay.io/operator-framework/scorecard-test:v1.23.0
|
||||
labels:
|
||||
suite: olm
|
||||
test: olm-crds-have-resources-test
|
||||
@@ -33,9 +32,9 @@
|
||||
path: /stages/0/tests/-
|
||||
value:
|
||||
entrypoint:
|
||||
- scorecard-test
|
||||
- olm-spec-descriptors
|
||||
image: quay.io/operator-framework/scorecard-test:v1.12.0
|
||||
- scorecard-test
|
||||
- olm-spec-descriptors
|
||||
image: quay.io/operator-framework/scorecard-test:v1.23.0
|
||||
labels:
|
||||
suite: olm
|
||||
test: olm-spec-descriptors-test
|
||||
@@ -43,9 +42,9 @@
|
||||
path: /stages/0/tests/-
|
||||
value:
|
||||
entrypoint:
|
||||
- scorecard-test
|
||||
- olm-status-descriptors
|
||||
image: quay.io/operator-framework/scorecard-test:v1.12.0
|
||||
- scorecard-test
|
||||
- olm-status-descriptors
|
||||
image: quay.io/operator-framework/scorecard-test:v1.23.0
|
||||
labels:
|
||||
suite: olm
|
||||
test: olm-status-descriptors-test
|
||||
|
||||
@@ -1,13 +1,17 @@
|
||||
# Adds namespace to all resources.
|
||||
namespace: osdk-test
|
||||
|
||||
namePrefix: osdk-
|
||||
|
||||
# Labels to add to all resources and selectors.
|
||||
# commonLabels:
|
||||
# someName: someValue
|
||||
#commonLabels:
|
||||
# someName: someValue
|
||||
|
||||
patchesStrategicMerge:
|
||||
- manager_image.yaml
|
||||
- debug_logs_patch.yaml
|
||||
- ../default/manager_auth_proxy_patch.yaml
|
||||
|
||||
apiVersion: kustomize.config.k8s.io/v1beta1
|
||||
kind: Kustomization
|
||||
resources:
|
||||
@@ -17,5 +21,3 @@ resources:
|
||||
images:
|
||||
- name: testing
|
||||
newName: testing-operator
|
||||
patches:
|
||||
- path: pull_policy/Never.yaml
|
||||
|
||||
@@ -19,6 +19,6 @@
|
||||
state: absent
|
||||
|
||||
- name: Unset pull policy
|
||||
command: '{{ kustomize }} edit remove patch pull_policy/{{ operator_pull_policy }}.yaml'
|
||||
command: '{{ kustomize }} edit remove patch --path pull_policy/{{ operator_pull_policy }}.yaml'
|
||||
args:
|
||||
chdir: '{{ config_dir }}/testing'
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
- name: Build kustomize testing overlay
|
||||
# load_restrictor must be set to none so we can load patch files from the default overlay
|
||||
# load-restrictor must be set to none so we can load patch files from the default overlay
|
||||
command: '{{ kustomize }} build --load-restrictor LoadRestrictionsNone .'
|
||||
args:
|
||||
chdir: '{{ config_dir }}/testing'
|
||||
|
||||
@@ -49,13 +49,13 @@
|
||||
name: Demo Job Template
|
||||
wait: yes
|
||||
validate_certs: no
|
||||
controller_host: localhost
|
||||
controller_host: localhost/awx/
|
||||
controller_username: admin
|
||||
controller_password: "{{ admin_pw_secret.resources[0].data.password | b64decode }}"
|
||||
rescue:
|
||||
- name: Get list of project updates and jobs
|
||||
uri:
|
||||
url: "http://localhost/api/v2/{{ resource }}/"
|
||||
url: "http://localhost/awx/api/v2/{{ resource }}/"
|
||||
user: admin
|
||||
password: "{{ admin_pw_secret.resources[0].data.password | b64decode }}"
|
||||
force_basic_auth: yes
|
||||
|
||||
18
molecule/default/tasks/awxbackup_test.yml
Normal file
18
molecule/default/tasks/awxbackup_test.yml
Normal file
@@ -0,0 +1,18 @@
|
||||
---
|
||||
# - name: Create the awx.ansible.com/v1beta1.AWXBackup
|
||||
# k8s:
|
||||
# state: present
|
||||
# namespace: '{{ namespace }}'
|
||||
# definition: "{{ lookup('template', '/'.join([samples_dir, cr_file])) | from_yaml }}"
|
||||
# wait: yes
|
||||
# wait_timeout: 300
|
||||
# wait_condition:
|
||||
# type: Successful
|
||||
# status: "True"
|
||||
# vars:
|
||||
# cr_file: 'awx_v1beta1_awxbackup.yaml'
|
||||
#
|
||||
# - name: Add assertions here
|
||||
# assert:
|
||||
# that: false
|
||||
# fail_msg: FIXME Add real assertions for your operator
|
||||
18
molecule/default/tasks/awxrestore_test.yml
Normal file
18
molecule/default/tasks/awxrestore_test.yml
Normal file
@@ -0,0 +1,18 @@
|
||||
---
|
||||
# - name: Create the awx.ansible.com/v1beta1.AWXRestore
|
||||
# k8s:
|
||||
# state: present
|
||||
# namespace: '{{ namespace }}'
|
||||
# definition: "{{ lookup('template', '/'.join([samples_dir, cr_file])) | from_yaml }}"
|
||||
# wait: yes
|
||||
# wait_timeout: 300
|
||||
# wait_condition:
|
||||
# type: Successful
|
||||
# status: "True"
|
||||
# vars:
|
||||
# cr_file: 'awx_v1beta1_awxrestore.yaml'
|
||||
#
|
||||
# - name: Add assertions here
|
||||
# assert:
|
||||
# that: false
|
||||
# fail_msg: FIXME Add real assertions for your operator
|
||||
@@ -11,6 +11,7 @@ spec:
|
||||
image_version: {{ awx_version }}
|
||||
{% endif %}
|
||||
ingress_type: ingress
|
||||
ingress_path: /awx
|
||||
ingress_annotations: |
|
||||
kubernetes.io/ingress.class: nginx
|
||||
web_resource_requirements:
|
||||
|
||||
@@ -11,6 +11,6 @@
|
||||
command: kind delete cluster --name osdk-test --kubeconfig {{ kubeconfig }}
|
||||
|
||||
- name: Unset pull policy
|
||||
command: '{{ kustomize }} edit remove patch pull_policy/{{ operator_pull_policy }}.yaml'
|
||||
command: '{{ kustomize }} edit remove patch --path pull_policy/{{ operator_pull_policy }}.yaml'
|
||||
args:
|
||||
chdir: '{{ config_dir }}/testing'
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
molecule
|
||||
molecule<4.0.2
|
||||
molecule-docker
|
||||
yamllint
|
||||
ansible-lint
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
collections:
|
||||
- name: community.general
|
||||
- name: kubernetes.core
|
||||
version: 1.2.1
|
||||
version: 2.3.2
|
||||
- name: operator_sdk.util
|
||||
- name: community.docker
|
||||
- name: awx.awx
|
||||
|
||||
31
playbooks/awx.yml
Normal file
31
playbooks/awx.yml
Normal file
@@ -0,0 +1,31 @@
|
||||
---
|
||||
- hosts: localhost
|
||||
gather_facts: no
|
||||
collections:
|
||||
- kubernetes.core
|
||||
- operator_sdk.util
|
||||
vars:
|
||||
no_log: true
|
||||
pre_tasks:
|
||||
- name: Verify imagePullSecrets
|
||||
k8s_info:
|
||||
kind: Secret
|
||||
namespace: '{{ ansible_operator_meta.namespace }}'
|
||||
name: redhat-operators-pull-secret
|
||||
register: _rh_ops_secret
|
||||
no_log: "{{ no_log }}"
|
||||
- name: Create imagePullSecret
|
||||
k8s:
|
||||
state: present
|
||||
definition:
|
||||
apiVersion: v1
|
||||
kind: Secret
|
||||
metadata:
|
||||
name: redhat-operators-pull-secret
|
||||
namespace: '{{ ansible_operator_meta.namespace }}'
|
||||
stringData:
|
||||
operator: awx
|
||||
when:
|
||||
- (_rh_ops_secret is not defined) or not (_rh_ops_secret['resources'] | length)
|
||||
roles:
|
||||
- installer
|
||||
0
projects/.gitkeep
Executable file → Normal file
0
projects/.gitkeep
Executable file → Normal file
@@ -1,6 +1,6 @@
|
||||
---
|
||||
collections:
|
||||
- name: kubernetes.core
|
||||
version: '==1.2.1'
|
||||
version: '>=2.3.2'
|
||||
- name: operator_sdk.util
|
||||
version: "0.2.0"
|
||||
version: "0.4.0"
|
||||
|
||||
@@ -45,7 +45,7 @@ The resulting pvc will contain a backup tar that can be used to restore to a new
|
||||
Role Variables
|
||||
--------------
|
||||
|
||||
A custom, pre-created pvc can be used by setting the following variables.
|
||||
A custom, pre-created pvc can be used by setting the following variables.
|
||||
|
||||
```
|
||||
backup_pvc: 'awx-backup-volume-claim'
|
||||
@@ -62,18 +62,36 @@ backup_storage_requirements: '20Gi'
|
||||
|
||||
By default, the backup pvc will be created in the same namespace the awxbackup object is created in. If you want your backup to be stored
|
||||
in a specific namespace, you can do so by specifying `backup_pvc_namespace`. Keep in mind that you will
|
||||
need to provide the same namespace when restoring.
|
||||
need to provide the same namespace when restoring.
|
||||
|
||||
```
|
||||
backup_pvc_namespace: 'custom-namespace'
|
||||
```
|
||||
The backup pvc will be created in the same namespace the awxbackup object is created in.
|
||||
|
||||
If a custom postgres configuration secret was used when deploying AWX, it will automatically be used by the backup role.
|
||||
To check the name of this secret, look at the postgresConfigurationSecret status on your AWX object.
|
||||
If a custom postgres configuration secret was used when deploying AWX, it will automatically be used by the backup role.
|
||||
To check the name of this secret, look at the postgresConfigurationSecret status on your AWX object.
|
||||
|
||||
The postgresql pod for the old deployment is used when backing up data to the new postgresql pod. If your postgresql pod has a custom label,
|
||||
you can pass that via the `postgres_label_selector` variable to make sure the postgresql pod can be found.
|
||||
|
||||
It is also possible to tie the lifetime of the backup files to that of the AWXBackup resource object. To do that you can set the
|
||||
`clean_backup_on_delete` value to true. This will delete the `backupDirectory` on the pvc associated with the AWXBackup object deleted.
|
||||
|
||||
```
|
||||
clean_backup_on_delete: true
|
||||
```
|
||||
|
||||
Variable to define resources limits and request for backup CR.
|
||||
```
|
||||
backup_resource_requirements:
|
||||
limits:
|
||||
cpu: "1000m"
|
||||
memory: "4096Mi"
|
||||
requests:
|
||||
cpu: "25m"
|
||||
memory: "32Mi"
|
||||
```
|
||||
|
||||
Testing
|
||||
----------------
|
||||
|
||||
@@ -12,4 +12,25 @@ backup_pvc_namespace: "{{ ansible_operator_meta.namespace }}"
|
||||
backup_storage_requirements: ''
|
||||
|
||||
# Set no_log settings on certain tasks
|
||||
no_log: 'true'
|
||||
no_log: true
|
||||
|
||||
# Variable to set when you want backups to be cleaned up when the CRD object is deleted
|
||||
clean_backup_on_delete: false
|
||||
|
||||
# Variable to signal that this role is being run as a finalizer
|
||||
finalizer_run: false
|
||||
|
||||
# Default resource requirements
|
||||
backup_resource_requirements:
|
||||
limits:
|
||||
cpu: "1000m"
|
||||
memory: "4096Mi"
|
||||
requests:
|
||||
cpu: "25m"
|
||||
memory: "32Mi"
|
||||
# Allow additional parameters to be added to the pg_dump backup command
|
||||
pg_dump_suffix: ''
|
||||
|
||||
# Maintain some of the recommended `app.kubernetes.io/*` labels on the resource (self)
|
||||
set_self_labels: true
|
||||
...
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
set_fact:
|
||||
awx_spec:
|
||||
spec: "{{ _awx }}"
|
||||
previous_deployment_name: "{{ this_awx['resources'][0]['metadata']['name'] }}"
|
||||
|
||||
- name: Write awx object to pvc
|
||||
k8s_exec:
|
||||
|
||||
48
roles/backup/tasks/creation.yml
Normal file
48
roles/backup/tasks/creation.yml
Normal file
@@ -0,0 +1,48 @@
|
||||
---
|
||||
- name: Patching labels to {{ kind }} kind
|
||||
k8s:
|
||||
state: present
|
||||
definition:
|
||||
apiVersion: "{{ api_version }}"
|
||||
kind: "{{ kind }}"
|
||||
name: "{{ ansible_operator_meta.name }}"
|
||||
namespace: "{{ ansible_operator_meta.namespace }}"
|
||||
metadata:
|
||||
name: "{{ ansible_operator_meta.name }}"
|
||||
namespace: "{{ ansible_operator_meta.namespace }}"
|
||||
labels:
|
||||
app.kubernetes.io/name: "{{ ansible_operator_meta.name }}"
|
||||
app.kubernetes.io/part-of: "{{ ansible_operator_meta.name }}"
|
||||
app.kubernetes.io/managed-by: "{{ deployment_type }}-operator"
|
||||
app.kubernetes.io/component: "{{ deployment_type }}"
|
||||
app.kubernetes.io/operator-version: '{{ lookup("env", "OPERATOR_VERSION") }}'
|
||||
when: set_self_labels | bool
|
||||
|
||||
- name: Look up details for this backup object
|
||||
k8s_info:
|
||||
api_version: "{{ api_version }}"
|
||||
kind: "{{ kind }}"
|
||||
name: "{{ ansible_operator_meta.name }}"
|
||||
namespace: "{{ ansible_operator_meta.namespace }}"
|
||||
register: this_backup
|
||||
|
||||
- block:
|
||||
- include_tasks: init.yml
|
||||
|
||||
- include_tasks: postgres.yml
|
||||
|
||||
- include_tasks: awx-cro.yml
|
||||
|
||||
- include_tasks: secrets.yml
|
||||
|
||||
- name: Set flag signifying this backup was successful
|
||||
set_fact:
|
||||
backup_complete: true
|
||||
|
||||
- include_tasks: cleanup.yml
|
||||
|
||||
when:
|
||||
- this_backup['resources'][0]['status']['backupDirectory'] is not defined
|
||||
|
||||
- name: Update status variables
|
||||
include_tasks: update_status.yml
|
||||
7
roles/backup/tasks/delete_backup.yml
Normal file
7
roles/backup/tasks/delete_backup.yml
Normal file
@@ -0,0 +1,7 @@
|
||||
---
|
||||
- name: Cleanup backup associated with this option if enabled
|
||||
k8s_exec:
|
||||
namespace: "{{ backup_pvc_namespace }}"
|
||||
pod: "{{ ansible_operator_meta.name }}-db-management"
|
||||
command: >-
|
||||
bash -c 'rm -rf {{ backup_dir }}'
|
||||
24
roles/backup/tasks/dump_receptor_secrets.yml
Normal file
24
roles/backup/tasks/dump_receptor_secrets.yml
Normal file
@@ -0,0 +1,24 @@
|
||||
---
|
||||
|
||||
- name: Get secret
|
||||
k8s_info:
|
||||
version: v1
|
||||
kind: Secret
|
||||
namespace: '{{ ansible_operator_meta.namespace }}'
|
||||
name: "{{ item }}"
|
||||
register: _secret
|
||||
no_log: "{{ no_log }}"
|
||||
|
||||
- name: Backup secret if exists
|
||||
block:
|
||||
- name: Set secret key
|
||||
set_fact:
|
||||
_data: "{{ _secret['resources'][0]['data'] }}"
|
||||
_type: "{{ _secret['resources'][0]['type'] }}"
|
||||
no_log: "{{ no_log }}"
|
||||
|
||||
- name: Create and Add secret names and data to dictionary
|
||||
set_fact:
|
||||
secret_dict: "{{ secret_dict | default({}) | combine({item: { 'name': item, 'data': _data, 'type': _type }}) }}"
|
||||
no_log: "{{ no_log }}"
|
||||
when: _secret | length
|
||||
20
roles/backup/tasks/finalizer.yml
Normal file
20
roles/backup/tasks/finalizer.yml
Normal file
@@ -0,0 +1,20 @@
|
||||
---
|
||||
- name: Look up details for this backup object
|
||||
k8s_info:
|
||||
api_version: "{{ api_version }}"
|
||||
kind: "{{ kind }}"
|
||||
name: "{{ ansible_operator_meta.name }}"
|
||||
namespace: "{{ ansible_operator_meta.namespace }}"
|
||||
register: this_backup
|
||||
|
||||
- block:
|
||||
- include_tasks: init.yml
|
||||
|
||||
- include_tasks: delete_backup.yml
|
||||
|
||||
- include_tasks: cleanup.yml
|
||||
vars:
|
||||
backup_dir: "{{ this_backup['resources'][0]['status']['backupDirectory'] | default() }}"
|
||||
when:
|
||||
- clean_backup_on_delete
|
||||
- backup_dir | length > 0
|
||||
@@ -1,5 +1,4 @@
|
||||
---
|
||||
|
||||
- name: Delete any existing management pod
|
||||
k8s:
|
||||
name: "{{ ansible_operator_meta.name }}-db-management"
|
||||
@@ -57,8 +56,8 @@
|
||||
apiVersion: v1
|
||||
kind: PersistentVolumeClaim
|
||||
metadata:
|
||||
name: '{{ deployment_name }}-backup-claim'
|
||||
namespace: '{{ backup_pvc_namespace }}'
|
||||
name: "{{ deployment_name }}-backup-claim"
|
||||
namespace: "{{ backup_pvc_namespace }}"
|
||||
ownerReferences: null
|
||||
when:
|
||||
- backup_pvc == '' or backup_pvc is not defined
|
||||
|
||||
@@ -1,47 +1,8 @@
|
||||
---
|
||||
- name: Patching labels to {{ kind }} kind
|
||||
k8s:
|
||||
state: present
|
||||
definition:
|
||||
apiVersion: '{{ api_version }}'
|
||||
kind: '{{ kind }}'
|
||||
name: '{{ ansible_operator_meta.name }}'
|
||||
namespace: '{{ ansible_operator_meta.namespace }}'
|
||||
metadata:
|
||||
name: '{{ ansible_operator_meta.name }}'
|
||||
namespace: '{{ ansible_operator_meta.namespace }}'
|
||||
labels:
|
||||
app.kubernetes.io/name: '{{ ansible_operator_meta.name }}'
|
||||
app.kubernetes.io/part-of: '{{ ansible_operator_meta.name }}'
|
||||
app.kubernetes.io/managed-by: '{{ deployment_type }}-operator'
|
||||
app.kubernetes.io/component: '{{ deployment_type }}'
|
||||
app.kubernetes.io/operator-version: '{{ lookup("env", "OPERATOR_VERSION") }}'
|
||||
- name: Run creation tasks
|
||||
include_tasks: creation.yml
|
||||
when: not finalizer_run
|
||||
|
||||
- name: Look up details for this backup object
|
||||
k8s_info:
|
||||
api_version: "{{ api_version }}"
|
||||
kind: "{{ kind }}"
|
||||
name: "{{ ansible_operator_meta.name }}"
|
||||
namespace: "{{ ansible_operator_meta.namespace }}"
|
||||
register: this_backup
|
||||
|
||||
- block:
|
||||
- include_tasks: init.yml
|
||||
|
||||
- include_tasks: postgres.yml
|
||||
|
||||
- include_tasks: awx-cro.yml
|
||||
|
||||
- include_tasks: secrets.yml
|
||||
|
||||
- name: Set flag signifying this backup was successful
|
||||
set_fact:
|
||||
backup_complete: true
|
||||
|
||||
- include_tasks: cleanup.yml
|
||||
|
||||
when:
|
||||
- this_backup['resources'][0]['status']['backupDirectory'] is not defined
|
||||
|
||||
- name: Update status variables
|
||||
include_tasks: update_status.yml
|
||||
- name: Run finalizer tasks
|
||||
include_tasks: finalizer.yml
|
||||
when: finalizer_run
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
- block:
|
||||
- name: Delete pod to reload a resource configuration
|
||||
set_fact:
|
||||
postgres_label_selector: "app.kubernetes.io/instance=postgres-{{ deployment_name }}"
|
||||
postgres_label_selector: "app.kubernetes.io/instance=postgres-{{ supported_pg_version }}-{{ deployment_name }}"
|
||||
when: postgres_label_selector is not defined
|
||||
|
||||
- name: Get the postgres pod information
|
||||
@@ -75,7 +75,7 @@
|
||||
namespace: "{{ backup_pvc_namespace }}"
|
||||
pod: "{{ ansible_operator_meta.name }}-db-management"
|
||||
command: >-
|
||||
bash -c "chmod 0600 {{ backup_dir }}/tower.db && chown postgres:root {{ backup_dir }}/tower.db"
|
||||
bash -c "chmod 660 {{ backup_dir }}/tower.db && chown :root {{ backup_dir }}/tower.db"
|
||||
|
||||
- name: Set full resolvable host name for postgres pod
|
||||
set_fact:
|
||||
@@ -91,6 +91,7 @@
|
||||
-d {{ awx_postgres_database }}
|
||||
-p {{ awx_postgres_port }}
|
||||
-F custom
|
||||
{{ pg_dump_suffix }}
|
||||
no_log: "{{ no_log }}"
|
||||
|
||||
- name: Write pg_dump to backup on PVC
|
||||
|
||||
@@ -1,11 +1,5 @@
|
||||
---
|
||||
|
||||
- name: Create Temporary secrets file
|
||||
tempfile:
|
||||
state: file
|
||||
suffix: .json
|
||||
register: tmp_secrets
|
||||
|
||||
- name: Dump (generated) secret names from statuses and data into file
|
||||
include_tasks: dump_generated_secret.yml
|
||||
with_items:
|
||||
@@ -23,6 +17,12 @@
|
||||
- bundle_cacert_secret
|
||||
- ee_pull_credentials_secret
|
||||
|
||||
- name: Dump receptor secret names and data into file
|
||||
include_tasks: dump_receptor_secrets.yml
|
||||
loop:
|
||||
- '{{ deployment_name }}-receptor-ca'
|
||||
- '{{ deployment_name }}-receptor-work-signing'
|
||||
|
||||
# image_pull_secret is deprecated in favor of image_pull_secrets
|
||||
- name: Dump image_pull_secret into file
|
||||
include_tasks: dump_secret.yml
|
||||
|
||||
@@ -20,6 +20,10 @@ spec:
|
||||
- name: {{ ansible_operator_meta.name }}-backup
|
||||
mountPath: /backups
|
||||
readOnly: false
|
||||
{% if backup_resource_requirements is defined %}
|
||||
resources:
|
||||
{{ backup_resource_requirements | to_nice_yaml(indent=2) | indent(width=6, first=False) }}
|
||||
{%- endif %}
|
||||
volumes:
|
||||
- name: {{ ansible_operator_meta.name }}-backup
|
||||
persistentVolumeClaim:
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
---
|
||||
deployment_type: "awx"
|
||||
_postgres_image: postgres
|
||||
_postgres_image_version: 12
|
||||
_postgres_image_version: 13
|
||||
backup_complete: false
|
||||
database_type: "unmanaged"
|
||||
supported_pg_version: 13
|
||||
|
||||
8
roles/common/defaults/main.yml
Normal file
8
roles/common/defaults/main.yml
Normal file
@@ -0,0 +1,8 @@
|
||||
---
|
||||
deployment_type: awx
|
||||
kind: 'AWX'
|
||||
api_version: '{{ deployment_type }}.ansible.com/v1beta1'
|
||||
|
||||
# Used to determine some cluster specific logic regarding projects_persistence pvc permissions
|
||||
is_k8s: false
|
||||
is_openshift: false
|
||||
32
roles/common/meta/main.yml
Normal file
32
roles/common/meta/main.yml
Normal file
@@ -0,0 +1,32 @@
|
||||
---
|
||||
galaxy_info:
|
||||
author: Ansible
|
||||
description: AWX role for AWX Operator for Kubernetes.
|
||||
company: Red Hat, Inc.
|
||||
|
||||
license: MIT
|
||||
|
||||
min_ansible_version: 2.8
|
||||
|
||||
platforms:
|
||||
- name: EL
|
||||
versions:
|
||||
- all
|
||||
- name: Debian
|
||||
versions:
|
||||
- all
|
||||
|
||||
galaxy_tags:
|
||||
- tower
|
||||
- awx
|
||||
- ansible
|
||||
- automation
|
||||
- ci
|
||||
- cd
|
||||
- deployment
|
||||
|
||||
dependencies: []
|
||||
|
||||
collections:
|
||||
- kubernetes.core
|
||||
- operator_sdk.util
|
||||
20
roles/common/tasks/main.yml
Normal file
20
roles/common/tasks/main.yml
Normal file
@@ -0,0 +1,20 @@
|
||||
---
|
||||
|
||||
- name: Get information about the cluster
|
||||
set_fact:
|
||||
api_groups: "{{ lookup('k8s', cluster_info='api_groups') }}"
|
||||
when:
|
||||
- not is_openshift | bool
|
||||
- not is_k8s | bool
|
||||
|
||||
- name: Determine the cluster type
|
||||
set_fact:
|
||||
is_openshift: "{{ True if 'route.openshift.io' in api_groups else False }}"
|
||||
is_k8s: "{{ False if 'route.openshift.io' in api_groups else True }}"
|
||||
when:
|
||||
- not is_openshift | bool
|
||||
- not is_k8s | bool
|
||||
|
||||
# Indicate what kind of cluster we are in (OpenShift or Kubernetes).
|
||||
- debug:
|
||||
msg: "CLUSTER TYPE: is_openshift={{ is_openshift }}; is_k8s={{ is_k8s }}"
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
deployment_type: awx
|
||||
kind: '{{ deployment_type | upper }}'
|
||||
kind: 'AWX'
|
||||
api_version: '{{ deployment_type }}.ansible.com/v1beta1'
|
||||
|
||||
database_name: "{{ deployment_type }}"
|
||||
@@ -9,8 +9,10 @@ database_username: "{{ deployment_type }}"
|
||||
task_privileged: false
|
||||
service_type: ClusterIP
|
||||
ingress_type: none
|
||||
ingress_class_name: ''
|
||||
ingress_path: '/'
|
||||
ingress_path_type: 'Prefix'
|
||||
ingress_api_version: 'networking.k8s.io/v1'
|
||||
# Add annotations to the service account. Specify as literal block. E.g.:
|
||||
# service_account_annotations: |
|
||||
# eks.amazonaws.com/role-arn: arn:aws:iam::<ACCOUNT_ID>:role/<IAM_ROLE_NAME>
|
||||
@@ -49,6 +51,10 @@ route_tls_termination_mechanism: edge
|
||||
#
|
||||
route_tls_secret: ''
|
||||
|
||||
# Route API Version to support older version
|
||||
# of the kubernetes services
|
||||
route_api_version: 'route.openshift.io/v1'
|
||||
|
||||
# Host to create the root with.
|
||||
# If not specific will default to <instance-name>-<namespace>-<routerCanonicalHostname>
|
||||
#
|
||||
@@ -127,11 +133,9 @@ extra_volumes: ''
|
||||
_image: quay.io/ansible/awx
|
||||
_image_version: "{{ lookup('env', 'DEFAULT_AWX_VERSION') or 'latest' }}"
|
||||
_redis_image: docker.io/redis
|
||||
_redis_image_version: latest
|
||||
_redis_image_version: 7
|
||||
_postgres_image: postgres
|
||||
_postgres_image_version: 12
|
||||
_init_container_image: quay.io/centos/centos
|
||||
_init_container_image_version: stream8
|
||||
_postgres_image_version: 13
|
||||
image_pull_policy: IfNotPresent
|
||||
image_pull_secrets: []
|
||||
|
||||
@@ -157,6 +161,11 @@ ee_images:
|
||||
|
||||
_control_plane_ee_image: quay.io/ansible/awx-ee:latest
|
||||
|
||||
_init_container_image: "{{ _control_plane_ee_image.split(':')[0] }}"
|
||||
_init_container_image_version: "{{ _control_plane_ee_image.split(':')[1] }}"
|
||||
|
||||
_init_projects_container_image: quay.io/centos/centos:stream9
|
||||
|
||||
create_preload_data: true
|
||||
|
||||
replicas: "1"
|
||||
@@ -223,6 +232,9 @@ ee_extra_volume_mounts: ''
|
||||
# kubernetes.io/os: linux
|
||||
postgres_selector: ''
|
||||
|
||||
# Specify whether or not to keep the old PVC after PostgreSQL upgrades
|
||||
postgres_keep_pvc_after_upgrade: True
|
||||
|
||||
# Add node tolerations for the Postgres pods.
|
||||
# Specify as literal block. E.g.:
|
||||
# postgres_tolerations: |
|
||||
@@ -283,4 +295,14 @@ development_mode: false
|
||||
security_context_settings: {}
|
||||
|
||||
# Set no_log settings on certain tasks
|
||||
no_log: 'true'
|
||||
no_log: true
|
||||
|
||||
# Should AWX instances be automatically upgraded when operator gets upgraded
|
||||
#
|
||||
auto_upgrade: true
|
||||
|
||||
# Maintain some of the recommended `app.kubernetes.io/*` labels on the resource (self)
|
||||
set_self_labels: true
|
||||
|
||||
# Disable web container's nginx ipv6 listener
|
||||
ipv6_disabled: false
|
||||
|
||||
27
roles/installer/filter_plugins/cpu_string_to_decimal.py
Normal file
27
roles/installer/filter_plugins/cpu_string_to_decimal.py
Normal file
@@ -0,0 +1,27 @@
|
||||
# Copyright (c) 2017 Ansible Project
|
||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
|
||||
from __future__ import (absolute_import, division, print_function)
|
||||
__metaclass__ = type
|
||||
|
||||
from ansible.errors import AnsibleFilterError
|
||||
|
||||
__ERROR_MSG = "Not a valid cpu value. Cannot process value"
|
||||
|
||||
class FilterModule(object):
|
||||
def filters(self):
|
||||
return {
|
||||
'cpu_string_to_decimal': self.cpu_string_to_decimal
|
||||
}
|
||||
def cpu_string_to_decimal(self, cpu_string):
|
||||
|
||||
# verify if task_output is a dict
|
||||
if not isinstance(cpu_string, str):
|
||||
raise AnsibleFilterError(__ERROR_MSG)
|
||||
|
||||
if cpu_string[-1] == 'm':
|
||||
cpu = int(cpu_string[:-1])//1000
|
||||
else:
|
||||
cpu = int(cpu_string)
|
||||
|
||||
return cpu
|
||||
@@ -25,7 +25,8 @@ galaxy_info:
|
||||
- cd
|
||||
- deployment
|
||||
|
||||
dependencies: []
|
||||
dependencies:
|
||||
- role: common
|
||||
|
||||
collections:
|
||||
- kubernetes.core
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
- name: Create admin password secret
|
||||
k8s:
|
||||
apply: true
|
||||
definition: "{{ lookup('template', 'admin_password_secret.yaml.j2') }}"
|
||||
definition: "{{ lookup('template', 'secrets/admin_password_secret.yaml.j2') }}"
|
||||
no_log: "{{ no_log }}"
|
||||
|
||||
- name: Read admin password secret
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
- name: Create broadcast websocket secret
|
||||
k8s:
|
||||
apply: true
|
||||
definition: "{{ lookup('template', 'broadcast_websocket_secret.yaml.j2') }}"
|
||||
definition: "{{ lookup('template', 'secrets/broadcast_websocket_secret.yaml.j2') }}"
|
||||
no_log: "{{ no_log }}"
|
||||
|
||||
- name: Read broadcast websocket secret
|
||||
|
||||
@@ -23,6 +23,8 @@
|
||||
- '{{ _secret_key }}'
|
||||
- '{{ _postgres_configuration }}'
|
||||
- '{{ _broadcast_websocket_secret }}'
|
||||
- '{{ ansible_operator_meta.name }}-receptor-ca'
|
||||
- '{{ ansible_operator_meta.name }}-receptor-work-signing'
|
||||
no_log: "{{ no_log }}"
|
||||
|
||||
when: not garbage_collect_secrets | bool
|
||||
|
||||
@@ -71,7 +71,7 @@
|
||||
- name: Create Database configuration
|
||||
k8s:
|
||||
apply: true
|
||||
definition: "{{ lookup('template', 'postgres_secret.yaml.j2') }}"
|
||||
definition: "{{ lookup('template', 'secrets/postgres_secret.yaml.j2') }}"
|
||||
no_log: "{{ no_log }}"
|
||||
|
||||
- name: Read Database Configuration
|
||||
@@ -92,11 +92,67 @@
|
||||
set_fact:
|
||||
__postgres_configuration_secret: "{{ pg_config['resources'][0]['metadata']['name'] }}"
|
||||
|
||||
- name: Store Database Configuration
|
||||
set_fact:
|
||||
awx_postgres_user: "{{ pg_config['resources'][0]['data']['username'] | b64decode }}"
|
||||
awx_postgres_pass: "{{ pg_config['resources'][0]['data']['password'] | b64decode }}"
|
||||
awx_postgres_database: "{{ pg_config['resources'][0]['data']['database'] | b64decode }}"
|
||||
awx_postgres_port: "{{ pg_config['resources'][0]['data']['port'] | b64decode }}"
|
||||
awx_postgres_host: "{{ pg_config['resources'][0]['data']['host'] | b64decode }}"
|
||||
awx_postgres_sslmode: "{{ pg_config['resources'][0]['data']['sslmode'] | default('prefer'|b64encode) | b64decode }}"
|
||||
no_log: "{{ no_log }}"
|
||||
|
||||
- name: Set database as managed
|
||||
set_fact:
|
||||
managed_database: "{{ pg_config['resources'][0]['data']['type'] | default('') | b64decode == 'managed' }}"
|
||||
|
||||
- name: Get the old postgres pod information
|
||||
k8s_info:
|
||||
kind: Pod
|
||||
namespace: "{{ ansible_operator_meta.namespace }}"
|
||||
name: "{{ ansible_operator_meta.name }}-postgres-0"
|
||||
field_selectors:
|
||||
- status.phase=Running
|
||||
register: old_postgres_pod
|
||||
|
||||
- name: Look up details for this deployment
|
||||
k8s_info:
|
||||
api_version: "{{ api_version }}"
|
||||
kind: "{{ kind }}"
|
||||
name: "{{ ansible_operator_meta.name }}"
|
||||
namespace: "{{ ansible_operator_meta.namespace }}"
|
||||
register: this_awx
|
||||
|
||||
- name: Check if postgres pod is running and version 12
|
||||
block:
|
||||
- name: Set path to PG_VERSION file for given container image
|
||||
set_fact:
|
||||
path_to_pg_version: '{{ postgres_data_path }}/PG_VERSION'
|
||||
|
||||
- name: Get old PostgreSQL version
|
||||
k8s_exec:
|
||||
namespace: "{{ ansible_operator_meta.namespace }}"
|
||||
pod: "{{ ansible_operator_meta.name }}-postgres-0"
|
||||
command: |
|
||||
bash -c """
|
||||
cat {{ path_to_pg_version }}
|
||||
"""
|
||||
register: _old_pg_version
|
||||
|
||||
- name: Upgrade data dir from Postgres 12 to 13 if applicable
|
||||
include_tasks: upgrade_postgres.yml
|
||||
when:
|
||||
- _old_pg_version.stdout | default('0') | trim == '12'
|
||||
when:
|
||||
- managed_database
|
||||
- this_awx['resources'][0]['status']['upgradedPostgresVersion'] | default('none') != '12'
|
||||
- old_postgres_pod['resources'] | length # upgrade is complete and old pg pod has been removed
|
||||
|
||||
- block:
|
||||
- name: Create Database if no database is specified
|
||||
k8s:
|
||||
apply: true
|
||||
definition: "{{ lookup('template', 'postgres.yaml.j2') }}"
|
||||
definition: "{{ lookup('template', 'statefulsets/postgres.yaml.j2') }}"
|
||||
register: create_statefulset_result
|
||||
|
||||
- name: Scale down Deployment for migration
|
||||
@@ -111,7 +167,7 @@
|
||||
kubernetes.core.k8s_scale:
|
||||
api_version: apps/v1
|
||||
kind: StatefulSet
|
||||
name: "{{ ansible_operator_meta.name }}-postgres"
|
||||
name: "{{ ansible_operator_meta.name }}-postgres-13"
|
||||
namespace: "{{ ansible_operator_meta.namespace }}"
|
||||
replicas: 0
|
||||
wait: yes
|
||||
@@ -121,7 +177,7 @@
|
||||
state: absent
|
||||
api_version: apps/v1
|
||||
kind: StatefulSet
|
||||
name: "{{ ansible_operator_meta.name }}-postgres"
|
||||
name: "{{ ansible_operator_meta.name }}-postgres-13"
|
||||
namespace: "{{ ansible_operator_meta.namespace }}"
|
||||
wait: yes
|
||||
when: create_statefulset_result.error == 422
|
||||
@@ -129,24 +185,30 @@
|
||||
- name: Recreate PostgreSQL statefulset with updated values
|
||||
k8s:
|
||||
apply: true
|
||||
definition: "{{ lookup('template', 'postgres.yaml.j2') }}"
|
||||
when: pg_config['resources'][0]['data']['type'] | default('') | b64decode == 'managed'
|
||||
definition: "{{ lookup('template', 'statefulsets/postgres.yaml.j2') }}"
|
||||
when: managed_database
|
||||
|
||||
- name: Store Database Configuration
|
||||
- name: Set Default label selector for custom resource generated postgres
|
||||
set_fact:
|
||||
awx_postgres_user: "{{ pg_config['resources'][0]['data']['username'] | b64decode }}"
|
||||
awx_postgres_pass: "{{ pg_config['resources'][0]['data']['password'] | b64decode }}"
|
||||
awx_postgres_database: "{{ pg_config['resources'][0]['data']['database'] | b64decode }}"
|
||||
awx_postgres_port: "{{ pg_config['resources'][0]['data']['port'] | b64decode }}"
|
||||
awx_postgres_host: "{{ pg_config['resources'][0]['data']['host'] | b64decode }}"
|
||||
awx_postgres_sslmode: "{{ pg_config['resources'][0]['data']['sslmode'] | default('prefer'|b64encode) | b64decode }}"
|
||||
no_log: "{{ no_log }}"
|
||||
postgres_label_selector: "app.kubernetes.io/instance=postgres-{{ supported_pg_version }}-{{ ansible_operator_meta.name }}"
|
||||
when: postgres_label_selector is not defined
|
||||
|
||||
- name: Get the postgres pod information
|
||||
k8s_info:
|
||||
kind: Pod
|
||||
namespace: "{{ ansible_operator_meta.namespace }}"
|
||||
label_selectors:
|
||||
- "{{ postgres_label_selector }}"
|
||||
field_selectors:
|
||||
- status.phase=Running
|
||||
register: postgres_pod
|
||||
|
||||
- name: Wait for Database to initialize if managed DB
|
||||
k8s_info:
|
||||
kind: Pod
|
||||
namespace: '{{ ansible_operator_meta.namespace }}'
|
||||
name: '{{ ansible_operator_meta.name }}-postgres-0' # using name to keep compatibility
|
||||
label_selectors:
|
||||
- "{{ postgres_label_selector }}"
|
||||
field_selectors:
|
||||
- status.phase=Running
|
||||
register: postgres_pod
|
||||
@@ -156,11 +218,7 @@
|
||||
- "postgres_pod['resources'][0]['status']['containerStatuses'][0]['ready'] == true"
|
||||
delay: 5
|
||||
retries: 60
|
||||
when: pg_config['resources'][0]['data']['type'] | default('') | b64decode == 'managed'
|
||||
|
||||
- name: Set database as managed
|
||||
set_fact:
|
||||
managed_database: "{{ pg_config['resources'][0]['data']['type'] | default('') | b64decode == 'managed' }}"
|
||||
when: managed_database
|
||||
|
||||
- name: Look up details for this deployment
|
||||
k8s_info:
|
||||
|
||||
@@ -34,6 +34,7 @@
|
||||
bash -c "awx-manage list_instances | grep '^\[tower capacity=[0-9]*\]'"
|
||||
register: legacy_queue
|
||||
changed_when: false
|
||||
ignore_errors: true
|
||||
|
||||
- name: Unregister legacy queue
|
||||
k8s_exec:
|
||||
|
||||
84
roles/installer/tasks/install.yml
Normal file
84
roles/installer/tasks/install.yml
Normal file
@@ -0,0 +1,84 @@
|
||||
---
|
||||
- name: Patching labels to AWX kind
|
||||
k8s:
|
||||
state: present
|
||||
definition:
|
||||
apiVersion: '{{ api_version }}'
|
||||
kind: '{{ kind }}'
|
||||
name: '{{ ansible_operator_meta.name }}'
|
||||
namespace: '{{ ansible_operator_meta.namespace }}'
|
||||
metadata:
|
||||
name: '{{ ansible_operator_meta.name }}'
|
||||
namespace: '{{ ansible_operator_meta.namespace }}'
|
||||
labels: '{{ lookup("template", "labels/common.yaml.j2") | from_yaml }}'
|
||||
when: set_self_labels | bool
|
||||
|
||||
- name: Include secret key configuration tasks
|
||||
include_tasks: secret_key_configuration.yml
|
||||
|
||||
- name: Load LDAP CAcert certificate
|
||||
include_tasks: load_ldap_cacert_secret.yml
|
||||
when:
|
||||
- ldap_cacert_secret != ''
|
||||
|
||||
- name: Load ldap bind password
|
||||
include_tasks: load_ldap_password_secret.yml
|
||||
when:
|
||||
- ldap_password_secret != ''
|
||||
|
||||
- name: Load bundle certificate authority certificate
|
||||
include_tasks: load_bundle_cacert_secret.yml
|
||||
when:
|
||||
- bundle_cacert_secret != ''
|
||||
|
||||
- name: Include admin password configuration tasks
|
||||
include_tasks: admin_password_configuration.yml
|
||||
|
||||
- name: Include broadcast websocket configuration tasks
|
||||
include_tasks: broadcast_websocket_configuration.yml
|
||||
|
||||
- name: Include set_images tasks
|
||||
include_tasks: set_images.yml
|
||||
|
||||
- name: Include database configuration tasks
|
||||
include_tasks: database_configuration.yml
|
||||
|
||||
- name: Load Route TLS certificate
|
||||
include_tasks: load_route_tls_secret.yml
|
||||
when:
|
||||
- ingress_type | lower == 'route'
|
||||
- route_tls_secret != ''
|
||||
|
||||
- name: Include resources configuration tasks
|
||||
include_tasks: resources_configuration.yml
|
||||
|
||||
- name: Check for pending migrations
|
||||
k8s_exec:
|
||||
namespace: "{{ ansible_operator_meta.namespace }}"
|
||||
pod: "{{ tower_pod_name }}"
|
||||
container: "{{ ansible_operator_meta.name }}-task"
|
||||
command: >-
|
||||
bash -c "awx-manage showmigrations | grep -v '[X]' | grep '[ ]' | wc -l"
|
||||
changed_when: false
|
||||
register: database_check
|
||||
|
||||
- name: Migrate the database if the K8s resources were updated. # noqa 305
|
||||
k8s_exec:
|
||||
namespace: "{{ ansible_operator_meta.namespace }}"
|
||||
pod: "{{ tower_pod_name }}"
|
||||
container: "{{ ansible_operator_meta.name }}-task"
|
||||
command: >-
|
||||
bash -c "awx-manage migrate --noinput"
|
||||
register: migrate_result
|
||||
when:
|
||||
- database_check is defined
|
||||
- (database_check.stdout|trim) != '0'
|
||||
|
||||
- name: Initialize Django
|
||||
include_tasks: initialize_django.yml
|
||||
|
||||
- name: Update status variables
|
||||
include_tasks: update_status.yml
|
||||
|
||||
- name: Cleanup & Set garbage collection refs
|
||||
include_tasks: cleanup.yml
|
||||
@@ -1,88 +1,13 @@
|
||||
---
|
||||
- name: Patching labels to AWX kind
|
||||
k8s:
|
||||
state: present
|
||||
definition:
|
||||
apiVersion: '{{ api_version }}'
|
||||
kind: '{{ kind }}'
|
||||
name: '{{ ansible_operator_meta.name }}'
|
||||
namespace: '{{ ansible_operator_meta.namespace }}'
|
||||
metadata:
|
||||
name: '{{ ansible_operator_meta.name }}'
|
||||
namespace: '{{ ansible_operator_meta.namespace }}'
|
||||
labels:
|
||||
app.kubernetes.io/name: '{{ ansible_operator_meta.name }}'
|
||||
app.kubernetes.io/part-of: '{{ ansible_operator_meta.name }}'
|
||||
app.kubernetes.io/managed-by: '{{ deployment_type }}-operator'
|
||||
app.kubernetes.io/component: '{{ deployment_type }}'
|
||||
app.kubernetes.io/operator-version: '{{ lookup("env", "OPERATOR_VERSION") }}'
|
||||
|
||||
- name: Include secret key configuration tasks
|
||||
include_tasks: secret_key_configuration.yml
|
||||
|
||||
- name: Load LDAP CAcert certificate
|
||||
include_tasks: load_ldap_cacert_secret.yml
|
||||
when:
|
||||
- ldap_cacert_secret != ''
|
||||
|
||||
- name: Load ldap bind password
|
||||
include_tasks: load_ldap_password_secret.yml
|
||||
when:
|
||||
- ldap_password_secret != ''
|
||||
|
||||
- name: Load bundle certificate authority certificate
|
||||
include_tasks: load_bundle_cacert_secret.yml
|
||||
when:
|
||||
- bundle_cacert_secret != ''
|
||||
|
||||
- name: Include admin password configuration tasks
|
||||
include_tasks: admin_password_configuration.yml
|
||||
|
||||
- name: Include broadcast websocket configuration tasks
|
||||
include_tasks: broadcast_websocket_configuration.yml
|
||||
|
||||
- name: Include set_images tasks
|
||||
include_tasks: set_images.yml
|
||||
|
||||
- name: Include database configuration tasks
|
||||
include_tasks: database_configuration.yml
|
||||
|
||||
- name: Load Route TLS certificate
|
||||
include_tasks: load_route_tls_secret.yml
|
||||
when:
|
||||
- ingress_type | lower == 'route'
|
||||
- route_tls_secret != ''
|
||||
|
||||
- name: Include resources configuration tasks
|
||||
include_tasks: resources_configuration.yml
|
||||
|
||||
- name: Check for pending migrations
|
||||
k8s_exec:
|
||||
- name: Check for presence of Deployment
|
||||
k8s_info:
|
||||
api_version: v1
|
||||
kind: Deployment
|
||||
name: "{{ ansible_operator_meta.name }}"
|
||||
namespace: "{{ ansible_operator_meta.namespace }}"
|
||||
pod: "{{ tower_pod_name }}"
|
||||
container: "{{ ansible_operator_meta.name }}-task"
|
||||
command: >-
|
||||
bash -c "awx-manage showmigrations | grep -v '[X]' | grep '[ ]' | wc -l"
|
||||
changed_when: false
|
||||
register: database_check
|
||||
register: tower_deployment
|
||||
|
||||
- name: Migrate the database if the K8s resources were updated. # noqa 305
|
||||
k8s_exec:
|
||||
namespace: "{{ ansible_operator_meta.namespace }}"
|
||||
pod: "{{ tower_pod_name }}"
|
||||
container: "{{ ansible_operator_meta.name }}-task"
|
||||
command: >-
|
||||
bash -c "awx-manage migrate --noinput"
|
||||
register: migrate_result
|
||||
when:
|
||||
- database_check is defined
|
||||
- (database_check.stdout|trim) != '0'
|
||||
|
||||
- name: Initialize Django
|
||||
include_tasks: initialize_django.yml
|
||||
|
||||
- name: Update status variables
|
||||
include_tasks: update_status.yml
|
||||
|
||||
- name: Cleanup & Set garbage collection refs
|
||||
include_tasks: cleanup.yml
|
||||
# Just execute deployment steps when auto_upgrade is true or when no deployment exists
|
||||
- name: Start installation
|
||||
include_tasks: install.yml
|
||||
when: (tower_deployment['resources'] | length > 0 and auto_upgrade | bool ) or (tower_deployment['resources'] | length == 0)
|
||||
|
||||
@@ -13,25 +13,20 @@
|
||||
awx_old_postgres_host: "{{ old_pg_config['resources'][0]['data']['host'] | b64decode }}"
|
||||
no_log: "{{ no_log }}"
|
||||
|
||||
- name: Default label selector to custom resource generated postgres
|
||||
- name: Set Default label selector for custom resource generated postgres
|
||||
set_fact:
|
||||
postgres_label_selector: "app.kubernetes.io/instance=postgres-{{ ansible_operator_meta.name }}"
|
||||
postgres_label_selector: "app.kubernetes.io/instance=postgres-{{ supported_pg_version }}-{{ ansible_operator_meta.name }}"
|
||||
when: postgres_label_selector is not defined
|
||||
|
||||
- name: Get the postgres pod information
|
||||
k8s_info:
|
||||
kind: Pod
|
||||
namespace: '{{ ansible_operator_meta.namespace }}'
|
||||
name: '{{ ansible_operator_meta.name }}-postgres-0' # using name to keep compatibility
|
||||
namespace: "{{ ansible_operator_meta.namespace }}"
|
||||
label_selectors:
|
||||
- "{{ postgres_label_selector }}"
|
||||
field_selectors:
|
||||
- status.phase=Running
|
||||
register: postgres_pod
|
||||
until:
|
||||
- "postgres_pod['resources'] | length"
|
||||
- "postgres_pod['resources'][0]['status']['phase'] == 'Running'"
|
||||
- "postgres_pod['resources'][0]['status']['containerStatuses'][0]['ready'] == true"
|
||||
delay: 5
|
||||
retries: 60
|
||||
|
||||
- name: Set the resource pod name as a variable.
|
||||
set_fact:
|
||||
|
||||
@@ -11,11 +11,11 @@
|
||||
- "app.kubernetes.io/component={{ deployment_type }}"
|
||||
field_selectors:
|
||||
- status.phase=Running
|
||||
register: tower_pods
|
||||
register: tower_pod
|
||||
|
||||
- name: Set the resource pod name as a variable.
|
||||
set_fact:
|
||||
tower_pod_name: "{{ tower_pods['resources'][0]['metadata']['name'] | default('') }}"
|
||||
tower_pod_name: "{{ tower_pod['resources'][0]['metadata']['name'] | default('') }}"
|
||||
|
||||
- name: Set user provided control plane ee image
|
||||
set_fact:
|
||||
@@ -27,6 +27,139 @@
|
||||
set_fact:
|
||||
_control_plane_ee_image: "{{ _custom_control_plane_ee_image | default(lookup('env', 'RELATED_IMAGE_CONTROL_PLANE_EE')) | default(_control_plane_ee_image, true) }}"
|
||||
|
||||
- name: Check for Receptor CA Secret
|
||||
k8s_info:
|
||||
kind: Secret
|
||||
namespace: '{{ ansible_operator_meta.namespace }}'
|
||||
name: '{{ ansible_operator_meta.name }}-receptor-ca'
|
||||
register: _receptor_ca
|
||||
no_log: "{{ no_log }}"
|
||||
|
||||
- name: Migrate Receptor CA Secret
|
||||
when:
|
||||
- _receptor_ca['resources'] | default([]) | length
|
||||
- _receptor_ca['resources'][0]['type'] != "kubernetes.io/tls"
|
||||
block:
|
||||
- name: Delete old Receptor CA Secret
|
||||
k8s:
|
||||
state: absent
|
||||
kind: Secret
|
||||
namespace: '{{ ansible_operator_meta.namespace }}'
|
||||
name: '{{ ansible_operator_meta.name }}-receptor-ca'
|
||||
- name: Create tempfile for receptor-ca.key
|
||||
tempfile:
|
||||
state: file
|
||||
suffix: .key
|
||||
register: _receptor_ca_key_file
|
||||
- name: Copy Receptor CA key from old secret to tempfile
|
||||
copy:
|
||||
content: "{{ _receptor_ca['resources'][0]['data']['receptor-ca.key'] | b64decode }}"
|
||||
dest: "{{ _receptor_ca_key_file.path }}"
|
||||
no_log: "{{ no_log }}"
|
||||
- name: Create tempfile for receptor-ca.crt
|
||||
tempfile:
|
||||
state: file
|
||||
suffix: .crt
|
||||
register: _receptor_ca_crt_file
|
||||
- name: Copy Receptor CA cert from old secret to tempfile
|
||||
copy:
|
||||
content: "{{ _receptor_ca['resources'][0]['data']['receptor-ca.crt'] | b64decode }}"
|
||||
dest: "{{ _receptor_ca_crt_file.path }}"
|
||||
no_log: "{{ no_log }}"
|
||||
- name: Create New Receptor CA secret
|
||||
k8s:
|
||||
apply: true
|
||||
definition: "{{ lookup('template', 'secrets/receptor_ca_secret.yaml.j2') }}"
|
||||
no_log: "{{ no_log }}"
|
||||
- name: Remove tempfiles
|
||||
file:
|
||||
path: "{{ item }}"
|
||||
state: absent
|
||||
loop:
|
||||
- "{{ _receptor_ca_key_file.path }}"
|
||||
- "{{ _receptor_ca_crt_file.path }}"
|
||||
|
||||
- name: Create Receptor Mesh CA
|
||||
block:
|
||||
- name: Create tempfile for receptor-ca.key
|
||||
tempfile:
|
||||
state: file
|
||||
suffix: .key
|
||||
register: _receptor_ca_key_file
|
||||
- name: Generate Receptor CA key
|
||||
command: |
|
||||
openssl genrsa -out {{ _receptor_ca_key_file.path }} 4096
|
||||
no_log: "{{ no_log }}"
|
||||
- name: Create tempfile for receptor-ca.crt
|
||||
tempfile:
|
||||
state: file
|
||||
suffix: .crt
|
||||
register: _receptor_ca_crt_file
|
||||
- name: Generate Receptor CA cert
|
||||
command: |
|
||||
openssl req -x509 -new -nodes -key {{ _receptor_ca_key_file.path }} \
|
||||
-subj "/CN={{ ansible_operator_meta.name }} Receptor Root CA" \
|
||||
-sha256 -days 3650 -out {{ _receptor_ca_crt_file.path }}
|
||||
no_log: "{{ no_log }}"
|
||||
- name: Create Receptor CA secret
|
||||
k8s:
|
||||
apply: true
|
||||
definition: "{{ lookup('template', 'secrets/receptor_ca_secret.yaml.j2') }}"
|
||||
no_log: "{{ no_log }}"
|
||||
- name: Remove tempfiles
|
||||
file:
|
||||
path: "{{ item }}"
|
||||
state: absent
|
||||
loop:
|
||||
- "{{ _receptor_ca_key_file.path }}"
|
||||
- "{{ _receptor_ca_crt_file.path }}"
|
||||
when: not _receptor_ca['resources'] | default([]) | length
|
||||
|
||||
- name: Check for Receptor work signing Secret
|
||||
k8s_info:
|
||||
kind: Secret
|
||||
namespace: '{{ ansible_operator_meta.namespace }}'
|
||||
name: '{{ ansible_operator_meta.name }}-receptor-work-signing'
|
||||
register: _receptor_work_signing
|
||||
no_log: "{{ no_log }}"
|
||||
|
||||
- name: Generate Receptor work signing RSA key pair
|
||||
block:
|
||||
- name: Create tempfile for receptor work signing private key
|
||||
tempfile:
|
||||
state: file
|
||||
suffix: .pem
|
||||
register: _receptor_work_signing_private_key_file
|
||||
- name: Generate Receptor work signing private key
|
||||
command: |
|
||||
openssl genrsa -out {{ _receptor_work_signing_private_key_file.path }} 4096
|
||||
no_log: "{{ no_log }}"
|
||||
- name: Create tempfile for receptor work signing public key
|
||||
tempfile:
|
||||
state: file
|
||||
suffix: .pem
|
||||
register: _receptor_work_signing_public_key_file
|
||||
- name: Generate Receptor work signing public key
|
||||
command: |
|
||||
openssl rsa \
|
||||
-in {{ _receptor_work_signing_private_key_file.path }} \
|
||||
-out {{ _receptor_work_signing_public_key_file.path }} \
|
||||
-outform PEM -pubout
|
||||
no_log: "{{ no_log }}"
|
||||
- name: Create Receptor work signing Secret
|
||||
k8s:
|
||||
apply: true
|
||||
definition: "{{ lookup('template', 'secrets/receptor_work_signing_secret.yaml.j2') }}"
|
||||
no_log: "{{ no_log }}"
|
||||
- name: Remove tempfiles
|
||||
file:
|
||||
path: "{{ item }}"
|
||||
state: absent
|
||||
loop:
|
||||
- "{{ _receptor_work_signing_private_key_file.path }}"
|
||||
- "{{ _receptor_work_signing_public_key_file.path }}"
|
||||
when: not _receptor_work_signing['resources'] | default([]) | length
|
||||
|
||||
- name: Apply Resources
|
||||
k8s:
|
||||
apply: yes
|
||||
@@ -34,12 +167,12 @@
|
||||
wait: yes
|
||||
register: tower_resources_result
|
||||
loop:
|
||||
- 'config'
|
||||
- 'app_credentials'
|
||||
- 'service_account'
|
||||
- 'persistent'
|
||||
- 'service'
|
||||
- 'ingress'
|
||||
- 'configmaps/config'
|
||||
- 'secrets/app_credentials'
|
||||
- 'rbac/service_account'
|
||||
- 'storage/persistent'
|
||||
- 'networking/service'
|
||||
- 'networking/ingress'
|
||||
no_log: "{{ no_log }}"
|
||||
|
||||
- name: Set default awx app image
|
||||
@@ -75,9 +208,9 @@
|
||||
- name: Apply deployment resources
|
||||
k8s:
|
||||
apply: yes
|
||||
definition: "{{ lookup('template', 'deployment.yaml.j2') }}"
|
||||
definition: "{{ lookup('template', 'deployments/deployment.yaml.j2') }}"
|
||||
wait: yes
|
||||
register: tower_deployment_result
|
||||
register: this_deployment_result
|
||||
|
||||
- block:
|
||||
- name: Delete pod to reload a resource configuration
|
||||
@@ -113,7 +246,7 @@
|
||||
set_fact:
|
||||
tower_pod_name: '{{ _new_pod["resources"][0]["metadata"]["name"] }}'
|
||||
when:
|
||||
- tower_resources_result.changed or tower_deployment_result.changed
|
||||
- tower_resources_result.changed or this_deployment_result.changed
|
||||
|
||||
- name: Verify the resource pod name is populated.
|
||||
assert:
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
kind: Deployment
|
||||
name: "{{ ansible_operator_meta.name }}"
|
||||
namespace: "{{ ansible_operator_meta.namespace }}"
|
||||
register: tower_deployment
|
||||
register: this_deployment
|
||||
|
||||
- name: Scale down Deployment for migration
|
||||
kubernetes.core.k8s_scale:
|
||||
@@ -16,4 +16,4 @@
|
||||
namespace: "{{ ansible_operator_meta.namespace }}"
|
||||
replicas: 0
|
||||
wait: yes
|
||||
when: tower_deployment['resources'] | length
|
||||
when: this_deployment['resources'] | length
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
- name: Create secret key secret
|
||||
k8s:
|
||||
apply: true
|
||||
definition: "{{ lookup('template', 'secret_key.yaml.j2') }}"
|
||||
definition: "{{ lookup('template', 'secrets/secret_key.yaml.j2') }}"
|
||||
no_log: "{{ no_log }}"
|
||||
|
||||
- name: Read secret key secret
|
||||
|
||||
@@ -101,3 +101,13 @@
|
||||
status:
|
||||
migratedFromSecret: "{{ tower_migrated_from_secret }}"
|
||||
when: tower_migrated_from_secret is defined
|
||||
|
||||
- name: Update upgradedPostgresVersion status
|
||||
operator_sdk.util.k8s_status:
|
||||
api_version: '{{ api_version }}'
|
||||
kind: "{{ kind }}"
|
||||
name: "{{ ansible_operator_meta.name }}"
|
||||
namespace: "{{ ansible_operator_meta.namespace }}"
|
||||
status:
|
||||
upgradedPostgresVersion: "{{ upgraded_postgres_version }}"
|
||||
when: upgraded_postgres_version is defined
|
||||
|
||||
132
roles/installer/tasks/upgrade_postgres.yml
Normal file
132
roles/installer/tasks/upgrade_postgres.yml
Normal file
@@ -0,0 +1,132 @@
|
||||
---
|
||||
|
||||
# Upgrade Posgres (Managed Databases only)
|
||||
# * If postgres version is not 12, and not an external postgres instance (when managed_database is yes),
|
||||
# then run this playbook with include_tasks from database_configuration.yml
|
||||
# * Data will be streamed via a pg_dump from the postgres 12 pod to the postgres 13
|
||||
# pod via a pg_restore.
|
||||
|
||||
|
||||
- name: Scale down Deployment for migration
|
||||
include_tasks: scale_down_deployment.yml
|
||||
|
||||
- name: Delete existing postgres configuration secret
|
||||
k8s:
|
||||
api_version: v1
|
||||
kind: Secret
|
||||
name: "{{ ansible_operator_meta.name }}-postgres-configuration"
|
||||
namespace: "{{ ansible_operator_meta.namespace }}"
|
||||
state: absent
|
||||
wait: yes
|
||||
|
||||
- name: Create Database configuration with new -postgres-{{ supported_pg_version }} hostname
|
||||
k8s:
|
||||
apply: true
|
||||
definition: "{{ lookup('template', 'secrets/postgres_upgrade_secret.yaml.j2') }}"
|
||||
no_log: "{{ no_log }}"
|
||||
|
||||
- name: Set new database var to be used when configuring app credentials (resources_configuration.yml)
|
||||
set_fact:
|
||||
awx_postgres_host: "{{ ansible_operator_meta.name }}-postgres-{{ supported_pg_version }}"
|
||||
no_log: "{{ no_log }}"
|
||||
|
||||
- name: Create Database if no database is specified
|
||||
k8s:
|
||||
apply: true
|
||||
definition: "{{ lookup('template', 'statefulsets/postgres.yaml.j2') }}"
|
||||
wait: true
|
||||
register: create_statefulset_result
|
||||
|
||||
- name: Set postgres label if not defined by user
|
||||
set_fact:
|
||||
postgres_label_selector: "app.kubernetes.io/instance=postgres-{{ supported_pg_version }}-{{ ansible_operator_meta.name }}"
|
||||
when: postgres_label_selector is not defined
|
||||
|
||||
- name: Get new postgres pod information
|
||||
k8s_info:
|
||||
kind: Pod
|
||||
namespace: "{{ ansible_operator_meta.namespace }}"
|
||||
label_selectors:
|
||||
- "{{ postgres_label_selector }}"
|
||||
field_selectors:
|
||||
- status.phase=Running
|
||||
register: postgres_pod
|
||||
until:
|
||||
- "postgres_pod['resources'] | length"
|
||||
- "postgres_pod['resources'][0]['status']['phase'] == 'Running'"
|
||||
- "postgres_pod['resources'][0]['status']['containerStatuses'][0]['ready'] == true"
|
||||
delay: 5
|
||||
retries: 60
|
||||
|
||||
- name: Set the resource pod name as a variable.
|
||||
set_fact:
|
||||
postgres_pod_name: "{{ postgres_pod['resources'][0]['metadata']['name'] }}"
|
||||
|
||||
- name: Set full resolvable host name for postgres pod
|
||||
set_fact:
|
||||
resolvable_db_host: "{{ ansible_operator_meta.name }}-postgres.{{ ansible_operator_meta.namespace }}.svc" # yamllint disable-line rule:line-length
|
||||
no_log: "{{ no_log }}"
|
||||
|
||||
- name: Set pg_dump command
|
||||
set_fact:
|
||||
pgdump: >-
|
||||
pg_dump
|
||||
-h {{ resolvable_db_host }}
|
||||
-U {{ awx_postgres_user }}
|
||||
-d {{ awx_postgres_database }}
|
||||
-p {{ awx_postgres_port }}
|
||||
-F custom
|
||||
no_log: "{{ no_log }}"
|
||||
|
||||
- name: Set pg_restore command
|
||||
set_fact:
|
||||
pg_restore: >-
|
||||
pg_restore
|
||||
-U {{ awx_postgres_user }}
|
||||
-d {{ awx_postgres_database }}
|
||||
no_log: "{{ no_log }}"
|
||||
|
||||
- name: Stream backup from pg_dump to the new postgresql container
|
||||
k8s_exec:
|
||||
namespace: "{{ ansible_operator_meta.namespace }}"
|
||||
pod: "{{ postgres_pod_name }}"
|
||||
command: |
|
||||
bash -c """
|
||||
set -e -o pipefail
|
||||
PGPASSWORD={{ awx_postgres_pass }} {{ pgdump }} | PGPASSWORD={{ awx_postgres_pass }} {{ pg_restore }}
|
||||
echo 'Successful'
|
||||
"""
|
||||
no_log: "{{ no_log }}"
|
||||
register: data_migration
|
||||
failed_when: "'Successful' not in data_migration.stdout"
|
||||
|
||||
- name: Set flag signifying that this instance has been migrated
|
||||
set_fact:
|
||||
upgraded_postgres_version: '13'
|
||||
|
||||
# Cleanup old Postgres resources
|
||||
- name: Remove old Postgres StatefulSet
|
||||
k8s:
|
||||
kind: StatefulSet
|
||||
api_version: v1
|
||||
namespace: "{{ ansible_operator_meta.namespace }}"
|
||||
name: "{{ ansible_operator_meta.name }}-postgres"
|
||||
state: absent
|
||||
wait: true
|
||||
|
||||
- name: Remove old Postgres Service
|
||||
k8s:
|
||||
kind: Service
|
||||
api_version: v1
|
||||
namespace: "{{ ansible_operator_meta.namespace }}"
|
||||
name: "{{ ansible_operator_meta.name }}-postgres"
|
||||
state: absent
|
||||
|
||||
- name: Remove old persistent volume claim
|
||||
k8s:
|
||||
kind: PersistentVolumeClaim
|
||||
api_version: v1
|
||||
namespace: "{{ ansible_operator_meta.namespace }}"
|
||||
name: "postgres-{{ ansible_operator_meta.name }}-postgres-0"
|
||||
state: absent
|
||||
when: postgres_keep_pvc_after_upgrade
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user