DIGIT Urban
PlatformDomainsAcademyDesign SystemFeedback
v2.6
v2.6
  • DIGIT Urban
  • Access DIGIT
  • Architecture
  • Roadmap
  • Release Notes
    • MDMS Configuration & Service Build Updates
    • Test Cases
    • Property Tax Release Notes
    • Citizen Engagement: Documents Feature Release Notes
    • OBPS Release Notes
  • Source Code-Urban Stack
  • 📘Product Docs
    • Products & Modules
      • Trade License (TL)
        • TL Brochure
        • TL Roadmap
        • TL Module Functional Specifications
        • TL Workflows
        • TL Implementation Guide
        • TL Master Data Templates
          • Trade Type
          • Trade Sub Type
          • Trade Category
          • Trade License Fee
          • Structure Sub Type
          • Structure Type
          • Trade License Document Attachment
        • TL Service Configuration
          • Trade License Calculator
        • TL Apply Flow UI Details
          • My Applications UI Flow
          • Send Back - Edit UI Flow
          • Trade License Renewal UI Flow
          • Employee Inbox UI Details
          • Employee Search Application Search License UI Flow
          • New Trade License UI Flow
          • Application Details - Trade Details UI Flows
          • Renew Edit Application
        • TL User Manual
          • Citizen User Manual
          • Employee User Manual
        • TL Demo Script
      • Property Tax
        • PT Brochure
        • PT Roadmap
        • PT Module Functional Specifications
        • PT Workflows
        • PT Implementation Guide
        • PT Master Data Templates
          • Mutation Fee
          • Rebate Rates
          • Penalty Rates
          • Interest Rates
          • Tax Rates
          • Unit Rates
          • Special Category Documents
          • Owner Special Category
          • Ownership Sub Category
          • Ownership Category
          • Usage Category Detail
          • Road Type
          • Construction Type
          • Property Type
          • Property Sub Type
          • Usage Category Major
          • Usage Category Minor
          • Usage Category Sub Minor
        • Property Tax Service
          • Property Mutation & Mutation Calculator
          • PT Update Number & Alternate Number
            • Update Primary Mobile Number & Alternate Mobile Number
          • Assessment of Property
          • PT Calculator
          • Fuzzy Search
            • Fuzzy Search Reindexing
        • PT - Create Property UI Details
          • Edit-Update Property
          • Property Tax - My Applications
          • Property Tax - My Properties
          • Property Tax - Quick Pay for Citizen
          • Create Application - Employee UI/UX Revamp
          • Employee Edit Application Flow
          • Employee - Search Property, Property Details Page & Assessment
          • Employee - Inbox & Application Details
          • Employee Inbox (Old UI)
          • Citizen Mutation Flow
          • Employee - Mutation (Ownership Transfer)
        • PT Data Migration
        • PT User Manual
          • Citizen User Manual
          • Employee User Manual
      • Water & Sewerage (W&S)
        • W&S Implementation Guide
        • W&S Module Functional Specifications
        • Water Services
          • Water Calculator Service
          • Sewerage Service
          • Sewerage Calculator Service
        • Sewerage Charges Master Data Templates
          • Sewerage Rates
          • Sewerage Penalty Rates
          • Sewerage Interest Rates
        • Water Charges Master Data Templates
          • Water Rates (Metered)
          • Pipe Size Types
          • Water Source Types
          • Water Rates (Non-Metered)
          • Water Penalty Rates
          • Water Interest Rates
        • W&S User Manual
          • W&S Citizen User Manual
          • W&S Employee User Manual
      • Public Grievances & Redressal (PGR)
        • PGR Brochure
        • PGR Roadmap
        • PGR Module Functional Specifications
        • PGR Workflows
        • PGR Implementation Guide
        • PGR Master Data Templates
          • Grievance Type
          • Grievance Sub Type
        • PGR Service Configuration
          • PGR Migration
        • PGR User Manual
          • Complaint Types List
          • Citizen User Manual
          • Employee User Manual
        • PGR Demo Script
      • Online Building Plan Approval System (OBPAS)
        • OBPAS Brochure
        • OBPAS Module Functional Specifications
        • OBPAS Implementation Guide
        • OBPAS Master Data Templates
          • Fee Structure
          • NOC Departments
          • Stakeholders Type
          • List Of Services
          • Service-Wise Documents
          • Building Occupancy
          • Building Sub Occupancy
          • Building Usage
          • Inspection Checklist
          • Town Planning Schemes
        • OBPAS DIGIT UI
          • Stakeholder - Registration Flow
          • OBPS-BPA/OC-BPA Employee Flow
            • OBPS Inbox
            • OBPS Search Application
          • OBPS-BPA/OC-BPA Architect
          • OBPS EDCR /OC-EDCR
          • OBPS BPA / OCBPA Citizen
          • Employee - Stakeholder
            • Stakeholder Inbox
            • Stakeholder Search Application
        • OBPAS Service Configuration
          • BPA Service Configuration
          • BPA Calculator Service
          • Setting Up eDCR Service
          • eDCR Integration
          • Noc Services
          • Land Services
        • OBPAS Demo Script
        • OBPAS User Manual
          • OBPAS Citizen User Manual
          • OBPAS Employee User Manual
      • mCollect (MCS)
        • mCollect Roadmap
        • mCollect Master Data Templates
          • Service Category
          • Service Sub Category
          • Service Sub Category GL Code Mapping
        • eChallan UI Details
          • Edit - Cancel Challan
          • Search and Pay Challan
          • mCollect UI Flow
          • Update - Cancel Challan UI Flow
          • Challan Creation
        • mCollect User Manual
          • MCS Citizen User Manual
          • MCS Employee User Manual
      • Faecal Sludge Management (FSM)
        • FSM Service Configuration
          • FSM Implementation - Configuration
          • FSM Calculator v1.0
          • FSM Services
          • FSM Vendor Registry v1.0
          • FSM Vehicle Registry v1.0
          • Legacy/Re-Indexing the FSM Data
          • FSM-DSS Technical Documentation
        • FSM User Manual
          • Citizen User Manual
          • Employee User Manual
          • DSO User Manual
          • Septage Treatment Plant Operator User Manual
      • Finance
        • Finance Module Functional Specifications
        • Finance Implementation Guide
        • Finance Master Data Templates
          • Bank Account
          • Chart Of Accounts
          • Funds
          • Function
          • Contractors
          • Suppliers
          • Schemes
          • Sub Schemes
          • Banks
          • Bank Branch
          • Deduction
          • Opening Balances
          • Sub Ledger Category
          • Sub Ledger Master
        • Finance Service Configuration
          • Finance Collections Voucher Consumer Service
        • Finance User Manual
          • Employee User Manual
          • Admin User Manual
          • Finance Reports Manual
      • Fire NOC
        • Fire NOC Master Data Templates
          • Building Usage Type
          • Building Sub Usage Type
          • Fire Station Master
          • Areas Served Master
          • Fire Station Mapping
          • Fire NOC Fee
        • Fire NOC Service
          • Fire NOC Calculator Service
        • Fire NOC User Manual
          • Fire NOC Citizen User Manual
          • Fire NOC Employee User Manual
        • NOC DIGIT UI
          • NOC Inbox
          • Application Overview
      • e-Challan Service
        • eChallan Calculator Services
      • HRMS
        • HRMS Employee Create-Edit UI Flow
        • Employee Details UI Flow
        • Employee Activation-Deactivation UI Flow
        • Search Employee By Multiple Criteria UI Flow
        • HRMS Service
        • Employees Count UI Flow
      • Events And Notifications
        • Citizen Flow
        • Employee Flow - Events
        • Employee Flow - Messages
      • Citizen Engagement Module
        • Documents: Implementation Details
      • Current Bill Cancellation UI Flow
        • Bill Details UI Flow
        • Cancel Bill UI Flow
      • Receipt Cancellation UI Flow
        • View Receipt - Cancel UI Flow
      • Auto Escalation UI Flow
      • DSS UI Flow
      • Product FAQs
  • Training Resources
    • Open Events
    • Training Videos
    • Technical Enablement Areas
    • eDCR Training Plan
  • Partner Support
    • eGov Enablement Support for DIGIT
    • Security Guidelines Handbook
    • Troubleshooting Guide
  • ⏹️Setup
    • Quickstart
      • 1. Infra Setup
      • 2. Deployment
      • FAQ
    • Full Installation
      • On AWS
        • 1. Pre-requisites
        • 2. Understanding EKS
        • 3. Setup AWS account
        • 4. Infra-as-code (Terraform)
        • 5. Prepare Deployment Config
        • 6. Deploy DIGIT
        • 7. Bootstrap DIGIT
        • FAQ
      • On Azure
        • 1. Pre-requisites
        • 2. Understanding AKS
        • 3. Infra-as-code (Terraform)
      • On GCP
      • On SDC
      • On NIC
    • Open Source Tools used in DIGIT
    • Productionize DIGIT
      • scaling
        • Horizontally Scale DIGIT Services
    • Learn More
      • Setup Requirements
        • Tech Enablement Training - Essential Skills and Pre-requisites
        • Tech Enablement Training (eDCR) - Essential Skills and Prerequisites
        • DIGIT Rollout Program Governance
        • DevOps Skills Requirements
        • Infra Requirements
        • Team Composition for DIGIT Implementation
        • Infra Best Practices
        • Operational Best practices
        • Why Kubernetes for DIGIT
      • Supported Clouds
        • Google Cloud
        • Azure
        • AWS
        • VSphere
        • SDC
        • NIC
      • Deployment - Key Concepts
        • Security Practices
        • CI/CD
        • Readiness & Liveness
        • Resource Requests & Limits
      • Understanding ERP Stack
        • ERP Monolithic Architecture
        • ERP Hybrid Architecture
        • ERP Coexistence Architecture
        • APMDP-HYBRID-INFRA-ARCHITECTURE
        • eGov SmartCity eGovernance Suite
        • ERP Deployment Process
        • ERP Release Process
        • ERP User Guide
      • Deploying DIGIT Services
        • Deployment Architecture
        • Routing Traffic
        • Backbone Deployment
      • Troubleshooting
        • Distributed Tracing
        • Logging
        • Monitoring & Alerts
  • 🫐Configure
    • Configure DIGIT
      • Git Repos
      • Setting up DIGIT
        • Configuring InfraOps
        • Setting up DIGIT Environment
        • Email And SMS Setup
        • FileStore Setup
        • Setting Up SSL Certificate
        • Periodic Log Cleanup
      • Setting up Master Data
        • MDMS Overview
        • Configuring Tenants
        • Configuring Master Data
        • Adding New Master
        • State Level Vs City Level Master
      • Master Data Collection Templates
        • Environment Setup
          • State Level Setup
            • Tenants Information
            • SMS Account Configuration
            • Email Account Configuration
            • Google Play Store Account
            • Payment Gateway Configuration
            • POS Integration Configuration
            • Domain Name Configuration
            • SSL Configuration
            • ULB Departments
            • ULB Designations
            • Localization
            • Google Map Configuration
          • ULB Level Setup
            • Boundary Hierarchies
            • Boundary Data
            • Cross Hierarchy Mapping
            • ULB Bank Accounts
        • Module Setup
          • Web Portals Templates
            • State Portal
            • ULB Portal
          • HRMS Data Templates
            • User Roles
            • System Users
          • Billing And Payments Data Templates
            • Tax Heads
            • Receipt Format
            • Demand Bill Format
          • DSS Data Templates
            • KPI Acceptance
          • Workflow Data Templates
            • Workflow Actions
            • Workflow Levels
            • Workflow Process
            • Workflow Notifications
          • Common Configuration Details
            • Standard Document List
            • Service Document Mapping
            • Checklist
            • Configuring Data FAQs
      • Configuring DIGIT Service Stack
        • Core Services
          • Workflow Services
          • Location Services
          • User Services
          • Access Control Services
          • PDF Generation Service
          • MDMS (Master Data Management Service)
          • Payment Gateway Service
          • NLP Engine Service
          • User Session Management In DIGIT
          • Indexer Service
          • URL Shortening Service
          • XState Core Chatbot
            • XState-Chatbot Integration Document
            • Xstate-Chatbot Message Localisation
        • Business Service
          • Appropriation Service
          • Billing Service
            • Bill Amendment Service Configuration
          • Collection Service
            • Collection Service Migration
            • Collection Service V2
          • Billing Collection Integration
          • Dashboard Analytics - Backend
          • DSS Technical Documentation
          • DSS Dashboard - Technical Document for UI
          • DSS Features Enhancements
          • Technical Script/Steps For Migration Process
          • Bill Amendment
        • Municipal Service
          • Turn-Io-Adapter
          • Inbox Service
        • Utilities
      • Configuring Services
        • Persister Configuration
        • Indexer Configuration
        • Setting up a Language
          • Adding New Language
          • Setting Up Default Language For SMS & Emails
        • API Dos and Don'ts
        • Setting Up SMS Gateway
          • Using The Generic GET & POST SMS Gateway Interface
        • Setting Up Service Locally
        • Configuring Workflows
          • Setting Up Workflows
          • Configuring Workflows For An Entity
          • Workflow Auto Escalation
        • DSS Configuration And Setup
          • Building New Dashboards
        • Configuring New Reports
          • Types Of Reports Used In Report Service
          • Impact Of Heavy Reports On Platform
        • Adding Roles To System
        • Mapping Roles With APIs
        • Deployment Of App on Play Store
        • Adding New APIs For Access
        • FileStore Service
        • Telemetry Service
        • Report Service
        • ID Generation Service
        • Localization Service
        • Email Notification Service
        • SMS Notification Service
        • SMS Template Approval Process
        • Searcher Service
        • Zuul Service
        • User OTP Service
        • eGov OTP Service
        • Persister Service
        • Encryption Service
        • Document Uploader Service
        • Notification Enhancement Based on Different Channels
        • Configuring Localization
          • Setup Base Product Localization
          • Configure SMS and Email
        • DIGIT: Internal Datamart Deployment Steps
        • Customizing PDF Notices And Certificates
          • Integration Of PDF In UI For Download And Print PDF
          • Customizing PDF Receipts & Certificates
      • QA Automation
        • Kafka Consumer Producer Approach
        • Jenkins Setup for Automation
        • Automation Framework Knowledge Base
          • Automation Test Tags
          • Automation Test Reporting
        • State-Level UI Customization
      • Configuration FAQs
    • CI/CD SetUp
      • CI/CD Build Job Pipeline Setup
  • 🛃Customize
    • Customize DIGIT
      • Frontend/UI
      • DIGIT Customization
        • API Do's & Don'ts
        • Writing A New Customer
        • Enhancing Existing Service
Powered by GitBook

​All content on this page by eGov Foundation is licensed under a Creative Commons Attribution 4.0 International License.

On this page
  • Best practices for securing your Kubernetes cluster
  • Use a Managed Kubernetes Service if Possible
  • Upgrade Kubernetes Frequently
  • Patch and Harden Your OS
  • Enforce RBAC
  • Use TLS
  • Segregate Resources in Namespaces
  • Control Pod to Pod Traffic
  • Create Separate User Accounts
  • Follow the Principle of Least Privilege
  • Frequently Rotate Infrastructure Credentials
  • Use a Partitioned Approach to Secure Secrets
  • Limit Resource Usage
  • Protect Your ETCD Cluster Like a Treasure Vault
  • Control Container Privileges
  • Enable Auditing
  • Conclusion

Was this helpful?

Edit on GitHub
Export as PDF
  1. Setup
  2. Learn More
  3. Setup Requirements

Infra Best Practices

PreviousTeam Composition for DIGIT ImplementationNextOperational Best practices

Last updated 3 years ago

Was this helpful?

Best practices for securing your Kubernetes cluster

Kubernetes has changed the way organizations deploy and run their applications, and it has created a significant shift in mindsets. While it has already gained a lot of popularity and more and more organizations are embracing the change, running Kubernetes in production requires care.

Although Kubernetes is open source and does it have its share of vulnerabilities, making the right architectural decision can prevent a disaster from happening.

You need to have a deep level of understanding of how Kubernetes works and how to enforce the best practices so that you can run a secure, highly available, production-ready Kubernetes cluster.

Although Kubernetes is a robust container orchestration platform, the sheer level of complexity with multiple moving parts overwhelms all administrators.

That is the reason why Kubernetes has a large attack surface, and, therefore, hardening of the cluster is an absolute must if you are to run Kubernetes in production.

There are a massive number of configurations in K8s, and while you can configure a few things correctly, the chances are that you might misconfigure a few things.

I will describe a few best practices that you can adopt if you are running Kubernetes in production. Let’s find out.

Use a Managed Kubernetes Service if Possible

If you are running your Kubernetes cluster in the cloud, consider using a managed Kubernetes cluster such as or .

A managed cluster comes with some level of hardening already in place, and, therefore, there are fewer chances to misconfigure things. A managed cluster also makes upgrades easy, and sometimes automatic. It helps you manage your cluster with ease and provides monitoring and alerting out of the box.

Upgrade Kubernetes Frequently

Since Kubernetes is open source, vulnerabilities appear quickly and security patches are released regularly. You need to ensure that your cluster is up to date with the latest security patches and for that, add an upgrade schedule in your standard operating procedure.

Having a CI/CD pipeline that runs periodically for executing rolling updates for your cluster is a plus. You would not need to check for upgrades manually, and rolling updates would cause minimal disruption and downtime; also, there would be fewer chances to make mistakes.

That would make upgrades less of a pain. If you are using a managed Kubernetes cluster, your cloud provider can cover this aspect for you.

Patch and Harden Your OS

It goes without saying that you should patch and harden the operating system of your Kubernetes nodes. This would ensure that an attacker would have the least attack surface possible.

You should upgrade your OS regularly and ensure that it is up to date.

Enforce RBAC

Kubernetes post version 1.6 has role-based access control (RBAC) enabled by default. Ensure that your cluster has this enabled.

You also need to ensure that legacy attribute-based access control (ABAC) is disabled. Enforcing RBAC gives you several advantages as you can now control who can access your cluster and ensure that the right people have the right set of permissions.

RBAC does not end with securing access to the cluster by Kubectl clients but also by pods running within the cluster, nodes, proxies, scheduler, and volume plugins.

Only provide the required access to service accounts and ensure that the API server authenticates and authorizes them every time they make a request.

Use TLS

Running your API server on plain HTTP in production is a terrible idea. It opens your cluster to a man in the middle attack and would open up multiple security holes.

Always use transport layer security (TLS) to ensure that communication between Kubectl clients and the API server is secure and encrypted.

Be aware of any non-TLS ports you expose for managing your cluster. Also ensure that internal clients such as pods running within the cluster, nodes, proxies, scheduler, and volume plugins use TLS to interact with the API server.

Segregate Resources in Namespaces

While it might be tempting to create all resources within your default namespace, it would give you tons of advantages if you use namespaces. Not only will it be able to segregate your resources in logical groups but it will also enable you to define security boundaries to resources in namespaces.

Namespaces logically behave as a separate cluster within Kubernetes. You might want to create namespaces based on teams, or based on the type of resources, projects, or customers depending on your use case.

After that, you can do clever stuff like defining resource quotas, limit ranges, user permissions, and RBAC on the namespace layer.

Avoid binding ClusterRoles to users and service accounts, instead provide them namespace roles so that users have access only to their namespace and do not unintentionally misconfigure someone else’s resources.

Cluster Role and Namespace Role Bindings

Control Pod to Pod Traffic

You can use Kubernetes network policies that work as firewalls within your cluster. That would ensure that an attacker who gained access to a pod (especially the ones exposed externally) would not be able to access other pods from it.

You can create Ingress and Egress rules to allow traffic from the desired source to the desired target and deny everything else.

Kubernetes Network Policy

Create Separate User Accounts

Do not share this file within your team, instead, create a separate user account for every user and only provide the right accesses to them. Bear in mind that Kubernetes does not maintain an internal user directory, and therefore, you need to ensure that you have the right solution in place to create and manage your users.

Once you create the user, you can generate a private key and a certificate signing request for the user, and Kubernetes would sign and generate a CA cert for the user.

You can then securely share the CA certificate with the user. The user can then use the certificate within kubectl to authenticate with the API server securely.

Configuring User Accounts

Follow the Principle of Least Privilege

You can provide granular access to user and service accounts with RBAC. Let us consider a typical organization where you can have multiple roles, such as:

  1. Application developers — These need access only to a namespace and not the entire cluster. Ensure that you provide them with access only to deploy their applications and troubleshoot them only within their namespace. You might want application developers with access to spin only ClusterIP services and might wish to grant permissions only to network administrators to define ingresses for them.

  2. Network administrators — You can provide network admins access to networking features such as ingresses, and privileges to spin up external services.

  3. Cluster administrators — These are sysadmins whose main job is to administer the entire cluster. These are the only people that should have cluster-admin access and only the amount that is necessary for them to do their roles.

The above is not etched in stone, and you can have a different organization policy and different roles, but the only thing to keep in mind here is that you need to enforce the principle of least privilege.

That means that individuals and teams should have only the right amount of access they need to perform their job, nothing less and nothing more.

Frequently Rotate Infrastructure Credentials

It does not stop with just issuing separate user accounts and using TLS to authenticate with the API server. It is an absolute must that you frequently rotate and issue credentials to your users.

Set up an automated system that periodically revokes the old TLS certificates and issues new ones to your user. That helps as you don’t want attackers to get hold of a TLS cert or a token and then make use of it indefinitely.

Use a Partitioned Approach to Secure Secrets

Imagine a scenario where an externally exposed web application is compromised, and someone has gained access to the pod. In that scenario, they would be able to access the secrets (such as private keys) and target the entire system.

The way to protect from this kind of attack is to have a sidecar container that stores the private key and responds to signing requests from the main container.

In case someone gets access to your login microservice, they would not be able to gain access to your private key, and therefore, it would not be a straightforward attack, giving you valuable time to protect yourself.

Partitioned Approach

Limit Resource Usage

The last thing you would want as a cluster-admin is a situation where a poorly written microservice code that has a memory leak can take over a cluster node causing the Kubernetes cluster to crash. That is an extremely important and generally ignored area.

You can add a resource limit and requests on the pod level as a developer or the namespace as an administrator. You can use resource quotas to limit the amount of CPU, memory, or persistent disk a namespace can allocate.

It can also allow you to limit the number of pods, volumes, or services you can spin within a namespace. You can also make use of limit ranges that provide you with a minimum and maximum size of resources every unit of the cluster within the namespace can request.

That will limit users from seeking an unusually large amount of resources such as memory and CPU.

Specifying a default resource limit and request on a namespace level is generally a good idea as developers aren’t perfect. If they forget to specify a limit, then the default limit and requests would protect you from resource overrun.

Protect Your ETCD Cluster Like a Treasure Vault

The ETCD datastore is the primary source of data for your Kubernetes cluster. That is where all cluster information and the expected configuration is stored.

If someone gains access to your ETCD database, all security measures will go down the drain. They will have full control of your cluster, and they can do what they want by modifying state in your ETCD datastore.

You should always ensure that only the API server can communicate with the ETCD datastore and only through TLS using a secure mutual auth. You can put your ETCD nodes behind a firewall and block all traffic except the ones originating from the API server.

Do not use the master ETCD for any other purpose but for managing your Kubernetes cluster and do not provide any other component access to the ETCD cluster.

Enable encryption of your secret data at rest. That is extremely important so that if someone gets access to your ETCD cluster, they should not be able to view your secrets by just doing a hex dump of your secrets.

Control Container Privileges

Containers run on nodes and therefore have some level of access to the host file system, however, the best way to reduce the attack surface is to architect your application in such a way that containers do not need to run as root.

Use pod security policies to restrict the pod to access HostPath volumes as that might result in getting access to the host filesystem. Administrators can use a restrictive pod policy so that anyone who gained access to one pod should not be able to access another pod from there.

Enable Auditing

Audit loggers are now a beta feature in Kubernetes, and I recommend you make use of it. That would help you troubleshoot and investigate what happened in case of an attack.

As a cluster-admin dealing with a security incident, the last thing you would want is that you are unaware of what exactly happened with your cluster and who has done what.

Conclusion

Remember that the above are just some general best practices and they are not exhaustive. You are free to adjust and make changes based on your use case and ways of working for your team.

By default, when you boot your cluster through , you get access to the kubernetes-admin config file which is the superuser for performing all activities within your cluster.

A bootstrap token, for example, needs to be revoked as soon as you finish with your activity. You can also make use of a credential management system such as which can issue you with credentials when you need them and revoke them when you finish with your work.

All content on this page by is licensed under a .

⏹️
Google Kubernetes Engine
Azure Kubernetes Service
kubeadm
HashiCorp Vault
​
eGov Foundation
Creative Commons Attribution 4.0 International License
Creative Commons License