Giter Site home page Giter Site logo

ansible-role-kind's Introduction

Hi there ๐Ÿ‘‹

๐Ÿ”ญ An Author, Consultant, Developer Advocate and Google Developer Expert(Modern Architecures). As part of my role I actively educate developers on Kubernetes/OpenShift, Servicemesh, and Serverless technologies. With a career spanning close to two decades, most of my career was with services industry helping various enterprise customers build Java-based solutions.

๐Ÿ‘ฏ I am a contributor to Open Source projects for more than a decade and contributed/contributing to projects

My developer philosophy LEARN MORE, DO MORE and SHARE MORE!

๐Ÿ’ฌ Ask me about Argo CD, Istio, Knative, Tektoncd, Google Cloud

๐ŸŒฑ Iโ€™m currently learning golang and rust

Blogs

๐Ÿ˜„ He/Him/His

ansible-role-kind's People

Contributors

github-actions[bot] avatar kameshsampath avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

klapcsik

ansible-role-kind's Issues

Ansible Lint Errors

- name: molecule-kind

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.```

Suggestion: create a kind module

Suggestion

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.