mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-23 05:10:22 -07:00
K8s dynamic collected changes (#40745)
* Move k8s modules to dynamic backend * update required openshift version * update -> patch * use new dynamic client exceptions * style * guard urllib3 import * guard ansibleerror import * give more information about error cause * format in variable * style * rename tests * Search for provided kind in a few more places to match old behavior, properly handle failure * make common code use fail instead of fail_json, to work for lookup plugins as well * update docs * move openshift_raw tests into k8s tests * fix typo * Use diff of response and resource to determine change, don't do any checking client-side before making requests * remove duplicate yaml blocks * Update porting guide for k8s module * remove invalid doc refs * If fuzzy searching finds a resource, update resource_definition to match proper kind and version * remote unsupported openshift_raw variables * properly check environment variables when determining auth method:
This commit is contained in:
parent
82dfa542c2
commit
4d77878654
23 changed files with 661 additions and 2038 deletions
2
test/integration/targets/k8s/aliases
Normal file
2
test/integration/targets/k8s/aliases
Normal file
|
@ -0,0 +1,2 @@
|
|||
cloud/openshift
|
||||
posix/ci/cloud/group4/openshift
|
190
test/integration/targets/k8s/tasks/main.yml
Normal file
190
test/integration/targets/k8s/tasks/main.yml
Normal file
|
@ -0,0 +1,190 @@
|
|||
- name: Install requirements
|
||||
pip:
|
||||
name: openshift
|
||||
|
||||
# Kubernetes resources
|
||||
- name: Create a namespace
|
||||
k8s:
|
||||
name: testing
|
||||
kind: namespace
|
||||
register: output
|
||||
|
||||
- name: show output
|
||||
debug:
|
||||
var: output
|
||||
|
||||
- name: Create a service
|
||||
k8s:
|
||||
state: present
|
||||
resource_definition: &svc
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: web
|
||||
namespace: testing
|
||||
labels:
|
||||
app: galaxy
|
||||
service: web
|
||||
spec:
|
||||
selector:
|
||||
app: galaxy
|
||||
service: web
|
||||
ports:
|
||||
- protocol: TCP
|
||||
targetPort: 8000
|
||||
name: port-8000-tcp
|
||||
port: 8000
|
||||
register: output
|
||||
|
||||
- name: show output
|
||||
debug:
|
||||
var: output
|
||||
|
||||
- name: Create the service again
|
||||
k8s:
|
||||
state: present
|
||||
resource_definition: *svc
|
||||
register: output
|
||||
|
||||
- name: Service creation should be idempotent
|
||||
assert:
|
||||
that: not output.changed
|
||||
|
||||
- name: Create PVC
|
||||
k8s:
|
||||
state: present
|
||||
inline: &pvc
|
||||
apiVersion: v1
|
||||
kind: PersistentVolumeClaim
|
||||
metadata:
|
||||
name: elastic-volume
|
||||
namespace: testing
|
||||
spec:
|
||||
resources:
|
||||
requests:
|
||||
storage: 5Gi
|
||||
accessModes:
|
||||
- ReadWriteOnce
|
||||
|
||||
- name: Show output
|
||||
debug:
|
||||
var: output
|
||||
|
||||
- name: Create the PVC again
|
||||
k8s:
|
||||
state: present
|
||||
inline: *pvc
|
||||
|
||||
- name: PVC creation should be idempotent
|
||||
assert:
|
||||
that: not output.changed
|
||||
|
||||
- name: Create deployment
|
||||
k8s:
|
||||
state: present
|
||||
inline: &deployment
|
||||
apiVersion: apps/v1beta1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: elastic
|
||||
labels:
|
||||
app: galaxy
|
||||
service: elastic
|
||||
namespace: testing
|
||||
spec:
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: galaxy
|
||||
service: elastic
|
||||
spec:
|
||||
containers:
|
||||
- name: elastic
|
||||
volumeMounts:
|
||||
- mountPath: /usr/share/elasticsearch/data
|
||||
name: elastic-volume
|
||||
command: ['elasticsearch']
|
||||
image: 'ansible/galaxy-elasticsearch:2.4.6'
|
||||
volumes:
|
||||
- name: elastic-volume
|
||||
persistentVolumeClaim:
|
||||
claimName: elastic-volume
|
||||
replicas: 1
|
||||
strategy:
|
||||
type: RollingUpdate
|
||||
register: output
|
||||
|
||||
- name: Show output
|
||||
debug:
|
||||
var: output
|
||||
|
||||
- name: Create deployment again
|
||||
k8s:
|
||||
state: present
|
||||
inline: *deployment
|
||||
register: output
|
||||
|
||||
- name: Deployment creation should be idempotent
|
||||
assert:
|
||||
that: not output.changed
|
||||
|
||||
# OpenShift Resources
|
||||
- name: Create a project
|
||||
k8s:
|
||||
name: testing
|
||||
kind: project
|
||||
api_version: v1
|
||||
register: output
|
||||
|
||||
- name: show output
|
||||
debug:
|
||||
var: output
|
||||
|
||||
- name: Create deployment config
|
||||
k8s:
|
||||
state: present
|
||||
inline: &dc
|
||||
apiVersion: v1
|
||||
kind: DeploymentConfig
|
||||
metadata:
|
||||
name: elastic
|
||||
labels:
|
||||
app: galaxy
|
||||
service: elastic
|
||||
namespace: testing
|
||||
spec:
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: galaxy
|
||||
service: elastic
|
||||
spec:
|
||||
containers:
|
||||
- name: elastic
|
||||
volumeMounts:
|
||||
- mountPath: /usr/share/elasticsearch/data
|
||||
name: elastic-volume
|
||||
command: ['elasticsearch']
|
||||
image: 'ansible/galaxy-elasticsearch:2.4.6'
|
||||
volumes:
|
||||
- name: elastic-volume
|
||||
persistentVolumeClaim:
|
||||
claimName: elastic-volume
|
||||
replicas: 1
|
||||
strategy:
|
||||
type: Rolling
|
||||
register: output
|
||||
|
||||
- name: Show output
|
||||
debug:
|
||||
var: output
|
||||
|
||||
- name: Create deployment config again
|
||||
k8s:
|
||||
state: present
|
||||
inline: *dc
|
||||
register: output
|
||||
|
||||
- name: DC creation should be idempotent
|
||||
assert:
|
||||
that: not output.changed
|
Loading…
Add table
Add a link
Reference in a new issue