mirror of
https://github.com/ansible/awx-operator.git
synced 2026-03-27 05:43:11 +00:00
Compare commits
27 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a534c856db | ||
|
|
acda72558f | ||
|
|
9e2eb16b67 | ||
|
|
6b02c2c53b | ||
|
|
0ca3f1a7c4 | ||
|
|
69474557eb | ||
|
|
48e3a96305 | ||
|
|
da7e227f71 | ||
|
|
98d5ac126d | ||
|
|
cb5db01406 | ||
|
|
494384c1d7 | ||
|
|
34c2e48e0a | ||
|
|
122995fda7 | ||
|
|
9761c78fe9 | ||
|
|
062c7153c6 | ||
|
|
6ef4aed024 | ||
|
|
3fe42ed4b9 | ||
|
|
2ff1d35b6d | ||
|
|
d3934d9e08 | ||
|
|
3c8ce3718a | ||
|
|
66f03c3c16 | ||
|
|
7e2c2bf92c | ||
|
|
7b95f03a30 | ||
|
|
b0cb1cc07d | ||
|
|
5be4c13016 | ||
|
|
07427be0b7 | ||
|
|
c23bc68900 |
35
.github/workflows/devel.yaml
vendored
35
.github/workflows/devel.yaml
vendored
@@ -13,15 +13,36 @@ jobs:
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Build Image
|
||||
- name: Fail if QUAY_REGISTRY not set
|
||||
run: |
|
||||
IMG=awx-operator:devel make docker-build
|
||||
if [[ -z "${{ vars.QUAY_REGISTRY }}" ]]; then
|
||||
echo "QUAY_REGISTRY not set. Please set QUAY_REGISTRY in variable GitHub Actions variables."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
- name: Push To Quay
|
||||
uses: redhat-actions/push-to-registry@v2.1.1
|
||||
- name: Log into registry ghcr.io
|
||||
uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d # v3.0.0
|
||||
with:
|
||||
image: awx-operator
|
||||
tags: devel
|
||||
registry: quay.io/ansible/
|
||||
registry: ghcr.io
|
||||
username: ${{ github.actor }}
|
||||
password: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
|
||||
- name: Log into registry quay.io
|
||||
uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d # v3.0.0
|
||||
with:
|
||||
registry: ${{ vars.QUAY_REGISTRY }}
|
||||
username: ${{ secrets.QUAY_USER }}
|
||||
password: ${{ secrets.QUAY_TOKEN }}
|
||||
|
||||
|
||||
- name: Build and Store Image @ghcr
|
||||
run: |
|
||||
IMG=ghcr.io/${{ github.repository }}:${{ github.sha }} make docker-buildx
|
||||
|
||||
|
||||
- name: Publish Image to quay.io
|
||||
run: |
|
||||
docker buildx imagetools create \
|
||||
ghcr.io/${{ github.repository }}:${{ github.sha }} \
|
||||
--tag ${{ vars.QUAY_REGISTRY }}/awx-operator:devel
|
||||
|
||||
61
.github/workflows/promote.yaml
vendored
61
.github/workflows/promote.yaml
vendored
@@ -8,47 +8,76 @@ on:
|
||||
tag_name:
|
||||
description: 'Name for the tag of the release.'
|
||||
required: true
|
||||
quay_registry:
|
||||
description: 'Quay registry to push to.'
|
||||
default: 'quay.io/ansible'
|
||||
|
||||
env:
|
||||
QUAY_REGISTRY: ${{ vars.QUAY_REGISTRY }}
|
||||
|
||||
jobs:
|
||||
promote:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Set TAG_NAME for workflow_dispatch event
|
||||
- name: Set GitHub Env vars for workflow_dispatch event
|
||||
if: ${{ github.event_name == 'workflow_dispatch' }}
|
||||
run: |
|
||||
echo "TAG_NAME=${{ github.event.inputs.tag_name }}" >> $GITHUB_ENV
|
||||
echo "QUAY_REGISTRY=${{ github.event.inputs.quay_registry }}" >> $GITHUB_ENV
|
||||
|
||||
- name: Set TAG_NAME for release event
|
||||
- name: Set GitHub Env vars if release event
|
||||
if: ${{ github.event_name == 'release' }}
|
||||
run: |
|
||||
echo "TAG_NAME=${{ github.event.release.tag_name }}" >> $GITHUB_ENV
|
||||
|
||||
- name: Fail if QUAY_REGISTRY not set
|
||||
run: |
|
||||
if [[ -z "${{ env.QUAY_REGISTRY }}" ]]; then
|
||||
echo "QUAY_REGISTRY not set. Please set QUAY_REGISTRY in variable GitHub Actions variables."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
- uses: actions/checkout@v3
|
||||
with:
|
||||
depth: 0
|
||||
|
||||
- name: Log in to GHCR
|
||||
run: |
|
||||
echo ${{ secrets.GITHUB_TOKEN }} | docker login ghcr.io -u ${{ github.actor }} --password-stdin
|
||||
|
||||
- name: Log in to Quay
|
||||
run: |
|
||||
echo ${{ secrets.QUAY_TOKEN }} | docker login quay.io -u ${{ secrets.QUAY_USER }} --password-stdin
|
||||
- name: Log into registry ghcr.io
|
||||
uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d # v3.0.0
|
||||
with:
|
||||
registry: ghcr.io
|
||||
username: ${{ github.actor }}
|
||||
password: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Re-tag and promote awx-operator image
|
||||
|
||||
- name: Log into registry quay.io
|
||||
uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d # v3.0.0
|
||||
with:
|
||||
registry: ${{ env.QUAY_REGISTRY }}
|
||||
username: ${{ secrets.QUAY_USER }}
|
||||
password: ${{ secrets.QUAY_TOKEN }}
|
||||
|
||||
|
||||
- name: Pull Tagged Staged Image and Publish to quay.io
|
||||
run: |
|
||||
docker pull ghcr.io/${{ github.repository }}:${TAG_NAME}
|
||||
docker tag ghcr.io/${{ github.repository }}:${TAG_NAME} quay.io/${{ github.repository }}:${TAG_NAME}
|
||||
docker tag ghcr.io/${{ github.repository }}:${TAG_NAME} quay.io/${{ github.repository }}:latest
|
||||
docker push quay.io/${{ github.repository }}:${TAG_NAME}
|
||||
docker push quay.io/${{ github.repository }}:latest
|
||||
docker buildx imagetools create \
|
||||
ghcr.io/${{ github.repository }}:${{ env.TAG_NAME }} \
|
||||
--tag ${{ env.QUAY_REGISTRY }}/awx-operator:${{ env.TAG_NAME }}
|
||||
|
||||
|
||||
- name: Pull Staged Image and Publish to quay.io/${{ github.repository }}:latest
|
||||
run: |
|
||||
docker buildx imagetools create \
|
||||
ghcr.io/${{ github.repository }}:${{ env.TAG_NAME }} \
|
||||
--tag ${{ env.QUAY_REGISTRY }}/awx-operator:latest
|
||||
|
||||
|
||||
- name: Release Helm chart
|
||||
run: |
|
||||
ansible-playbook ansible/helm-release.yml -v \
|
||||
-e operator_image=quay.io/${{ github.repository }} \
|
||||
-e operator_image=${{ env.QUAY_REGISTRY }}/awx-operator \
|
||||
-e chart_owner=${{ github.repository_owner }} \
|
||||
-e tag=${TAG_NAME} \
|
||||
-e tag=${{ env.TAG_NAME }} \
|
||||
-e gh_token=${{ secrets.GITHUB_TOKEN }} \
|
||||
-e gh_user=${{ github.actor }} \
|
||||
-e repo_type=https
|
||||
|
||||
39
.github/workflows/stage.yml
vendored
39
.github/workflows/stage.yml
vendored
@@ -37,12 +37,6 @@ jobs:
|
||||
|
||||
exit 0
|
||||
|
||||
- name: Checkout awx
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
repository: ${{ github.repository_owner }}/awx
|
||||
path: awx
|
||||
|
||||
- name: Checkout awx-operator
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
@@ -53,17 +47,20 @@ jobs:
|
||||
run: |
|
||||
python3 -m pip install docker
|
||||
|
||||
- name: Log in to GHCR
|
||||
run: |
|
||||
echo ${{ secrets.GITHUB_TOKEN }} | docker login ghcr.io -u ${{ github.actor }} --password-stdin
|
||||
- name: Log into registry ghcr.io
|
||||
uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d # v3.0.0
|
||||
with:
|
||||
registry: ghcr.io
|
||||
username: ${{ github.actor }}
|
||||
password: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Build and stage awx-operator
|
||||
- name: Stage awx-operator
|
||||
working-directory: awx-operator
|
||||
run: |
|
||||
BUILD_ARGS="--build-arg DEFAULT_AWX_VERSION=${{ github.event.inputs.default_awx_version }} \
|
||||
--build-arg OPERATOR_VERSION=${{ github.event.inputs.version }}" \
|
||||
IMAGE_TAG_BASE=ghcr.io/${{ github.repository_owner }}/awx-operator \
|
||||
VERSION=${{ github.event.inputs.version }} make docker-build docker-push
|
||||
--build-arg OPERATOR_VERSION=${{ github.event.inputs.version }}" \
|
||||
IMG=ghcr.io/${{ github.repository }}:${{ github.event.inputs.version }} \
|
||||
make docker-buildx
|
||||
|
||||
- name: Run test deployment
|
||||
working-directory: awx-operator
|
||||
@@ -76,10 +73,12 @@ jobs:
|
||||
env:
|
||||
AWX_TEST_VERSION: ${{ github.event.inputs.default_awx_version }}
|
||||
|
||||
- name: Create draft release
|
||||
working-directory: awx
|
||||
run: |
|
||||
ansible-playbook tools/ansible/stage.yml \
|
||||
-e version=${{ github.event.inputs.version }} \
|
||||
-e repo=${{ github.repository_owner }}/awx-operator \
|
||||
-e github_token=${{ secrets.GITHUB_TOKEN }}
|
||||
- name: Create Draft Release
|
||||
id: create_release
|
||||
uses: actions/create-release@v1
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
with:
|
||||
tag_name: ${{ github.event.inputs.version }}
|
||||
release_name: Release ${{ github.event.inputs.version }}
|
||||
draft: true
|
||||
|
||||
@@ -25,7 +25,7 @@ Have questions about this document or anything not covered here? Please file a n
|
||||
|
||||
|
||||
## Submmiting your work
|
||||
1. From your fork `devel` branch, create a new brach to stage your changes.
|
||||
1. From your fork `devel` branch, create a new branch to stage your changes.
|
||||
```sh
|
||||
#> git checkout -b <branch-name>
|
||||
```
|
||||
|
||||
19
Makefile
19
Makefile
@@ -107,6 +107,21 @@ docker-build: ## Build docker image with the manager.
|
||||
docker-push: ## Push docker image with the manager.
|
||||
${CONTAINER_CMD} push ${IMG}
|
||||
|
||||
# PLATFORMS defines the target platforms for the manager image be build to provide support to multiple
|
||||
# architectures. (i.e. make docker-buildx IMG=myregistry/mypoperator:0.0.1). To use this option you need to:
|
||||
# - able to use docker buildx . More info: https://docs.docker.com/build/buildx/
|
||||
# - have enable BuildKit, More info: https://docs.docker.com/develop/develop-images/build_enhancements/
|
||||
# - be able to push the image for your registry (i.e. if you do not inform a valid value via IMG=<myregistry/image:<tag>> than the export will fail)
|
||||
# To properly provided solutions that supports more than one platform you should use this option.
|
||||
PLATFORMS ?= linux/arm64,linux/amd64,linux/s390x,linux/ppc64le
|
||||
.PHONY: docker-buildx
|
||||
docker-buildx: ## Build and push docker image for the manager for cross-platform support
|
||||
- docker buildx create --name project-v3-builder
|
||||
docker buildx use project-v3-builder
|
||||
- docker buildx build --push $(BUILD_ARGS) --platform=$(PLATFORMS) --tag ${IMG} -f Dockerfile .
|
||||
- docker buildx rm project-v3-builder
|
||||
|
||||
|
||||
##@ Deployment
|
||||
|
||||
.PHONY: install
|
||||
@@ -162,7 +177,7 @@ ifeq (,$(shell which operator-sdk 2>/dev/null))
|
||||
@{ \
|
||||
set -e ;\
|
||||
mkdir -p $(dir $(OPERATOR_SDK)) ;\
|
||||
curl -sSLo $(OPERATOR_SDK) https://github.com/operator-framework/operator-sdk/releases/download/v1.32.0/operator-sdk_$(OS)_$(ARCHA) ;\
|
||||
curl -sSLo $(OPERATOR_SDK) https://github.com/operator-framework/operator-sdk/releases/download/v1.33.0/operator-sdk_$(OS)_$(ARCHA) ;\
|
||||
chmod +x $(OPERATOR_SDK) ;\
|
||||
}
|
||||
else
|
||||
@@ -178,7 +193,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.32.0/ansible-operator_$(OS)_$(ARCHA) ;\
|
||||
curl -sSLo $(ANSIBLE_OPERATOR) https://github.com/operator-framework/ansible-operator-plugins/releases/download/v1.34.0/ansible-operator_$(OS)_$(ARCHA) ;\
|
||||
chmod +x $(ANSIBLE_OPERATOR) ;\
|
||||
}
|
||||
else
|
||||
|
||||
11
PROJECT
11
PROJECT
@@ -1,3 +1,7 @@
|
||||
# Code generated by tool. DO NOT EDIT.
|
||||
# This file is used to track the info used to scaffold your project
|
||||
# and allow the plugins properly work.
|
||||
# More info: https://book.kubebuilder.io/reference/project-config.html
|
||||
domain: ansible.com
|
||||
layout:
|
||||
- ansible.sdk.operatorframework.io/v1
|
||||
@@ -27,4 +31,11 @@ resources:
|
||||
group: awx
|
||||
kind: AWXRestore
|
||||
version: v1beta1
|
||||
- api:
|
||||
crdVersion: v1
|
||||
namespaced: true
|
||||
domain: ansible.com
|
||||
group: awx
|
||||
kind: AWXMeshIngress
|
||||
version: v1alpha1
|
||||
version: "3"
|
||||
|
||||
@@ -14,7 +14,7 @@ An [Ansible AWX](https://github.com/ansible/awx) operator for Kubernetes built w
|
||||
|
||||
# AWX Operator Documentation
|
||||
|
||||
The AWX Operator documentation is now available at https://awx-operator.readthedocs.io/en/latest/
|
||||
The AWX Operator documentation is now available at https://awx-operator.readthedocs.io/
|
||||
|
||||
For docs changes, create PRs on the appropriate files in the /docs folder.
|
||||
|
||||
|
||||
7
awxmeshingress-demo.yml
Normal file
7
awxmeshingress-demo.yml
Normal file
@@ -0,0 +1,7 @@
|
||||
---
|
||||
apiVersion: awx.ansible.com/v1beta1
|
||||
kind: AWXMeshIngress
|
||||
metadata:
|
||||
name: awx-demo
|
||||
spec:
|
||||
deployment_name: awx-demo
|
||||
81
config/crd/bases/awx.ansible.com_awxmeshingresses.yaml
Normal file
81
config/crd/bases/awx.ansible.com_awxmeshingresses.yaml
Normal file
@@ -0,0 +1,81 @@
|
||||
---
|
||||
apiVersion: apiextensions.k8s.io/v1
|
||||
kind: CustomResourceDefinition
|
||||
metadata:
|
||||
name: awxmeshingresses.awx.ansible.com
|
||||
spec:
|
||||
group: awx.ansible.com
|
||||
names:
|
||||
kind: AWXMeshIngress
|
||||
listKind: AWXMeshIngressList
|
||||
plural: awxmeshingresses
|
||||
singular: awxmeshingress
|
||||
scope: Namespaced
|
||||
versions:
|
||||
- name: v1alpha1
|
||||
schema:
|
||||
openAPIV3Schema:
|
||||
description: AWXMeshIngress is the Schema for the awxmeshingresses API
|
||||
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:
|
||||
description: Spec defines the desired state of AWXMeshIngress
|
||||
type: object
|
||||
x-kubernetes-preserve-unknown-fields: true
|
||||
required:
|
||||
- deployment_name
|
||||
properties:
|
||||
deployment_name:
|
||||
description: Name of the AWX deployment to create the Mesh Ingress for.
|
||||
type: string
|
||||
external_hostname:
|
||||
description: External hostname to use for the Mesh Ingress.
|
||||
type: string
|
||||
external_ipaddress:
|
||||
description: External IP address to use for the Mesh Ingress.
|
||||
type: string
|
||||
ingress_type:
|
||||
description: The ingress type to use to reach the deployed instance
|
||||
type: string
|
||||
enum:
|
||||
- none
|
||||
- Ingress
|
||||
- ingress
|
||||
- IngressRouteTCP
|
||||
- ingressroutetcp
|
||||
- Route
|
||||
- route
|
||||
ingress_api_version:
|
||||
description: The Ingress API version to use
|
||||
type: string
|
||||
ingress_annotations:
|
||||
description: Annotations to add to the Ingress Controller
|
||||
type: string
|
||||
ingress_class_name:
|
||||
description: The name of ingress class to use instead of the cluster default.
|
||||
type: string
|
||||
ingress_controller:
|
||||
description: Special configuration for specific Ingress Controllers
|
||||
type: string
|
||||
status:
|
||||
description: Status defines the observed state of AWXMeshIngress
|
||||
type: object
|
||||
x-kubernetes-preserve-unknown-fields: true
|
||||
type: object
|
||||
served: true
|
||||
storage: true
|
||||
subresources:
|
||||
status: {}
|
||||
@@ -54,8 +54,8 @@ spec:
|
||||
description: Username to use for the admin account
|
||||
type: string
|
||||
default: admin
|
||||
hostname:
|
||||
description: The hostname of the instance
|
||||
hostname: # deprecated
|
||||
description: (Deprecated) The hostname of the instance
|
||||
type: string
|
||||
admin_email:
|
||||
description: The admin user email
|
||||
@@ -123,12 +123,24 @@ spec:
|
||||
ingress_annotations:
|
||||
description: Annotations to add to the Ingress Controller
|
||||
type: string
|
||||
ingress_tls_secret:
|
||||
description: Secret where the Ingress TLS secret can be found
|
||||
ingress_tls_secret: # deprecated
|
||||
description: (Deprecated) Secret where the Ingress TLS secret can be found
|
||||
type: string
|
||||
ingress_class_name:
|
||||
description: The name of ingress class to use instead of the cluster default.
|
||||
type: string
|
||||
ingress_hosts:
|
||||
description: Ingress hostnames of the instance
|
||||
type: array
|
||||
items:
|
||||
type: object
|
||||
properties:
|
||||
hostname:
|
||||
description: Hostname of the instance
|
||||
type: string
|
||||
tls_secret:
|
||||
description: Secret where the Ingress TLS secret can be found
|
||||
type: string
|
||||
ingress_controller:
|
||||
description: Special configuration for specific Ingress Controllers
|
||||
type: string
|
||||
|
||||
@@ -5,4 +5,5 @@ resources:
|
||||
- bases/awx.ansible.com_awxs.yaml
|
||||
- bases/awx.ansible.com_awxbackups.yaml
|
||||
- bases/awx.ansible.com_awxrestores.yaml
|
||||
- bases/awx.ansible.com_awxmeshingresses.yaml
|
||||
#+kubebuilder:scaffold:crdkustomizeresource
|
||||
|
||||
@@ -39,6 +39,7 @@ spec:
|
||||
- --leader-elect
|
||||
- --leader-election-id=awx-operator
|
||||
image: controller:latest
|
||||
imagePullPolicy: Always
|
||||
name: awx-manager
|
||||
env:
|
||||
- name: ANSIBLE_GATHERING
|
||||
|
||||
@@ -212,7 +212,7 @@ spec:
|
||||
kind: AWX
|
||||
name: awxs.awx.ansible.com
|
||||
specDescriptors:
|
||||
- displayName: Hostname
|
||||
- displayName: Hostname (Deprecated)
|
||||
path: hostname
|
||||
x-descriptors:
|
||||
- urn:alm:descriptor:com.tectonic.ui:advanced
|
||||
@@ -302,12 +302,17 @@ spec:
|
||||
- urn:alm:descriptor:com.tectonic.ui:advanced
|
||||
- urn:alm:descriptor:com.tectonic.ui:text
|
||||
- urn:alm:descriptor:com.tectonic.ui:fieldDependency:ingress_type:Ingress
|
||||
- displayName: Ingress TLS Secret
|
||||
- displayName: Ingress TLS Secret (Deprecated)
|
||||
path: ingress_tls_secret
|
||||
x-descriptors:
|
||||
- urn:alm:descriptor:com.tectonic.ui:advanced
|
||||
- urn:alm:descriptor:io.kubernetes:Secret
|
||||
- urn:alm:descriptor:com.tectonic.ui:fieldDependency:ingress_type:Ingress
|
||||
- displayName: Ingress Hosts
|
||||
path: ingress_hosts
|
||||
x-descriptors:
|
||||
- urn:alm:descriptor:com.tectonic.ui:advanced
|
||||
- urn:alm:descriptor:com.tectonic.ui:text
|
||||
- displayName: Ingress Controller
|
||||
path: ingress_controller
|
||||
x-descriptors:
|
||||
|
||||
31
config/rbac/awxmeshingress_editor_role.yaml
Normal file
31
config/rbac/awxmeshingress_editor_role.yaml
Normal file
@@ -0,0 +1,31 @@
|
||||
# permissions for end users to edit awxmeshingresses.
|
||||
apiVersion: rbac.authorization.k8s.io/v1
|
||||
kind: ClusterRole
|
||||
metadata:
|
||||
labels:
|
||||
app.kubernetes.io/name: clusterrole
|
||||
app.kubernetes.io/instance: awxmeshingress-editor-role
|
||||
app.kubernetes.io/component: rbac
|
||||
app.kubernetes.io/created-by: awx-operator
|
||||
app.kubernetes.io/part-of: awx-operator
|
||||
app.kubernetes.io/managed-by: kustomize
|
||||
name: awxmeshingress-editor-role
|
||||
rules:
|
||||
- apiGroups:
|
||||
- awx.ansible.com
|
||||
resources:
|
||||
- awxmeshingresses
|
||||
verbs:
|
||||
- create
|
||||
- delete
|
||||
- get
|
||||
- list
|
||||
- patch
|
||||
- update
|
||||
- watch
|
||||
- apiGroups:
|
||||
- awx.ansible.com
|
||||
resources:
|
||||
- awxmeshingresses/status
|
||||
verbs:
|
||||
- get
|
||||
27
config/rbac/awxmeshingress_viewer_role.yaml
Normal file
27
config/rbac/awxmeshingress_viewer_role.yaml
Normal file
@@ -0,0 +1,27 @@
|
||||
# permissions for end users to view awxmeshingresses.
|
||||
apiVersion: rbac.authorization.k8s.io/v1
|
||||
kind: ClusterRole
|
||||
metadata:
|
||||
labels:
|
||||
app.kubernetes.io/name: clusterrole
|
||||
app.kubernetes.io/instance: awxmeshingress-viewer-role
|
||||
app.kubernetes.io/component: rbac
|
||||
app.kubernetes.io/created-by: awx-operator
|
||||
app.kubernetes.io/part-of: awx-operator
|
||||
app.kubernetes.io/managed-by: kustomize
|
||||
name: awxmeshingress-viewer-role
|
||||
rules:
|
||||
- apiGroups:
|
||||
- awx.ansible.com
|
||||
resources:
|
||||
- awxmeshingresses
|
||||
verbs:
|
||||
- get
|
||||
- list
|
||||
- watch
|
||||
- apiGroups:
|
||||
- awx.ansible.com
|
||||
resources:
|
||||
- awxmeshingresses/status
|
||||
verbs:
|
||||
- get
|
||||
@@ -124,3 +124,16 @@ rules:
|
||||
- awxrestores
|
||||
verbs:
|
||||
- '*'
|
||||
- apiGroups:
|
||||
- traefik.containo.us
|
||||
- traefik.io
|
||||
resources:
|
||||
- ingressroutetcps
|
||||
verbs:
|
||||
- get
|
||||
- list
|
||||
- create
|
||||
- delete
|
||||
- patch
|
||||
- update
|
||||
- watch
|
||||
|
||||
8
config/samples/awx_v1alpha1_awxmeshingress.yaml
Normal file
8
config/samples/awx_v1alpha1_awxmeshingress.yaml
Normal file
@@ -0,0 +1,8 @@
|
||||
# Placeholder to pass CI and allow bundle generation
|
||||
---
|
||||
apiVersion: awx.ansible.com/v1alpha1
|
||||
kind: AWXMeshIngress
|
||||
metadata:
|
||||
name: example-awx-mesh-ingress
|
||||
spec:
|
||||
deployment_name: example-awx
|
||||
@@ -3,4 +3,5 @@ resources:
|
||||
- awx_v1beta1_awx.yaml
|
||||
- awx_v1beta1_awxbackup.yaml
|
||||
- awx_v1beta1_awxrestore.yaml
|
||||
- awx_v1alpha1_awxmeshingress.yaml
|
||||
#+kubebuilder:scaffold:manifestskustomizesamples
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
### 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.
|
||||
@@ -99,4 +99,4 @@ spec:
|
||||
|
||||
If the cluster you are deploying in has a ResoruceQuota, you will need to configure resource limits for all of the pods deployed in that cluster. This can be done for AWX pods on the AWX spec in the manner shown above.
|
||||
|
||||
There is an example you can use in [`config/samples/awx_v1beta1_awx_resource_limits.yaml`](../../../config/samples/awx_v1beta1_awx_resource_limits.yaml).
|
||||
There is an example you can use in [`awx_v1beta1_awx_resource_limits.yaml`](https://raw.githubusercontent.com/ansible/awx-operator/devel/config/samples/awx_v1beta1_awx_resource_limits.yaml).
|
||||
|
||||
@@ -16,30 +16,3 @@ The following variables are customizable
|
||||
spec:
|
||||
ipv6_disabled: true
|
||||
```
|
||||
|
||||
### 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.
|
||||
|
||||
@@ -32,7 +32,7 @@ The following variables are customizable only when `service_type=LoadBalancer`
|
||||
| --------------------- | ---------------------------------------- | ------- |
|
||||
| loadbalancer_protocol | Protocol to use for Loadbalancer ingress | http |
|
||||
| loadbalancer_port | Port used for Loadbalancer ingress | 80 |
|
||||
| loadbalancer_ip | Assign Loadbalancer IP | '' |
|
||||
| loadbalancer_ip | Assign Loadbalancer IP | '' |
|
||||
|
||||
```yaml
|
||||
---
|
||||
@@ -86,22 +86,26 @@ spec:
|
||||
|
||||
The following variables are customizable when `ingress_type=ingress`. The `ingress` type creates an Ingress resource as [documented](https://kubernetes.io/docs/concepts/services-networking/ingress/) which can be shared with many other Ingress Controllers as [listed](https://kubernetes.io/docs/concepts/services-networking/ingress-controllers/).
|
||||
|
||||
| Name | Description | Default |
|
||||
| ------------------- | ---------------------------------------- | --------------------------- |
|
||||
| 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 |
|
||||
| ingress_api_version | Define the Ingress resource apiVersion | 'networking.k8s.io/v1' |
|
||||
| Name | Description | Default |
|
||||
| ---------------------------------- | ---------------------------------------------------------------------------------- | --------------------------- |
|
||||
| ingress_annotations | Ingress annotations | Empty string |
|
||||
| ingress_tls_secret _(deprecated)_ | Secret that contains the TLS information | Empty string |
|
||||
| ingress_class_name | Define the ingress class name | Cluster default |
|
||||
| hostname _(deprecated)_ | Define the FQDN | {{ meta.name }}.example.com |
|
||||
| ingress_hosts | Define one or multiple FQDN with optional Secret that contains the TLS information | Empty string |
|
||||
| ingress_path | Define the ingress path to the service | / |
|
||||
| ingress_path_type | Define the type of the path (for LBs) | Prefix |
|
||||
| ingress_api_version | Define the Ingress resource apiVersion | 'networking.k8s.io/v1' |
|
||||
|
||||
```yaml
|
||||
---
|
||||
spec:
|
||||
...
|
||||
ingress_type: ingress
|
||||
hostname: awx-demo.example.com
|
||||
ingress_hosts:
|
||||
- hostname: awx-demo.example.com
|
||||
- hostname: awx-demo.sample.com
|
||||
tls_secret: sample-tls-secret
|
||||
ingress_annotations: |
|
||||
environment: testing
|
||||
```
|
||||
@@ -119,7 +123,10 @@ Some Ingress Controllers need a special configuration to fully support AWX, add
|
||||
spec:
|
||||
...
|
||||
ingress_type: ingress
|
||||
hostname: awx-demo.example.com
|
||||
ingress_hosts:
|
||||
- hostname: awx-demo.example.com
|
||||
- hostname: awx-demo.sample.com
|
||||
tls_secret: sample-tls-secret
|
||||
ingress_controller: contour
|
||||
```
|
||||
|
||||
|
||||
@@ -63,6 +63,7 @@ nav:
|
||||
- user-guide/advanced-configuration/privileged-tasks.md
|
||||
- user-guide/advanced-configuration/containers-resource-requirements.md
|
||||
- user-guide/advanced-configuration/priority-classes.md
|
||||
- user-guide/advanced-configuration/adding-execution-nodes.md
|
||||
- user-guide/advanced-configuration/scaling-the-web-and-task-pods-independently.md
|
||||
- user-guide/advanced-configuration/assigning-awx-pods-to-specific-nodes.md
|
||||
- user-guide/advanced-configuration/trusting-a-custom-certificate-authority.md
|
||||
|
||||
19
molecule/default/tasks/awxmeshingress_test.yml
Normal file
19
molecule/default/tasks/awxmeshingress_test.yml
Normal file
@@ -0,0 +1,19 @@
|
||||
# TODO: Add tests for AWXMeshIngress
|
||||
# ---
|
||||
# - name: Create the awx.ansible.com/v1alpha1.AWXMeshIngress
|
||||
# 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_v1alpha1_awxmeshingress.yaml'
|
||||
|
||||
# - name: Add assertions here
|
||||
# assert:
|
||||
# that: false
|
||||
# fail_msg: FIXME Add real assertions for your operator
|
||||
24
roles/backup/tasks/dump_ingress_tls_secrets.yml
Normal file
24
roles/backup/tasks/dump_ingress_tls_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
|
||||
@@ -12,11 +12,18 @@
|
||||
include_tasks: dump_secret.yml
|
||||
loop:
|
||||
- route_tls_secret
|
||||
# ingress_tls_secret is deprecated in favor of ingress_hosts.tls_secret
|
||||
- ingress_tls_secret
|
||||
- ldap_cacert_secret
|
||||
- bundle_cacert_secret
|
||||
- ee_pull_credentials_secret
|
||||
|
||||
- name: Dump ingress tls secret names from awx spec and data into file
|
||||
include_tasks: dump_ingress_tls_secrets.yml
|
||||
with_items:
|
||||
- "{{ awx_spec.spec['ingress_hosts'] | default('') | map(attribute='tls_secret', default='') | select() | list }}"
|
||||
when: "{{ awx_spec.spec['ingress_hosts'] | default('') | map(attribute='tls_secret', default='') | select() | list | length }}"
|
||||
|
||||
- name: Dump receptor secret names and data into file
|
||||
include_tasks: dump_receptor_secrets.yml
|
||||
loop:
|
||||
|
||||
@@ -40,6 +40,16 @@ ingress_tls_secret: ''
|
||||
# ingress_controller: contour
|
||||
ingress_controller: ''
|
||||
|
||||
# One or multiple FQDN with optional Secret that contains the TLS information.
|
||||
# The TLS secret either has to exist before hand with
|
||||
# the corresponding cert and key or just be an indicator for where an automated
|
||||
# process like cert-manager (enabled via annotations) will store the TLS
|
||||
# certificate and key.
|
||||
# ingress_hosts:
|
||||
# - hostname: awx-demo.example.com
|
||||
# tls_secret: example-com-tls
|
||||
ingress_hosts: ''
|
||||
|
||||
loadbalancer_protocol: 'http'
|
||||
loadbalancer_port: '80'
|
||||
service_annotations: ''
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
- name: Delete old deployment for before installing during upgrade
|
||||
k8s:
|
||||
kind: Deployment
|
||||
api_version: v1
|
||||
api_version: apps/v1
|
||||
namespace: "{{ ansible_operator_meta.namespace }}"
|
||||
name: "{{ ansible_operator_meta.name }}"
|
||||
state: absent
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
|
||||
- name: Check for presence of awx-task Deployment
|
||||
k8s_info:
|
||||
api_version: v1
|
||||
api_version: apps/v1
|
||||
kind: Deployment
|
||||
name: "{{ ansible_operator_meta.name }}-task"
|
||||
namespace: "{{ ansible_operator_meta.namespace }}"
|
||||
@@ -17,7 +17,7 @@
|
||||
|
||||
- name: Check for presence of awx-web Deployment
|
||||
k8s_info:
|
||||
api_version: v1
|
||||
api_version: apps/v1
|
||||
kind: Deployment
|
||||
name: "{{ ansible_operator_meta.name }}-web"
|
||||
namespace: "{{ ansible_operator_meta.namespace }}"
|
||||
|
||||
@@ -13,7 +13,7 @@ metadata:
|
||||
annotations:
|
||||
{% if ingress_annotations %}
|
||||
{{ ingress_annotations | indent(width=4) }}
|
||||
{% endif %}
|
||||
{%- endif %}
|
||||
{% if ingress_controller|lower == "contour" %}
|
||||
projectcontour.io/websocket-routes: "/websocket"
|
||||
kubernetes.io/ingress.class: contour
|
||||
@@ -24,6 +24,7 @@ spec:
|
||||
ingressClassName: '{{ ingress_class_name }}'
|
||||
{% endif %}
|
||||
rules:
|
||||
{% if not ingress_hosts %}
|
||||
- http:
|
||||
paths:
|
||||
- path: '{{ ingress_path }}'
|
||||
@@ -33,6 +34,37 @@ spec:
|
||||
name: '{{ ansible_operator_meta.name }}-service'
|
||||
port:
|
||||
number: 80
|
||||
{% if hostname %}
|
||||
host: {{ hostname }}
|
||||
{% endif %}
|
||||
{% if ingress_controller|lower == "contour" %}
|
||||
- path: '{{ ingress_path.rstrip("/") }}/websocket'
|
||||
pathType: '{{ ingress_path_type }}'
|
||||
backend:
|
||||
service:
|
||||
name: '{{ ansible_operator_meta.name }}-service'
|
||||
port:
|
||||
number: 80
|
||||
{% endif %}
|
||||
{% if ingress_tls_secret %}
|
||||
tls:
|
||||
- hosts:
|
||||
- {{ hostname }}
|
||||
secretName: {{ ingress_tls_secret }}
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
{% if ingress_hosts %}
|
||||
{% for item in ingress_hosts %}
|
||||
- host: {{ item.hostname }}
|
||||
http:
|
||||
paths:
|
||||
- path: '{{ ingress_path }}'
|
||||
pathType: '{{ ingress_path_type }}'
|
||||
backend:
|
||||
service:
|
||||
name: '{{ ansible_operator_meta.name }}-service'
|
||||
port:
|
||||
number: 80
|
||||
{% if ingress_controller|lower == "contour" %}
|
||||
- path: '{{ ingress_path.rstrip("/") }}/websocket'
|
||||
pathType: '{{ ingress_path_type }}'
|
||||
@@ -42,14 +74,15 @@ spec:
|
||||
port:
|
||||
number: 80
|
||||
{% endif %}
|
||||
{% if hostname %}
|
||||
host: {{ hostname }}
|
||||
{% endif %}
|
||||
{% if ingress_tls_secret %}
|
||||
{% endfor %}
|
||||
tls:
|
||||
{% for item in ingress_hosts %}
|
||||
{% if 'tls_secret' in item %}
|
||||
- hosts:
|
||||
- {{ hostname }}
|
||||
secretName: {{ ingress_tls_secret }}
|
||||
- {{ item.hostname }}
|
||||
secretName: {{ item.tls_secret }}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
|
||||
|
||||
@@ -11,13 +11,20 @@ DATABASES = {
|
||||
{% if awx_postgres_sslmode in ['verify-ca', 'verify-full'] %}
|
||||
'sslrootcert': '{{ ca_trust_bundle }}',
|
||||
{% endif %}
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
LISTENER_DATABASES = {
|
||||
'default': {
|
||||
'OPTIONS': {
|
||||
{% if postgres_keepalives %}
|
||||
'keepalives': 1,
|
||||
'keepalives_idle': {{ postgres_keepalives_idle }},
|
||||
'keepalives_interval': {{ postgres_keepalives_interval }},
|
||||
'keepalives_count': {{ postgres_keepalives_count }},
|
||||
'keepalives': 1,
|
||||
'keepalives_idle': {{ postgres_keepalives_idle }},
|
||||
'keepalives_interval': {{ postgres_keepalives_interval }},
|
||||
'keepalives_count': {{ postgres_keepalives_count }},
|
||||
{% else %}
|
||||
'keepalives': 0,
|
||||
'keepalives': 0,
|
||||
{% endif %}
|
||||
},
|
||||
}
|
||||
|
||||
15
roles/mesh_ingress/defaults/main.yml
Normal file
15
roles/mesh_ingress/defaults/main.yml
Normal file
@@ -0,0 +1,15 @@
|
||||
---
|
||||
deployment_type: awx
|
||||
|
||||
ingress_type: none
|
||||
ingress_api_version: 'networking.k8s.io/v1'
|
||||
ingress_annotations: ''
|
||||
ingress_class_name: ''
|
||||
ingress_controller: ''
|
||||
|
||||
set_self_owneref: true
|
||||
|
||||
_control_plane_ee_image: quay.io/ansible/awx-ee:latest
|
||||
_image_pull_policy: Always
|
||||
|
||||
finalizer_run: false
|
||||
150
roles/mesh_ingress/tasks/creation.yml
Normal file
150
roles/mesh_ingress/tasks/creation.yml
Normal file
@@ -0,0 +1,150 @@
|
||||
---
|
||||
- name: Import common role
|
||||
import_role:
|
||||
name: common
|
||||
|
||||
- name: Debug is_openshift
|
||||
debug:
|
||||
msg: "is_openshift={{ is_openshift }}"
|
||||
|
||||
- name: Check for presence of AWX instance that we will use to create the Mesh Ingress for.
|
||||
k8s_info:
|
||||
api_version: awx.ansible.com/v1beta1
|
||||
kind: AWX
|
||||
name: "{{ deployment_name }}"
|
||||
namespace: "{{ ansible_operator_meta.namespace }}"
|
||||
register: awx_instance
|
||||
|
||||
- name: Fail if awx_deployment does not exist in the same namespace
|
||||
fail:
|
||||
msg: "AWX instance {{ deployment_name }} does not exist in the same namespace as the AWXMeshIngress instance."
|
||||
when: awx_instance.resources | length == 0
|
||||
|
||||
- name: Set awx_spec
|
||||
set_fact:
|
||||
awx_spec: "{{ awx_instance.resources[0].spec }}"
|
||||
|
||||
- name: Set owner_reference of AWXMeshIngress to related AWX instance
|
||||
k8s:
|
||||
state: present
|
||||
definition:
|
||||
apiVersion: awx.ansible.com/v1beta1
|
||||
kind: AWX
|
||||
name: "{{ deployment_name }}"
|
||||
namespace: "{{ ansible_operator_meta.namespace }}"
|
||||
metadata:
|
||||
name: "{{ deployment_name }}"
|
||||
namespace: "{{ ansible_operator_meta.namespace }}"
|
||||
ownerReferences:
|
||||
- apiVersion: awx.ansible.com/v1beta1
|
||||
blockOwnerDeletion: true
|
||||
controller: true
|
||||
kind: AWX
|
||||
name: "{{ deployment_name }}"
|
||||
uid: "{{ awx_instance.resources[0].metadata.uid }}"
|
||||
when: set_self_owneref | bool
|
||||
|
||||
- name: Set user provided control plane ee image
|
||||
set_fact:
|
||||
_custom_control_plane_ee_image: "{{ awx_spec.control_plane_ee_image }}"
|
||||
when:
|
||||
- awx_spec.control_plane_ee_image | default([]) | length
|
||||
|
||||
- name: Set Control Plane EE image URL
|
||||
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: Set Image Pull Policy
|
||||
set_fact:
|
||||
_image_pull_policy: "{{ awx_spec.image_pull_policy | default(_image_pull_policy, true) }}"
|
||||
|
||||
- name: Default ingress_type to Route if OpenShift
|
||||
set_fact:
|
||||
ingress_type: route
|
||||
when: is_openshift | bool and ingress_type == 'none'
|
||||
|
||||
- name: Apply Ingress resource
|
||||
k8s:
|
||||
apply: yes
|
||||
definition: "{{ lookup('template', 'ingress.yml.j2') }}"
|
||||
wait: yes
|
||||
wait_timeout: "120"
|
||||
register: ingress
|
||||
|
||||
# TODO: need to wait until the route is ready before we can get the hostname
|
||||
# right now this will rereconcile until the route is ready
|
||||
|
||||
- name: Set external_hostname
|
||||
set_fact:
|
||||
external_hostname: "{{ ingress.result.status.ingress[0].host }}"
|
||||
when: ingress_type == 'route'
|
||||
|
||||
- name: Create other resources
|
||||
k8s:
|
||||
apply: yes
|
||||
definition: "{{ lookup('template', '{{ item }}.yml.j2') }}"
|
||||
wait: yes
|
||||
wait_timeout: "120"
|
||||
loop:
|
||||
- service_account
|
||||
- receptor_conf.configmap
|
||||
- service
|
||||
- deployment
|
||||
|
||||
- name: Get the current resource task pod information.
|
||||
k8s_info:
|
||||
api_version: v1
|
||||
kind: Pod
|
||||
namespace: '{{ ansible_operator_meta.namespace }}'
|
||||
label_selectors:
|
||||
- "app.kubernetes.io/name={{ deployment_name }}-task"
|
||||
- "app.kubernetes.io/managed-by={{ deployment_type }}-operator"
|
||||
- "app.kubernetes.io/component={{ deployment_type }}"
|
||||
field_selectors:
|
||||
- status.phase=Running
|
||||
register: awx_task_pod
|
||||
|
||||
- name: Set the resource pod as a variable.
|
||||
set_fact:
|
||||
awx_task_pod: >-
|
||||
{{ awx_task_pod['resources']
|
||||
| rejectattr('metadata.deletionTimestamp', 'defined')
|
||||
| sort(attribute='metadata.creationTimestamp')
|
||||
| first | default({}) }}
|
||||
|
||||
- name: Set the resource pod name as a variable.
|
||||
set_fact:
|
||||
awx_task_pod_name: "{{ awx_task_pod['metadata']['name'] | default('') }}"
|
||||
|
||||
- name: Add new instance to AWX
|
||||
kubernetes.core.k8s_exec:
|
||||
namespace: "{{ ansible_operator_meta.namespace }}"
|
||||
pod: "{{ awx_task_pod_name }}"
|
||||
container: "{{ deployment_name }}-task"
|
||||
command: |
|
||||
awx-manage provision_instance
|
||||
--hostname {{ ansible_operator_meta.name }}
|
||||
--node_type hop
|
||||
|
||||
- name: Add internal receptor address
|
||||
kubernetes.core.k8s_exec:
|
||||
namespace: "{{ ansible_operator_meta.namespace }}"
|
||||
pod: "{{ awx_task_pod_name }}"
|
||||
container: "{{ deployment_name }}-task"
|
||||
command: |
|
||||
awx-manage add_receptor_address
|
||||
--instance {{ ansible_operator_meta.name }}
|
||||
--address {{ ansible_operator_meta.name }}
|
||||
--port 27199 --protocol ws
|
||||
--peers_from_control_nodes --is_internal --canonical
|
||||
|
||||
- name: Add external receptor address
|
||||
kubernetes.core.k8s_exec:
|
||||
namespace: "{{ ansible_operator_meta.namespace }}"
|
||||
pod: "{{ awx_task_pod_name }}"
|
||||
container: "{{ deployment_name }}-task"
|
||||
command: |
|
||||
awx-manage add_receptor_address
|
||||
--instance {{ ansible_operator_meta.name }}
|
||||
--address {{ external_hostname }}
|
||||
--port 443 --protocol ws
|
||||
33
roles/mesh_ingress/tasks/finalizer.yml
Normal file
33
roles/mesh_ingress/tasks/finalizer.yml
Normal file
@@ -0,0 +1,33 @@
|
||||
---
|
||||
- name: Get the current resource task pod information.
|
||||
k8s_info:
|
||||
api_version: v1
|
||||
kind: Pod
|
||||
namespace: '{{ ansible_operator_meta.namespace }}'
|
||||
label_selectors:
|
||||
- "app.kubernetes.io/name={{ deployment_name }}-task"
|
||||
- "app.kubernetes.io/managed-by={{ deployment_type }}-operator"
|
||||
- "app.kubernetes.io/component={{ deployment_type }}"
|
||||
field_selectors:
|
||||
- status.phase=Running
|
||||
register: awx_task_pod
|
||||
|
||||
- name: Set the resource pod as a variable.
|
||||
set_fact:
|
||||
awx_task_pod: >-
|
||||
{{ awx_task_pod['resources']
|
||||
| rejectattr('metadata.deletionTimestamp', 'defined')
|
||||
| sort(attribute='metadata.creationTimestamp')
|
||||
| first | default({}) }}
|
||||
|
||||
- name: Set the resource pod name as a variable.
|
||||
set_fact:
|
||||
awx_task_pod_name: "{{ awx_task_pod['metadata']['name'] | default('') }}"
|
||||
|
||||
- name: Deprovision mesh ingress instance in AWX
|
||||
kubernetes.core.k8s_exec:
|
||||
namespace: "{{ ansible_operator_meta.namespace }}"
|
||||
pod: "{{ awx_task_pod_name }}"
|
||||
container: "{{ deployment_name }}-task"
|
||||
command: "awx-manage deprovision_instance --hostname {{ ansible_operator_meta.name }}"
|
||||
register: result
|
||||
12
roles/mesh_ingress/tasks/main.yml
Normal file
12
roles/mesh_ingress/tasks/main.yml
Normal file
@@ -0,0 +1,12 @@
|
||||
---
|
||||
- name: Lowercase the ingress_type
|
||||
set_fact:
|
||||
ingress_type: "{{ ingress_type | lower }}"
|
||||
|
||||
- name: Run creation tasks
|
||||
include_tasks: creation.yml
|
||||
when: not finalizer_run
|
||||
|
||||
- name: Run finalizer tasks
|
||||
include_tasks: finalizer.yml
|
||||
when: finalizer_run
|
||||
78
roles/mesh_ingress/templates/deployment.yml.j2
Normal file
78
roles/mesh_ingress/templates/deployment.yml.j2
Normal file
@@ -0,0 +1,78 @@
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: {{ ansible_operator_meta.name }}
|
||||
namespace: {{ ansible_operator_meta.namespace }}
|
||||
spec:
|
||||
selector:
|
||||
matchLabels:
|
||||
app.kubernetes.io/name: {{ ansible_operator_meta.name }}
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app.kubernetes.io/name: {{ ansible_operator_meta.name }}
|
||||
spec:
|
||||
containers:
|
||||
- args:
|
||||
- /bin/sh
|
||||
- -c
|
||||
- |
|
||||
internal_hostname={{ ansible_operator_meta.name }}
|
||||
{% if external_hostname is defined %}
|
||||
external_hostname={{ external_hostname }}
|
||||
{% endif %}
|
||||
{% if external_ipaddress is defined %}
|
||||
external_ipaddress={{ external_ipaddress }}
|
||||
{% endif %}
|
||||
receptor --cert-makereq bits=2048 \
|
||||
commonname=$internal_hostname \
|
||||
dnsname=$internal_hostname \
|
||||
nodeid=$internal_hostname \
|
||||
{% if external_hostname is defined %}
|
||||
dnsname=$external_hostname \
|
||||
{% endif %}
|
||||
{% if external_ipaddress is defined %}
|
||||
ipaddress=$external_ipaddress \
|
||||
{% endif %}
|
||||
outreq=/etc/receptor/tls/receptor.req \
|
||||
outkey=/etc/receptor/tls/receptor.key
|
||||
receptor --cert-signreq \
|
||||
req=/etc/receptor/tls/receptor.req \
|
||||
cacert=/etc/receptor/tls/ca/mesh-CA.crt \
|
||||
cakey=/etc/receptor/tls/ca/mesh-CA.key \
|
||||
outcert=/etc/receptor/tls/receptor.crt \
|
||||
verify=yes
|
||||
exec receptor --config /etc/receptor/receptor.conf
|
||||
image: '{{ _control_plane_ee_image }}'
|
||||
imagePullPolicy: '{{ _image_pull_policy }}'
|
||||
name: {{ ansible_operator_meta.name }}-mesh-ingress
|
||||
volumeMounts:
|
||||
- mountPath: /etc/receptor/receptor.conf
|
||||
name: {{ ansible_operator_meta.name }}-receptor-config
|
||||
subPath: receptor.conf
|
||||
- mountPath: /etc/receptor/tls/ca/mesh-CA.crt
|
||||
name: {{ ansible_operator_meta.name }}-receptor-ca
|
||||
readOnly: true
|
||||
subPath: tls.crt
|
||||
- mountPath: /etc/receptor/tls/ca/mesh-CA.key
|
||||
name: {{ ansible_operator_meta.name }}-receptor-ca
|
||||
readOnly: true
|
||||
subPath: tls.key
|
||||
- mountPath: /etc/receptor/tls/
|
||||
name: {{ ansible_operator_meta.name }}-receptor-tls
|
||||
restartPolicy: Always
|
||||
schedulerName: default-scheduler
|
||||
serviceAccount: {{ ansible_operator_meta.name }}
|
||||
volumes:
|
||||
- name: {{ ansible_operator_meta.name }}-receptor-tls
|
||||
- name: {{ ansible_operator_meta.name }}-receptor-ca
|
||||
secret:
|
||||
defaultMode: 420
|
||||
secretName: {{ deployment_name }}-receptor-ca
|
||||
- configMap:
|
||||
defaultMode: 420
|
||||
items:
|
||||
- key: receptor_conf
|
||||
path: receptor.conf
|
||||
name: {{ ansible_operator_meta.name }}-receptor-config
|
||||
name: {{ ansible_operator_meta.name }}-receptor-config
|
||||
83
roles/mesh_ingress/templates/ingress.yml.j2
Normal file
83
roles/mesh_ingress/templates/ingress.yml.j2
Normal file
@@ -0,0 +1,83 @@
|
||||
{% if ingress_type|lower == "ingress" %}
|
||||
---
|
||||
{% if ingress_api_version is defined %}
|
||||
apiVersion: '{{ ingress_api_version }}'
|
||||
{% endif %}
|
||||
kind: Ingress
|
||||
metadata:
|
||||
name: {{ ansible_operator_meta.name }}
|
||||
namespace: {{ ansible_operator_meta.namespace }}
|
||||
annotations:
|
||||
{% if ingress_annotations %}
|
||||
{{ ingress_annotations | indent(width=4) }}
|
||||
{% endif %}
|
||||
{% if ingress_controller|lower == "nginx" %}
|
||||
nginx.ingress.kubernetes.io/ssl-passthrough: "true"
|
||||
{% endif %}
|
||||
spec:
|
||||
{% if ingress_class_name %}
|
||||
ingressClassName: '{{ ingress_class_name }}'
|
||||
{% endif %}
|
||||
rules:
|
||||
- http:
|
||||
paths:
|
||||
- path: /
|
||||
pathType: Prefix
|
||||
backend:
|
||||
service:
|
||||
name: {{ ansible_operator_meta.name }}
|
||||
port:
|
||||
number: 27199
|
||||
{% if external_hostname %}
|
||||
host: {{ external_hostname }}
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
|
||||
{% if ingress_type|lower == "ingressroutetcp" %}
|
||||
---
|
||||
{% if ingress_api_version is defined %}
|
||||
apiVersion: '{{ ingress_api_version }}'
|
||||
{% endif %}
|
||||
kind: IngressRouteTCP
|
||||
metadata:
|
||||
name: {{ ansible_operator_meta.name }}
|
||||
namespace: {{ ansible_operator_meta.namespace }}
|
||||
annotations:
|
||||
{% if ingress_annotations %}
|
||||
{{ ingress_annotations | indent(width=4) }}
|
||||
{% endif %}
|
||||
spec:
|
||||
entryPoints:
|
||||
- websecure
|
||||
routes:
|
||||
- services:
|
||||
- name: {{ ansible_operator_meta.name }}
|
||||
port: 27199
|
||||
{% if external_hostname %}
|
||||
match: HostSNI(`{{ external_hostname }}`)
|
||||
{% endif %}
|
||||
tls:
|
||||
passthrough: true
|
||||
{% endif %}
|
||||
|
||||
{% if ingress_type|lower == "route" %}
|
||||
---
|
||||
apiVersion: route.openshift.io/v1
|
||||
kind: Route
|
||||
metadata:
|
||||
annotations:
|
||||
openshift.io/host.generated: "true"
|
||||
name: {{ ansible_operator_meta.name }}
|
||||
namespace: {{ ansible_operator_meta.namespace }}
|
||||
spec:
|
||||
port:
|
||||
targetPort: ws
|
||||
tls:
|
||||
insecureEdgeTerminationPolicy: None
|
||||
termination: passthrough
|
||||
to:
|
||||
kind: Service
|
||||
name: {{ ansible_operator_meta.name }}
|
||||
weight: 100
|
||||
wildcardPolicy: None
|
||||
{% endif %}
|
||||
24
roles/mesh_ingress/templates/receptor_conf.configmap.yml.j2
Normal file
24
roles/mesh_ingress/templates/receptor_conf.configmap.yml.j2
Normal file
@@ -0,0 +1,24 @@
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: ConfigMap
|
||||
metadata:
|
||||
name: {{ ansible_operator_meta.name }}-receptor-config
|
||||
namespace: {{ ansible_operator_meta.namespace }}
|
||||
data:
|
||||
receptor_conf: |
|
||||
---
|
||||
- node:
|
||||
id: {{ ansible_operator_meta.name }}
|
||||
- log-level: debug
|
||||
- control-service:
|
||||
service: control
|
||||
- ws-listener:
|
||||
port: 27199
|
||||
tls: tlsserver
|
||||
- tls-server:
|
||||
cert: /etc/receptor/tls/receptor.crt
|
||||
key: /etc/receptor/tls/receptor.key
|
||||
name: tlsserver
|
||||
clientcas: /etc/receptor/tls/ca/mesh-CA.crt
|
||||
requireclientcert: true
|
||||
mintls13: false
|
||||
14
roles/mesh_ingress/templates/service.yml.j2
Normal file
14
roles/mesh_ingress/templates/service.yml.j2
Normal file
@@ -0,0 +1,14 @@
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: {{ ansible_operator_meta.name }}
|
||||
namespace: '{{ ansible_operator_meta.namespace }}'
|
||||
spec:
|
||||
type: ClusterIP
|
||||
ports:
|
||||
- name: ws
|
||||
port: 27199
|
||||
targetPort: 27199
|
||||
selector:
|
||||
app.kubernetes.io/name: {{ ansible_operator_meta.name }}
|
||||
6
roles/mesh_ingress/templates/service_account.yml.j2
Normal file
6
roles/mesh_ingress/templates/service_account.yml.j2
Normal file
@@ -0,0 +1,6 @@
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: ServiceAccount
|
||||
metadata:
|
||||
name: '{{ ansible_operator_meta.name }}'
|
||||
namespace: '{{ ansible_operator_meta.namespace }}'
|
||||
11
watches.yaml
11
watches.yaml
@@ -22,4 +22,15 @@
|
||||
kind: AWXRestore
|
||||
role: restore
|
||||
snakeCaseParameters: False
|
||||
|
||||
- version: v1alpha1
|
||||
group: awx.ansible.com
|
||||
kind: AWXMeshIngress
|
||||
role: mesh_ingress
|
||||
snakeCaseParameters: False
|
||||
finalizer:
|
||||
name: awx.ansible.com/awx-mesh-ingress-finalizer
|
||||
role: mesh_ingress
|
||||
vars:
|
||||
finalizer_run: true
|
||||
# +kubebuilder:scaffold:watch
|
||||
|
||||
Reference in New Issue
Block a user