Skip to content

mihaTrajbaric/k8s

Repository files navigation

SODALITE k8s collection

CI codecov

This repository hosts the sodalite.k8s Ansible Collection.

The collection includes quality Ansible content to help automate the management of applications in Kubernetes

Ansible version compatibility

This collection has been tested against following Ansible versions: >=2.9.17.

Plugins and modules within a collection may be tested with only specific Ansible versions. A collection may contain metadata that identifies these versions. PEP440 is the schema used to describe the versions of Ansible.

Python Support

  • Collection supports 3.6+

Note: Python2 is deprecated from 1st January 2020. Please switch to Python3.

External requirements

Collection requires python package kubernetes>=12.0.0.

Included content

Modules

Name Description
sodalite.k8s.config_map Creates k8s ConfigMap
sodalite.k8s.deployment Creates k8s Deployment
sodalite.k8s.ingress Creates k8s Ingress
sodalite.k8s.namespace Creates k8s Namespace
sodalite.k8s.pvc Creates k8s PersistentVolumeClaim
sodalite.k8s.secret Creates k8s Secret
sodalite.k8s.service Creates k8s Service
sodalite.k8s.storage_class Creates k8s StorageClass

Installation and Usage

Installing the Collection from GIT repository

Before using the Sodalite.k8s collection, you need to install it with the Ansible Galaxy CLI:

ansible-galaxy collection install git+https://github.com/mihaTrajbaric/k8s.git

You can also include it in a requirements.yml file and install it via ansible-galaxy collection install -r requirements.yml, using the format:

---
collections:
  - name: https://github.com/mihaTrajbaric/k8s.git
    type: git

Installing the Collection from Ansible Galaxy (TODO - no published yet)

Before using the Sodalite.8s collection, you need to install it with the Ansible Galaxy CLI:

ansible-galaxy collection install sodalite.k8s

You can also include it in a requirements.yml file and install it via ansible-galaxy collection install -r requirements.yml, using the format:

---
collections:
  - name: sodalite.k8s
    version: 1.0.0

Installing the Kubernetes Python Library

Content in this collection requires the Kubernetes Python client to interact with Kubernetes' APIs. You can install it with:

pip3 install kubernetes>=12.0.0

Using modules from the Kubernetes Collection in your playbooks

It's preferable to use content in this collection using their Fully Qualified Collection Namespace (FQCN), for example sodalite.k8s.deployment:

---
- hosts: localhost
  gather_facts: false
  connection: local

  tasks:
    - name: Ensure namespace exists.
      sodalite.k8s.namespace:
        name: test-namespace
        state: present

    - name: Create new configmap
      sodalite.k8s.config_map:
        name: myapp-config
        namespace: test-namespace
        data:
          DB_IP: another-service

    - name: Ensure the myapp Deployment exists
      sodalite.k8s.deployment:
        name: myapp-deployment
        namespace: test-namespace
        state: present
        labels:
          app: myapp
        selector:
          match_labels:
            app: myapp
        containers:
          - name: myapp-container
            image: myapp:latest
            ports:
              - host_port: 80
                container_port: 80
                protocol: TCP
            env_from:
              - config_map:
                  name: myapp-config

    - name: Ensure the myapp Service exists
      sodalite.k8s.service:
        name: myapp-service
        namespace: test-namespace
        state: present
        type: LoadBalancer
        selector:
          app: myapp
        ports:
          - name: my-port
            port: 8080
            target_port: 8080

See Ansible Using collections for more details.

Contributing to this collection (TODO)

Release notes

See the changelog.

Licensing

GNU General Public License v3.0 or later.

See LICENSE to see the full text.

About

k8s collection

Resources

License

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published