In the earlier parts of this series, I started small log parsing, system monitoring, security audits. Each step gave me more confidence to use Python as a real DevOps tool.
In Part 3, I moved into areas that are at the core of DevOps:
- Week 4 → Infrastructure as Code (IaC)
- Week 5 → Kubernetes automation
This part was a real eye-opener, because I wasn’t just running Terraform or Ansible or kubectl commands manually I was controlling them through Python, which makes automation pipelines more flexible and customizable. for code refer https://github.com/Harivelu0/python-for-devops
🔧 Week 4: Infrastructure as Code (IaC) with Python
The goal was to see how Python can tie together provisioning and configuration.
What I did
- Automated Terraform from Python to provision a VPC, EC2, and S3 bucket
- Ran Ansible playbooks directly from Python and parsed the output
What I learned
- Python can act as a wrapper to IaC tools, making it easier to embed Terraform and Ansible into larger automation workflows.
- Instead of treating IaC tools as separate, Python can become the “glue” that coordinates them.
- This approach helps when you want infrastructure + configuration management in one flow, without manual steps.
👉 The main takeaway for me: IaC becomes more powerful when Python orchestrates it.
☸️ Week 5: Kubernetes Automation with Python
Here I switched focus to Kubernetes not with kubectl commands, but by interacting directly with the API using the Python SDK.
What I did
- Created and deleted namespaces programmatically
- Built an RBAC Auditor to check ServiceAccounts and their bindings
- Flagged if any ServiceAccount had dangerous cluster-admin privileges
What I learned
- The Kubernetes API is powerful, and Python makes it accessible in a clean way.
- Automating namespace management showed me how cluster operations can be scripted, not just clicked in a dashboard.
- Writing the RBAC auditor gave me real insight into security risks — it’s easy to accidentally give applications more power than they need.
👉 The main takeaway for me: with Python, I can turn Kubernetes operations into repeatable scripts that also catch security issues early.
Top comments (0)