Latest changes

This commit is contained in:
Chris Houseknecht
2017-03-23 04:15:26 -04:00
parent f928690369
commit cc7f18bc25
14 changed files with 5502 additions and 1109 deletions

3
.gitignore vendored Normal file
View File

@@ -0,0 +1,3 @@
*.retry
.idea
*.log

201
LICENSE Normal file
View File

@@ -0,0 +1,201 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "{}"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright {yyyy} {name of copyright owner}
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

View File

@@ -1,38 +1,51 @@
Role Name
=========
# ansible-kubernetes-modules
A brief description of the role goes here.
Provides access to the latest pre-release K8s modules. Include this role in a playbook, and any other plays or roles will have access to the modules.
The modules are found in the [library folder](./library). Each has full documentation for parameters and the returned data structure. However, not all modules will include examples, only those where [test data]() has been created.
If you find an issue with a particular module, or have suggestions, please file an issue [here]((https://github.com/openshift/openshift-restclient-python/issues)
Requirements
------------
Any pre-requisites that may not be covered by Ansible itself or the role should be mentioned here. For instance, if the role uses the EC2 module, it may be a good idea to mention in this section that the boto package is required.
- Ansible installed from source
- [OpenShift Rest Client](https://github.com/openshift/openshift-restclient-python) installed on the host where the modules will execute.
Installation and use
--------------------
Use the Galaxy client to install the role:
```
$ ansible-galaxy install ansible.ansible-kubernetes-modules
```
Once installed, add it to a playbook:
```
---
- hosts: localhost
remote_user: root
roles:
- role: ansible-kubernetes-modules
install_python_requirements: no
- role: hello-world
```
Because the role is referenced, the `hello-world` role is able to deploy an applicatoin using the K8s modules. To see the contents of the role, check in the [tests/roles](./tests/roles) folder.
Role Variables
--------------
A description of the settable variables for this role should go here, including any variables that are in defaults/main.yml, vars/main.yml, and any variables that can/should be set via parameters to the role. Any variables that are read from other roles and/or the global scope (ie. hostvars, group vars, etc.) should be mentioned here as well.
install_python_requirements
> Set to true, if you want the OpenShift Rest Client installed. Defaults to false. Will install via `pip`.
Dependencies
------------
A list of other roles hosted on Galaxy should go here, plus any details in regards to parameters that may need to be set for other roles, or variables that are used from other roles.
Example Playbook
----------------
Including an example of how to use your role (for instance, with variables passed in as parameters) is always nice for users too:
- hosts: servers
roles:
- { role: username.rolename, x: 42 }
virtualenv
> Provide the name of a virtualenv to use when installing `pip` packages.
License
-------
BSD
Apache V2
Author Information
------------------
An optional section for the role authors to include contact information, or a website (HTML is not allowed).

View File

@@ -1,2 +1,3 @@
---
install_python_requirements: no
virtualenv:

View File

@@ -87,6 +87,13 @@ options:
- Path that the router watches for, to route traffic for to the service. Optional
aliases:
- path
spec_port_target_port:
description:
- The target port on pods selected by the service this route points to. If this
is a string, it will be looked up as a named port in the target endpoints port
list. Required
aliases:
- port_target_port
spec_tls_ca_certificate:
description:
- caCertificate provides the cert authority certificate contents
@@ -181,21 +188,20 @@ EXAMPLES = '''
namespace: k8s-project
state: present
host: www.example.com
target_reference_kind: Service
target_reference_name: service-name
spec_to_kind: Service
spec_to_name: service-name
tls_termination: edge
tls_key: |-
-----BEGIN PRIVATE KEY-----
asjdflajd0fjasldjflsjflkjlkjfaljsdfljasljflasjfljsdf
sdlfjalsdjfljasdfljsljfljsfljdf
key_file_contents
-----END PRIVATE KEY-----
tls_certificate: |-
-----BEGIN CERTIFICATE-----
kdlslfsfljetuoeiursljflsdjffljsfsf90909wrjf94lsjdf99KK
certificate contents
-----END CERTIFICATE-----
tls_ca_certificate: |-
-----BEGIN CERTIFICATE-----
asdfajflasfjfsljlrjlrjlsjfoijlsornkvksflsbgoehfflf54444
ca_certificate_contents
-----END CERTIFICATE-----
- name: Patch route
@@ -205,11 +211,11 @@ EXAMPLES = '''
state: present
host: www.example.com
tls_termination: reencrypt
target_reference_kind: Service
target_reference_name: other-service-name
spec_to_kind: Service
spec_to_name: other-service-name
tls_destination_ca_certificate: |-
-----BEGIN CERTIFICATE-----
destination cetricate_contents
destination_cetricate_contents
-----END CERTIFICATE-----
- name: Replace route
@@ -219,8 +225,8 @@ EXAMPLES = '''
state: replaced
host: www.example.com
path: /foo/bar/baz.html
target_reference_kind: Service
target_reference_name: whimsy-name
spec_to_kind: Service
spec_to_name: whimsy-name
tls_termination: edge
tls_key: |-
-----BEGIN PRIVATE KEY-----

View File

@@ -128,6 +128,32 @@ options:
aliases:
- selector_match_labels
type: dict
spec_strategy_rolling_update_max_surge:
description:
- 'The maximum number of pods that can be scheduled above the desired number of
pods. Value can be an absolute number (ex: 5) or a percentage of desired pods
(ex: 10%). This can not be 0 if MaxUnavailable is 0. Absolute number is calculated
from percentage by rounding up. By default, a value of 1 is used. Example: when
this is set to 30%, the new RC can be scaled up immediately when the rolling
update starts, such that the total number of old and new pods do not exceed
130% of desired pods. Once old pods have been killed, new RC can be scaled up
further, ensuring that total number of pods running at any time during the update
is atmost 130% of desired pods.'
aliases:
- strategy_rolling_update_max_surge
spec_strategy_rolling_update_max_unavailable:
description:
- 'The maximum number of pods that can be unavailable during the update. Value
can be an absolute number (ex: 5) or a percentage of desired pods (ex: 10%).
Absolute number is calculated from percentage by rounding up. This can not be
0 if MaxSurge is 0. By default, a fixed value of 1 is used. Example: when this
is set to 30%, the old RC can be scaled down to 70% of desired pods immediately
when the rolling update starts. Once new pods are ready, old RC can be scaled
down further, followed by scaling up the new RC, ensuring that the total number
of pods available at all times during the update is at least 70% of desired
pods.'
aliases:
- strategy_rolling_update_max_unavailable
spec_strategy_type:
description:
- Type of deployment. Can be "Recreate" or "RollingUpdate". Default is RollingUpdate.

View File

@@ -71,6 +71,11 @@ options:
- Specifies the name of the referenced service.
aliases:
- backend_service_name
spec_backend_service_port:
description:
- Specifies the port of the referenced service.
aliases:
- backend_service_port
spec_rules:
description:
- A list of host rules used to configure the Ingress. If unspecified, or no rule

View File

@@ -66,6 +66,14 @@ options:
password:
description:
- Provide a password for connecting to the API. Use in conjunction with I(username).
spec_min_available:
description:
- An eviction is allowed if at least "minAvailable" pods selected by "selector"
will still be available after the eviction, i.e. even in the absence of the
evicted pod. So for example you can prevent all voluntary evictions by specifying
"100%".
aliases:
- min_available
spec_selector_match_expressions:
description:
- matchExpressions is a list of label selector requirements. The requirements

View File

@@ -1,8 +1,10 @@
# tasks/main.yml
---
- name: Intall role requirements
- name: Intall latest openshift client
pip:
requirements: ../requirements.txt
name: git+https://github.com/openshift/openshift-restclient-python.git#egg=openshift
state: latest
virtualenv: "{{ virtualenv }}"
when: install_python_requirements

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,43 @@
apiVersion: v1
kind: DeploymentConfig
metadata:
name: hello-depoy
namespace: hello
labels:
app: hello
spec:
strategy:
type: Rolling
rollingParams:
updatePeriodSeconds: 1
intervalSeconds: 1
timeoutSeconds: 600
maxUnavailable: 25%
maxSurge: 25%
resources: {}
triggers:
- type: ConfigChange
replicas: 1
test: false
selector:
app: hello
template:
metadata:
name: hello-pod
labels:
app: hello
spec:
containers:
- name: hello
image: openshift/busybox-http-app
ports:
- name: web-8100-tcp
containerPort: 8080
protocol: TCP
resources: {}
terminationMessagePath: /dev/termination-log
imagePullPolicy: Always
restartPolicy: Always
terminationGracePeriodSeconds: 30
dnsPolicy: ClusterFirst
securityContext: {}

View File

@@ -0,0 +1,51 @@
- name: Create project
k8s_v1_project:
name: test-resource-defn
display_name: Resource Defn
description: Load resources
debug: no
register: create_project
- debug: var=create_project
# Create service from unaltered YAML copied from console
- name: Create service from resource definition
k8s_v1_service:
state: present
debug: yes
resource_definition:
apiVersion: v1
kind: Service
metadata:
name: hello-service
namespace: test-resource-defn
selfLink: /api/v1/namespaces/hello/services/hello-service
uid: fd228ddb-0f38-11e7-840c-a2a3304da08d
resourceVersion: '42303'
creationTimestamp: '2017-03-22T19:51:49Z'
labels:
app: hello
spec:
ports:
- name: web-tcp
protocol: TCP
port: 8080
targetPort: 8080
selector:
app: hello
type: ClusterIP
sessionAffinity: None
status:
loadBalancer: {}
register: create_service
- debug: var=create_service
- name: Create deployment from resource file
k8s_v1_deployment_config:
state: present
debug: yes
src: "{{ role_path }}/files/deployment.yml"
register: deployment_create
- debug: var=deployment_create

View File

@@ -1,12 +1,12 @@
- name: Create project
k8s_v1_project:
name: hello
display_name: Shiny Foo
description: W00T! Bitches
display_name: Hello World
description: Hello.
debug: yes
register: project
register: create_project
- debug: var=project
- debug: var=create_project
- name: Create service
k8s_v1_service:
@@ -22,9 +22,9 @@
labels:
app: hello
debug: yes
register: service
register: create_service
- debug: var=service
- debug: var=create_service
- name: Create deployment config
k8s_v1_deployment_config:
@@ -56,7 +56,12 @@
k8s_v1_route:
name: hello-route
namespace: hello
host: www.example.com
state: present
to_kind: Service
to_name: hello-service
tls_termination: edge
to_weight: 100
port_target_port: web-tcp
tls_termination: edge
register: create_route
- debug: var=create_route

View File

@@ -4,4 +4,4 @@
roles:
- role: ansible-kubernetes-modules
install_python_requirements: no
- role: hello-world
- role: hello-templates