No project description provided
Project description
The Idem Kubernetes provider
About
An Idem plugin to manage Kubernetes resources.
What is POP?
This project is built with pop, a Python-based implementation of Plugin Oriented Programming (POP). POP seeks to bring together concepts and wisdom from the history of computing in new ways to solve modern computing problems.
For more information:
Getting Started
Prerequisites
Python 3.7+
git (if installing from source or contributing to the project)
To contribute to the project and set up your local development environment, see CONTRIBUTING.rst in the source repository for this project.
Installation
You can install idem-k8s with the Python package installer (PyPI) or from source.
Install from PyPI
pip install idem-k8s
Install from source
# Clone repo
git clone git@<your-project-path>/idem-k8s.git
cd idem-k8s
# Set up venv
python3 -m venv .venv
source .venv/bin/activate
pip install -e .
Development
The idem-k8s plugin has built-in automatic code generation to extend support for additional Kubernetes resources. Automatic code generation creates over 90% of the code required to support a new Kubernetes resource.
Automatically generate a Kubernetes resource state file with the following command:
pop-create k8s \
--directory ~/idem_k8s/autogen/dummy \ # directory in which the generated state files are stored
-tv \
-n idem_k8s \
--resource apps/v1/DaemonSet # resource for which state files are generated
The resource argument follows the format: group/version/kind
For example, to add a resource state for Deployment, the argument is: apps/v1/Deployment
For more information, see the Kubernetes resource objects documentation.
Usage
Setup
After installation, idem-k8s execution and state modules are accessible to the pop hub.
For more information:
To use idem-k8s execution and state modules to manage cluster resources, you need to set up authentication in one of the following ways.
With environment variables
Set KUBE_CONFIG_PATH and KUBE_CTX environment variables to the Kubernetes configuration file and context found in your kube_config file.
In the Idem config file
Edit the Idem config file to include the kube_config_path and context under account extras. Use the following example as a guideline.
acct:
extras:
k8s:
default:
kube_config_path: ~/.kube/config
context: default
In a credentials.yaml file
Create or edit an Idem credentials.yaml file to add the kube_config_path and context to a Kubernetes profile. Use the following example as a guideline.
k8s:
default:
kube_config_path: ~/.kube/config
context: default
For more about Idem credentials files, including recommended steps for encryption and environment variables, see Authenticating with Idem
You are now ready to use idem-k8s.
States
Idem SLS files use states to ensure that resources are in a desired configuration. An idem-k8s SLS file supports three state functions: present, absent, and describe.
present
The present function ensures that a resource exists. If a resource doesn’t exist, running present creates it. If the resource already exists, running present might leave it unchanged, or update it if there are any configuration changes.
absent
The absent function ensures that a resource does not exist. If the resource exists, running absent deletes it. If the resource doesn’t exist, running absent has no effect.
describe
The describe function returns a list of all resources in the Kubernetes cluster of the same type as specified in the credential profile.
Accessing States
States can be accessed by their relative location in idem-k8s/k8s/states.
For example, a Kubernetes deployment state can be created with the present function as shown in the following SLS file.
k8s_deployment.sls:
nginx-deployment:
k8s.apps.v1.deployment.present:
- metadata:
name: nginx-deployment
namespace: default
- spec:
replicas: 3
selector:
match_labels:
app: nginx
strategy:
rolling_update:
max_surge: 25%
max_unavailable: 25%
type: RollingUpdate
template:
metadata:
labels:
app: nginx
spec:
containers:
- image: nginx:1.14.20
image_pull_policy: IfNotPresent
name: nginx
ports:
- container_port: 80
protocol: TCP
termination_message_path: /dev/termination-log
termination_message_policy: File
restart_policy: Always
The Idem command to create the preceding deployment state is:
idem state $PWD/k8s_deployment.sls
Current Supported Resources
apiregistration_k8s_io.v1
api_service
apps.v1
daemon_set
deployment
core.v1
config_map
namespace
secret
service_account
service
persistent_volume_claim
rbac.v1
cluster_role
cluster_role_binding
role_binding
storage_k8s_io.v1
storage_class
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file idem-k8s-0.3.0.tar.gz
.
File metadata
- Download URL: idem-k8s-0.3.0.tar.gz
- Upload date:
- Size: 38.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.8.0 pkginfo/1.8.3 readme-renderer/37.3 requests/2.28.1 requests-toolbelt/0.10.1 urllib3/1.26.13 tqdm/4.64.1 importlib-metadata/5.1.0 keyring/23.11.0 rfc3986/2.0.0 colorama/0.4.6 CPython/3.9.15
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5be570fe4769c63e60da3389c5f21535b8ca75dcd924d14435b9b912c032676a |
|
MD5 | 3a4450292321803cdc46529a4cb2f759 |
|
BLAKE2b-256 | 62402283c63777c4c11e2b4d3551d6811f122ff73bdc8ca05eab689508df519b |
File details
Details for the file idem_k8s-0.3.0-py3-none-any.whl
.
File metadata
- Download URL: idem_k8s-0.3.0-py3-none-any.whl
- Upload date:
- Size: 67.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.8.0 pkginfo/1.8.3 readme-renderer/37.3 requests/2.28.1 requests-toolbelt/0.10.1 urllib3/1.26.13 tqdm/4.64.1 importlib-metadata/5.1.0 keyring/23.11.0 rfc3986/2.0.0 colorama/0.4.6 CPython/3.9.15
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9fc6839bda3f35b3765c89466a0d01a3c64ae09cff7a64e6e788843d26398399 |
|
MD5 | 3e012e792c4d1da009906b99e26793d4 |
|
BLAKE2b-256 | 47ed1a951687a3f9d11d82243284a679fb522894ac82e2dd7fbb12e704933ce2 |