kameshsampath / ansible-role-kind Goto Github PK
View Code? Open in Web Editor NEWAnsible role for KinD
License: Apache License 2.0
Ansible role for KinD
License: Apache License 2.0
Create a kind module able to create/delete a kind cluster as proposed ti kind prokject but rejected - kubernetes-sigs/kind#1687.
It could be designed with the following attributes
kind:
version: 0.17.2
name: my-k8s-17
image:
registry: docker
routing: ingress
nodes:
- role: control-plane
- role: worker
- role: worker
extraPortMappings:
- containerPort: 80
hostPort: 80
listenAddress: "127.0.0.1"
potocol: TCP
extraMounts:
- hostPath: /path/to/my/files/
containerPath: /files
networking:
apiServerAddress: "127.0.0.1"
state: present
FYI, I started to look how to use kubernetes python client. See skeleton of the project
#!/usr/bin/python
from ansible.module_utils.basic import AnsibleModule
from ansible.module_utils.k8s.common import K8sAnsibleMixin
from kubernetes.client import ApiClient
class FakeKubeResponse:
def __init__(self, obj):
import json
self.data = json.dumps(obj)
def main():
module_args = dict(
# cluster_name=dict(type='str', required=True),
# version=dict(type='str', required=True),
pod_namespace=dict(type='str'),
label_selectors=dict(type='list', elements='str', default=[]),
)
module = AnsibleModule(
argument_spec=module_args,
)
k8s = K8sAnsibleMixin()
k8s.client = k8s.get_api_client()
type = {'kind': 'Pod', 'apiVersion': 'v1'}
result = k8s.kubernetes_facts(
type['kind'],
type['apiVersion'],
"",
module.params['pod_namespace'],
module.params['label_selectors'],
"")
pods = result['resources']
for i in pods:
jsonPod = i
api_client = ApiClient()
fake_kube_response = FakeKubeResponse(jsonPod)
v1pod = api_client.deserialize(fake_kube_response, 'V1Pod')
response = "Pod : name %s, running under namespace: %s, status is : %s" % (v1pod.metadata.name,
v1pod.metadata.namespace,
v1pod.status.conditions)
result = {'changed': True, 'result': response}
module.exit_json(**result)
if __name__ == '__main__':
main()
You can test it the command :
python3 ./plugins/modules/kind.py ./args.json
where agrs.json
is
{
"ANSIBLE_MODULE_ARGS": {
"pod_namespace": "bot",
"label_selectors": "app.kubernetes.io/name = snowdrop-bot"
}
}
WDYT : @kameshsampath
Couldn't parse task at /Users/kameshs/.ansible/roles/kameshsampath.kind/tasks/ingress.yml:2 (couldn't res
olve module/action 'helm_repository'. This often indicates a misspelling, missing collection, or incorrec
t module path.
The error appears to be in '<unicode string>': line 2, column 3, but may
be elsewhere in the file depending on the exact syntax problem.
(could not open file to display line))
{ 'helm_repository': { '__file__': '/Users/kameshs/.ansible/roles/kameshsampath.kind/tasks/ingress.yml',
'__line__': 4,
'name': 'stable',
'repo_url': 'https://kubernetes-charts.storage.googleapis.com'},
'ignore_errors': True,
'name': 'Add stable chart Repo',
'skipped_rules': []}
ERROR: Lint failed: Command 'set -e
yamllint .
ansible-lint molecule/default/converge.yml
' returned non-zero exit status 1.: Command 'set -e
yamllint .
ansible-lint molecule/default/converge.yml
' returned non-zero exit status 1.```
Check why controllers are configured always even when there is no changes
Assignees: @kameshsampath
Labels: knative,serving,eventing
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.