Linux_Practical_Interview_751 1000
Linux Practical Interview Questions (751-1000)
Section titled “Linux Practical Interview Questions (751-1000)”Linux Advanced Administration
Section titled “Linux Advanced Administration”Q751: How do you configure system performance monitoring?
Section titled “Q751: How do you configure system performance monitoring?”Answer:
# Use SAR for historical dataENABLED="true"
# Enable collectionsystemctl enable sysstatsystemctl start sysstat
# View reportssar -u 1 5 # CPU usagesar -r 1 5 # Memorysar -b 1 5 # I/Osar -n DEV 1 5 # NetworkQ752: How do you configure custom metrics collection?
Section titled “Q752: How do you configure custom metrics collection?”Answer:
# Use node_exporterdocker run -d -p 9100:9100 prom/node-exporter
# Custom metrics#!/bin/bashwhile true; do echo "custom_metric $(date +%s)" | nc -q1 localhost 9090 sleep 10doneQ753: How do you set up centralized logging?
Section titled “Q753: How do you set up centralized logging?”Answer:
# Using rsyslog# Server$ModLoad imtcp$InputTCPServerRun 514
# Client*.* @@logging-server:514
# Or ELK stack# Filebeat -> Logstash -> Elasticsearch -> KibanaQ754: How do you configure log retention policies?
Section titled “Q754: How do you configure log retention policies?”Answer:
# logrotate/var/log/myapp/*.log { daily rotate 90 compress delaycompress missingok create 0640 user group}
# Or with systemd# journald.confSystemMaxUse=500MMaxFileSec=1monthQ755: How do you implement audit trails?
Section titled “Q755: How do you implement audit trails?”Answer:
# Configure auditdauditctl -w /etc/passwd -p wa -k identityauditctl -w /etc/shadow -p wa -k identityauditctl -w /var/log/ -p wa -k logfiles
# Searchausearch -k identityaureport -fQ756: How do you set up file integrity monitoring?
Section titled “Q756: How do you set up file integrity monitoring?”Answer:
# Install AIDEaideinit
# Configure# /etc/aide/aide.conf/etc/shadow NORMAL/etc/passwd NORMAL/var/log NORMAL
# Daily check0 5 * * * /usr/bin/aide --checkQ757: How do you implement intrusion detection?
Section titled “Q757: How do you implement intrusion detection?”Answer:
# OSSEC# Installapt install ossec-hids-agent
# Configure# /var/ossec/etc/ossec.conf<active-response> <disabled>no</disabled></active-response>
# Rules in# /var/ossec/etc/rules/local_rules.xmlQ758: How do you configure network monitoring?
Section titled “Q758: How do you configure network monitoring?”Answer:
# Use Prometheus + blackbox exporterdocker run -d -p 9115:9110 prom/blackbox-exporter
# Configure# /etc/blackbox/blackbox.ymlmodules: http_2xx: prober: http
# Prometheus scrape- job_name: blackbox metrics_path: /probe static_configs: - targets: - https://example.comQ759: How do you set up service monitoring?
Section titled “Q759: How do you set up service monitoring?”Answer:
# Use Prometheus- job_name: 'service' static_configs: - targets: ['localhost:8080']
# Health check endpoint#!/bin/bashcurl -f http://localhost:8080/health || exit 1Q760: How do you implement application performance monitoring?
Section titled “Q760: How do you implement application performance monitoring?”Answer:
# Use APM (Application Performance Monitoring)# Options: New Relic, Datadog, Dynatrace, Elastic APM
# Example: Elastic APM# Install agentpip install elastic-apm
# Configure# apm.pyfrom elasticapm import Clientclient = Client(service_name='myapp')Q761: How do you configure system hardening scripts?
Section titled “Q761: How do you configure system hardening scripts?”Answer:
# CIS Benchmarks# Use Lynislynis audit system
# Use OpenSCAPoscap xccdf eval --profile xccdf_org.ssgproject.content_profile_cis \ --results scan-results.xml /usr/share/xml/scap/ssg/content/ssg-ubuntu2004-ds.xml
# Use CIS-CAT ProQ762: How do you implement automated patching?
Section titled “Q762: How do you implement automated patching?”Answer:
# unattended-upgradesapt install unattended-upgrades
# Configure# /etc/apt/apt.conf.d/50unattended-upgradesUnattended-Upgrade::Allowed-Origins { "${distro_id}:${distro_codename}-security";};
# Enabledpkg-reconfigure -plow unattended-upgradesQ763: How do you configure vulnerability scanning?
Section titled “Q763: How do you configure vulnerability scanning?”Answer:
# Use OpenVAS# Installapt install openvas
# Setupgreenbone-nvt-syncopenvasmd --rebuild
# Run scanopenvas -o scan-report.xml --target=target-id
# Or use Trivytrivy image nginx:latesttrivy fs .Q764: How do you implement change management?
Section titled “Q764: How do you implement change management?”Answer:
# Use configuration management# Ansible, Puppet, Chef, Salt
# Track changes# GitOps with ArgoCD/Flux
# Example: Ansible Tower# Create job templates# Track execution history# Require approval for productionQ765: How do you configure compliance reporting?
Section titled “Q765: How do you configure compliance reporting?”Answer:
# Use OpenSCAPoscap xccdf generate report scan-results.xml > report.html
# Use Lynislynis audit system --report-file /root/lynis-report.log
# Use AIDEaide --check --report /root/aide-report.logQ766: How do you implement data classification?
Section titled “Q766: How do you implement data classification?”Answer:
# Define classification levels# Public, Internal, Confidential, Restricted
# Implement with SELinuxsemanage fcontext -a -t confidential_t "/srv/confidential(/.*)?"
# Use ACLssetfacl -R -m u:admin:rwX /data/confidentialsetfacl -R -m g:auditors:rX /data/confidentialQ767: How do you configure data loss prevention?
Section titled “Q767: How do you configure data loss prevention?”Answer:
# Use OpenDLP# Or use content filters
# iptables exampleiptables -A OUTPUT -m string --string "confidential" -j DROP
# Or use auditdauditctl -w /data/ -p wa -k data_lossQ768: How do you implement encryption at rest?
Section titled “Q768: How do you implement encryption at rest?”Answer:
# LUKScryptsetup luksFormat /dev/sdb1cryptsetup open /dev/sdb1 crypt_volmkfs.ext4 /dev/mapper/crypt_vol
# File-level encryption# Use GPG or agegpg -c file.txt
# Database encryption# PostgreSQL: pgcrypto extensionQ769: How do you implement encryption in transit?
Section titled “Q769: How do you implement encryption in transit?”Answer:
# TLS/SSL everywhere# Nginxssl_protocols TLSv1.2 TLSv1.3;ssl_ciphers HIGH:!aNULL:!MD5;
# Database# PostgreSQL: ssl = on# MySQL: require ssl
# SSH# Use strong ciphersCiphers chacha20-poly1305@openssh.com,aes256-gcm@openssh.comQ770: How do you configure key management?
Section titled “Q770: How do you configure key management?”Answer:
# HashiCorp Vaultvault server -dev
# Store secretsvault kv put secret/myapp api_key=xxx
# Use in application# Use kubernetes-secrets-injector or external-secrets-operatorQ771: How do you implement access control?
Section titled “Q771: How do you implement access control?”Answer:
# RBAC (Role-Based Access Control)# Linux: groups and sudo
# SELinux# Enable and configure contextssemanage fcontext -a -t httpd_sys_content_t "/web(/.*)?"
# AppArmor# Create profiles for applicationsQ772: How do you configure network segmentation?
Section titled “Q772: How do you configure network segmentation?”Answer:
# VLANsvconfig add eth0 100vconfig add eth0 200
# Firewalls# DMZ, internal, database tiers
# Kubernetes# NetworkPolicieskubectl apply -f network-policy.yamlQ773: How do you implement zero trust network?
Section titled “Q773: How do you implement zero trust network?”Answer:
# mTLS for all communication# Use service mesh (Istio, Linkerd)
# Certificate-based authentication# Short-lived certificates
# Continuous verification# Real-time policy enforcementQ774: How do you configure API security?
Section titled “Q774: How do you configure API security?”Answer:
# Rate limiting# Nginxlimit_req_zone $binary_remote_addr zone=api:10m rate=10r/s;
# Authentication# JWT tokens# OAuth2/OIDC
# API Gateway# Kong, AWS API Gateway, TykQ775: How do you implement DDoS protection?
Section titled “Q775: How do you implement DDoS protection?”Answer:
# Rate limiting# Nginxlimit_req_zone $binary_remote_addr zone=ddos:10m rate=100r/s;
# Fail2ban# Block repeated offenders
# Cloud protection# AWS Shield, Cloudflare, AkamaiQ776: How do you configure backup verification?
Section titled “Q776: How do you configure backup verification?”Answer:
# Automated restore test#!/bin/bash# Restore to test environment# Verify data integrity# Report results
# Add to cron# 0 2 * * 0 /opt/backup-verify.shQ777: How do you implement disaster recovery testing?
Section titled “Q777: How do you implement disaster recovery testing?”Answer:
# Test procedures# 1. Document RTO/RPO# 2. Create runbooks# 3. Test failover# 4. Verify data# 5. Document lessons
# Schedule quarterly testsQ778: How do you configure high availability?
Section titled “Q778: How do you configure high availability?”Answer:
# Load balancer# HAProxy, NGINX
# Clustering# Pacemaker + Corosync# Keepalived for VIP
# Database# Master-slave or multi-master# Connection poolingQ779: How do you implement load balancing?
Section titled “Q779: How do you implement load balancing?”Answer:
# HAProxy configurationbackend servers balance roundrobin server s1 192.168.1.10:80 check server s2 192.168.1.11:80 check
# Health checks# Check inter 3s fall 2 rise 1Q780: How do you configure auto-scaling?
Section titled “Q780: How do you configure auto-scaling?”Answer:
# Kubernetes HPAkubectl autoscale deployment myapp --cpu-percent=70 --min=2 --max=10
# Cloud provider# AWS Auto Scaling Groups# GCP Managed Instance Groups# Azure Virtual Machine Scale SetsLinux DevOps
Section titled “Linux DevOps”Q781: How do you set up CI/CD pipeline?
Section titled “Q781: How do you set up CI/CD pipeline?”Answer:
# Jenkins# Installapt install jenkins
# Create pipeline# Jenkinsfilepipeline { agent any stages { stage('Build') { steps { sh 'make build' } } stage('Test') { steps { sh 'make test' } } stage('Deploy') { steps { sh 'make deploy' } } }}Q782: How do you use GitLab CI?
Section titled “Q782: How do you use GitLab CI?”Answer:
stages: - build - test - deploy
build: stage: build script: - docker build -t $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA . - docker push $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA
deploy: stage: deploy script: - kubectl apply -f deployment.yaml only: - mainQ783: How do you use GitHub Actions?
Section titled “Q783: How do you use GitHub Actions?”Answer:
name: CIon: [push]jobs: build: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - name: Run tests run: make test - name: Build run: make buildQ784: How do you configure container registries?
Section titled “Q784: How do you configure container registries?”Answer:
# Harbor# Installdocker run -d -p 80:80 -p 443:443 -v /data/harbor:/etc/harbor --name harborVMWare/harbor
# Pushdocker push myregistry.com/myimage:tag
# Pull with credentialsdocker login myregistry.comQ785: How do you implement infrastructure as code?
Section titled “Q785: How do you implement infrastructure as code?”Answer:
# Terraform example# main.tfprovider "aws" { region = "us-east-1"}
resource "aws_instance" "web" { ami = "ami-xxx" instance_type = "t3.micro" tags = { Name = "web" }}
# Commandsterraform initterraform planterraform applyQ786: How do you use Ansible for configuration management?
Section titled “Q786: How do you use Ansible for configuration management?”Answer:
- hosts: webservers become: yes tasks: - name: Install nginx apt: name: nginx state: present - name: Start nginx service: name: nginx state: started enabled: yesQ787: How do you use Chef for automation?
Section titled “Q787: How do you use Chef for automation?”Answer:
package 'nginx' do action :installend
service 'nginx' do action [:enable, :start]end
template '/etc/nginx/nginx.conf' do source 'nginx.conf.erb' mode '0644' notifies :restart, 'service[nginx]'endQ788: How do you use Puppet for automation?
Section titled “Q788: How do you use Puppet for automation?”Answer:
class nginx { package { 'nginx': ensure => installed, } service { 'nginx': ensure => running, enable => true, }}
include nginxQ789: How do you use Vagrant for development?
Section titled “Q789: How do you use Vagrant for development?”Answer:
# VagrantfileVagrant.configure("2") do |config| config.vm.box = "ubuntu/focal64"
config.vm.network "private_network", ip: "192.168.33.10"
config.vm.synced_folder "./data", "/vagrant_data"
config.vm.provision "shell", inline: <<-SHELL apt-get update apt-get install -y nginx SHELLendQ790: How do you use Packer for images?
Section titled “Q790: How do you use Packer for images?”Answer:
{ "builders": [ { "type": "amazon-ebs", "region": "us-east-1", "source_ami": "ami-xxx", "instance_type": "t2.micro", "ami_name": "my-custom-image" } ], "provisioners": [ { "type": "shell", "inline": [ "apt-get update", "apt-get install -y nginx" ] } ]}Linux Troubleshooting Advanced
Section titled “Linux Troubleshooting Advanced”Q791: How do you troubleshoot kernel panics?
Section titled “Q791: How do you troubleshoot kernel panics?”Answer:
# Check logsjournalctl -b -1dmesg
# Enable crash dump# /etc/default/kdump-toolsUSE_KDUMP=1
# After crash# Analyze with crash utilitycrash /var/crash/vmcore /usr/lib/debug/boot/vmlinux-$(uname -r)Q792: How do you troubleshoot OOM issues?
Section titled “Q792: How do you troubleshoot OOM issues?”Answer:
# Check OOM killerdmesg | grep -i "out of memory"journalctl -k | grep -i "killed process"
# Check processps aux --sort=-%mem | head
# Tune kernel# /etc/sysctl.confvm.overcommit_memory = 1vm.swappiness = 10Q793: How do you troubleshoot disk I/O bottlenecks?
Section titled “Q793: How do you troubleshoot disk I/O bottlenecks?”Answer:
# Check I/Oiostat -x 1
# Check processesiotop
# Check latencyiostat -x 1 | grep await
# Check queuecat /proc/diskstatsQ794: How do you troubleshoot network latency?
Section titled “Q794: How do you troubleshoot network latency?”Answer:
# Check latencyping -c 10 hostmtr host
# Check routesip routetraceroute host
# Check DNSdig hostnslookup host
# Check firewalliptables -L -nQ795: How do you troubleshoot high CPU usage?
Section titled “Q795: How do you troubleshoot high CPU usage?”Answer:
# Top processestophtop
# Per-processps aux --sort=-%cpu | head
# Threadsps -eLf -p PID
# System-widempstat -P ALL 1Q796: How do you troubleshoot memory leaks?
Section titled “Q796: How do you troubleshoot memory leaks?”Answer:
# Check memoryfree -h
# Monitor processpmap -x PID
# Use valgrindvalgrind --leak-check=full ./program
# Use systemd-cgtopsystemd-cgtopQ797: How do you troubleshoot service crashes?
Section titled “Q797: How do you troubleshoot service crashes?”Answer:
# Check statussystemctl status service
# Check logsjournalctl -u service -n 50journalctl -xe
# Core dumps# Enable# /etc/security/limits.conf* soft core unlimited
# Analyzecoredumpctlcoredumpctl gdb PIDQ798: How do you troubleshoot SSH issues?
Section titled “Q798: How do you troubleshoot SSH issues?”Answer:
# Verbose SSHssh -vvv user@host
# Check logstail -f /var/log/auth.log
# Test connectivitync -zv host 22
# Check keysls -la ~/.ssh/Q799: How do you troubleshoot DNS resolution?
Section titled “Q799: How do you troubleshoot DNS resolution?”Answer:
# Test DNSnslookup hostdig host +trace
# Check resolv.confcat /etc/resolv.conf
# Flush DNSsystemd-resolve --flush-caches
# Test specific servernslookup host 8.8.8.8Q800: How do you troubleshoot database performance?
Section titled “Q800: How do you troubleshoot database performance?”Answer:
# PostgreSQLEXPLAIN ANALYZE SELECT * FROM table;
# MySQLEXPLAIN FORMAT=JSON SELECT * FROM table;
# Check connectionsSELECT * FROM pg_stat_activity;
# Check slow queriesSHOW VARIABLES LIKE 'slow_query_log';Linux Advanced Topics
Section titled “Linux Advanced Topics”Q801: How do you configure kernel live patching?
Section titled “Q801: How do you configure kernel live patching?”Answer:
# Ubuntu Livepatch# Installsnap install canonical-livepatch
# Enablesudo canonical-livepatch enable
# Check statuscanonical-livepatch statusQ802: How do you use kpatch?
Section titled “Q802: How do you use kpatch?”Answer:
# Installapt install kpatch-dkms
# Create patchkpatch-build patch.diff
# Applykpatch load patch.ko
# Listkpatch listQ803: How do you configure dynamic tracing?
Section titled “Q803: How do you configure dynamic tracing?”Answer:
# Use bpftraceapt install bpftrace
# Write script# mytrace.bt#!/usr/bin/bpftraceBEGIN{ printf("Tracing... Hit Ctrl-C to end.\n")}kprobe:do_nice{ printf("PID %d nice: %d\n", pid, arg1)}
# Runbpftrace mytrace.btQ804: How do you use ftrace?
Section titled “Q804: How do you use ftrace?”Answer:
# Enablemount -t debugfs nodev /sys/kernel/debug
# List available tracerscat /sys/kernel/debug/tracing/available_tracers
# Set tracerecho function > /sys/kernel/debug/tracing/current_tracer
# Enable functionecho '*tcp*' > /sys/kernel/debug/tracing/set_ftrace_filter
# Readcat /sys/kernel/debug/tracing/traceQ805: How do you use perfetto?
Section titled “Q805: How do you use perfetto?”Answer:
# Installapt install perfetto
# Create config# config.pbtxtbuffers: { size_kb: 63488 fill_policy: DISCARD}data_sources: { config { name: "linux.ftrace" ftrace_config { ftrace_events: "sched/sched_switch" ftrace_events: "power/cpu_frequency" } }}
# Traceperfetto -c config.pbtxt -o trace.perfettoQ806: How do you configure BPF programs?
Section titled “Q806: How do you configure BPF programs?”Answer:
#include <linux/bpf.h>#include <bpf/bpf_helpers.h>
SEC("xdp_drop")int xdp_drop_prog(struct xdp_md *ctx) { return XDP_DROP;}
char _license[] SEC("license") = "GPL";Q807: How do you use CRIU?
Section titled “Q807: How do you use CRIU?”Answer:
# Installapt install criu
# Checkpointcriu dump -t PID --images-dir /tmp/checkpoint
# Restorecriu restore --images-dir /tmp/checkpoint
# Pre-dumpcriu predump -t PID --images-dir /tmp/checkpointQ808: How do you use crictl with Kata Containers?
Section titled “Q808: How do you use crictl with Kata Containers?”Answer:
# Install Kata Containerskata-runtime --version
# Configure containerd# /etc/containerd/config.toml[plugins] [plugins."io.containerd.grpc.v1.cri"] runtime_handler = "io.containerd.kata.v2"
# Use runtimecrictl run --runtime io.containerd.kata.v2 container.json pod.jsonQ809: How do you configure gVisor?
Section titled “Q809: How do you configure gVisor?”Answer:
# Installapt install runsc
# Configure containerd# /etc/containerd/config.toml[plugins] [plugins."io.containerd.grpc.v1.cri"] runtime_handler = "runsc"
# Runcrictl run --runtime runsc container.json pod.jsonQ810: How do you use Firecracker?
Section titled “Q810: How do you use Firecracker?”Answer:
# Installapt install firecracker
# Create microVM# config.json{ "boot-source": "vmlinux", "kernel-image": "vmlinux", "drive": { "path": "rootfs.ext4" }, "network-interfaces": [ { "guest-device": "eth0" } ]}
# Runfirecracker --config-file config.jsonLinux Cloud Native Advanced
Section titled “Linux Cloud Native Advanced”Q811: How do you use K3s in production?
Section titled “Q811: How do you use K3s in production?”Answer:
# Install with high availability# Use embedded etcd or external DB
# Installcurl -sfL https://get.k3s.io | INSTALL_K3S_EXEC="--write-kubeconfig-mode 644" sh -
# Tokencat /var/lib/rancher/k3s/server/node-token
# Add agentcurl -sfL https://get.k3s.io | K3S_URL=https://server:6443 K3S_TOKEN=TOKEN sh -Q812: How do you use K3s storage?
Section titled “Q812: How do you use K3s storage?”Answer:
# Use Longhorn# Installkubectl apply -f https://raw.githubusercontent.com/longhorn/longhorn/master/deploy/longhorn.yaml
# Create PVCapiVersion: v1kind: PersistentVolumeClaimmetadata: name: mypvcspec: accessModes: - ReadWriteOnce storageClassName: longhorn resources: requests: storage: 1GiQ813: How do you configure K3s service mesh?
Section titled “Q813: How do you configure K3s service mesh?”Answer:
# Install Linkerdcurl -sL https://run.linkerd.io/install | sh
# Injectkubectl get deploy -o yaml | linkerd inject - | kubectl apply -f -
# Checklinkerd viz dashboardQ814: How do you use k0s?
Section titled “Q814: How do you use k0s?”Answer:
# Installcurl -sSLf https://get.k0sproject.io | sh
# Startk0s controller
# Add workerk0s worker --token-file /var/lib/k0s/worker.tokenQ815: How do you use MicroK8s?
Section titled “Q815: How do you use MicroK8s?”Answer:
# Installsnap install microk8s --classic
# Enable addonsmicrok8s enable dns storage ingress
# Check statusmicrok8s status
# Use kubectlmicrok8s kubectl get podsQ816: How do you use Minikube with drivers?
Section titled “Q816: How do you use Minikube with drivers?”Answer:
# Installcurl -LO https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64install minikube-linux-amd64 /usr/local/bin/minikube
# Start with Dockerminikube start --driver=docker
# Start with KVMminikube start --driver=kvm2
# Addonsminikube addons enable ingressQ817: How do you use Kind?
Section titled “Q817: How do you use Kind?”Answer:
# Installgo install sigs.k8s.io/kind@v0.20.0
# Create clusterkind create cluster
# Custom clusterkind create cluster --config kind-config.yaml
# Load imagekind load docker-image myimage:latestQ818: How do you use k9s?
Section titled “Q818: How do you use k9s?”Answer:
# Installcurl -sS https://webinstall.dev/k9s | bash
# Runk9s
# Commands# :ns - namespace# :po - pods# :svc - services# :dp - deploymentsQ819: How do you use Lens?
Section titled “Q819: How do you use Lens?”Answer:
# Install# Download from lenside.com
# Connect to cluster# Add cluster via kubeconfig
# Features# Visual interface# Resource management# Terminal integrationQ820: How do you use Octant?
Section titled “Q820: How do you use Octant?”Answer:
# Install# Download from GitHub releases
# Runoctant
# Or as plugin in Lens# Enable in settingsLinux Advanced Security
Section titled “Linux Advanced Security”Q821: How do you configure SELinux policies?
Section titled “Q821: How do you configure SELinux policies?”Answer:
# Install policy toolsapt install policycoreutils-devel selinux-policy-dev
# Create module# myapp.temodule myapp 1.0;require { type http_t; type var_t; class file { read write };}allow http_t var_t:file { read write };
# Compilecheckmodule -M -m -o myapp.mod myapp.te
# Installsemodule -i myapp.ppQ822: How do you create AppArmor profiles?
Section titled “Q822: How do you create AppArmor profiles?”Answer:
# Generate profileaa-genprof /usr/bin/myapp
# Enforceaa-enforce /usr/bin/myapp
# Monitor in complainaa-complain /usr/bin/myapp
# Check statusaa-statusQ823: How do you implement full disk encryption?
Section titled “Q823: How do you implement full disk encryption?”Answer:
# During installation# Use LVM with LUKS
# After installation# Use dm-cryptcryptsetup luksFormat /dev/sdb1
# Backup headercryptsetup luksHeaderBackup /dev/sdb1 --header-backup-file /root/luks-header.imgQ824: How do you configure secure boot?
Section titled “Q824: How do you configure secure boot?”Answer:
# Install signed kernel# Use UEFI secure boot
# Enroll keys# MOK (Machine Owner Key)mokutil --import key.der
# Verifymokutil --list-enrolledsbverify --list /boot/vmlinuzQ825: How do you implement TPM security?
Section titled “Q825: How do you implement TPM security?”Answer:
# Install TPM toolsapt install tpm2-tools
# Create keytpm2_createprimary -G rsa -o primary.key
# Sealtpm2_unseal -c primary.key -o unsealed.key -i sealed.data
# Unsealtpm2_unseal -c primary.key -i sealed.dataQ826: How do you configure secure container runtime?
Section titled “Q826: How do you configure secure container runtime?”Answer:
# Use gVisor# Install runsc
# Use Kata Containers# Install kata-runtime
# Use Rootless Podmanpodman run --security-opt seccomp=default --security-opt no-new-privileges nginxQ827: How do you implement network policies in Kubernetes?
Section titled “Q827: How do you implement network policies in Kubernetes?”Answer:
# Default denyapiVersion: networking.k8s.io/v1kind: NetworkPolicymetadata: name: default-deny-allspec: podSelector: {} policyTypes: - Ingress - EgressQ828: How do you secure Kubernetes API?
Section titled “Q828: How do you secure Kubernetes API?”Answer:
# Use RBAC# Create ServiceAccount with minimal permissions
# Enable RBAC--authorization-mode=RBAC
# Use TLS# Ensure all traffic uses TLS
# Network policies# Limit access to API serverQ829: How do you secure etcd?
Section titled “Q829: How do you secure etcd?”Answer:
# Use TLS# Enable encryption at rest# Use separate etcd cluster# Enable authentication
# Backup etcdETCDCTL_API=3 etcdctl snapshot save backup.db \ --endpoints=https://127.0.0.1:2379 \ --cacert=/etc/kubernetes/pki/etcd/ca.crt \ --cert=/etc/kubernetes/pki/etcd/server.crt \ --key=/etc/kubernetes/pki/etcd/server.keyQ830: How do you implement secrets management in K8s?
Section titled “Q830: How do you implement secrets management in K8s?”Answer:
# Use external-secretsapiVersion: external-secrets.io/v1beta1kind: ClusterSecretStoremetadata: name: vault-backendspec: provider: vault: server: "https://vault:8200" path: "secret" version: "v2"
---apiVersion: external-secrets.io/v1beta1kind: ExternalSecretmetadata: name: mysecretspec: refreshInterval: 1h secretStoreRef: name: vault-backend kind: ClusterSecretStore target: name: mysecret data: - secretKey: api_key remoteRef: key: myapp/api_keyLinux Performance Engineering
Section titled “Linux Performance Engineering”Q831: How do you use BPF for performance?
Section titled “Q831: How do you use BPF for performance?”Answer:
# Use bpfcc-toolsapt install bpfcc-tools
# CPU analysisfunccount-bpfcc 't:kernel_function'
# I/O analysisbiolatency-bpfcc
# Network analysistcplife-bpfccQ832: How do you use flame graphs?
Section titled “Q832: How do you use flame graphs?”Answer:
# Installgit clone https://github.com/brendangregg/FlameGraph.git
# Generate# CPU profileperf record -F 99 -p PID -gperf script | ./FlameGraph/stackcollapse-perf.pl | ./FlameGraph/flamegraph.pl > flame.svg
# Memory./flamegraph.pl --title="Memory Profile" < profile.txt > memory.svgQ833: How do you use eBPF for tracing?
Section titled “Q833: How do you use eBPF for tracing?”Answer:
# bpftrace examples# Count system callsbpftrace -e 'tracepoint:syscalls:sys_enter_* { @[comm] = count(); }'
# Measure latencybpftrace -e 'kprobe:do_nice { @start[comm] = nsecs(); } kretprobe:do_nice /@start[comm]/ { @ns[comm] = quantize(nsecs() - @start[comm]); }'
# Network connectionsbpftrace -e 'kprobe:tcp_connect { @[comm] = count(); }'Q834: How do you configure kernel tuning for low latency?
Section titled “Q834: How do you configure kernel tuning for low latency?”Answer:
# Networknet.core.rmem_max = 134217728net.core.wmem_max = 134217728
# Kernelkernel.sched_latency_ns = 10000000kernel.sched_min_granularity_ns = 1000000kernel.sched_wakeup_granularity_ns = 1000000
# Applysysctl -pQ835: How do you optimize for real-time?
Section titled “Q835: How do you optimize for real-time?”Answer:
# Install RT kernelapt install linux-image-rt-*
# Configure# /etc/default/rtirqRTIRQ_RESET_ALL=onRTIRQ_POLLING="rtc"
# CPU isolation# Add to GRUB: isolcpus=1,2,3Q836: How do you use DPDK?
Section titled “Q836: How do you use DPDK?”Answer:
# Install DPDK# Download from dpdk.org
# Setupexport DPDK_DIR=/path/to/dpdkexport RTE_SDK=$DPDK_DIRexport RTE_TARGET=x86_64-native-linuxapp-gcc
# Buildmake config T=$RTE_TARGETmake -j$(nproc)
# Huge pagesecho 1024 > /sys/kernel/mm/hugepages/hugepages-2048kB/nr_hugepagesQ837: How do you use RDMA?
Section titled “Q837: How do you use RDMA?”Answer:
# Installapt install rdma-core
# Check devicesrdma link
# Configure# Use Mellanox or Intel RDMA cards
# Testib_write_bw -d mlx5_0 -aQ838: How do you use SR-IOV?
Section titled “Q838: How do you use SR-IOV?”Answer:
# Enable in BIOS
# Enable in kernel# Add to GRUB: intel_iommu=on
# Configureecho 2 > /sys/bus/pci/devices/0000\:01\:00.0/sriov_numvfs
# Verifylspci | grep -i virtual
# Assign to VMvirsh attach-interface --domain vm --type hostdev --source 0000:01:00.2 --managedQ839: How do you use NUMA optimization?
Section titled “Q839: How do you use NUMA optimization?”Answer:
# Check NUMAnumactl --hardware
# Pin processnumactl --cpunodebind=0 --membind=0 process
# Use libnuma# In codenuma_run_on_node(0);numa_tonodememory(0, size);Q840: How do you use huge pages?
Section titled “Q840: How do you use huge pages?”Answer:
# Checkcat /proc/meminfo | grep Huge
# Configureecho 256 > /sys/kernel/mm/hugepages/hugepages-2048kB/nr_hugepages
# Use in application# mmap with MAP_HUGETLB flag
# For Java# -XX:+UseLargePagesLinux Advanced Storage
Section titled “Linux Advanced Storage”Q841: How do you configure NVMe optimization?
Section titled “Q841: How do you configure NVMe optimization?”Answer:
# Checknvme listnvme smart-log /dev/nvme0
# Optimize# Use noop or deadline schedulerecho none > /sys/block/nvme0n1/queue/scheduler
# Increase queue depthecho 1024 > /sys/block/nvme0n1/queue/nr_requestsQ842: How do you use persistent memory?
Section titled “Q842: How do you use persistent memory?”Answer:
# Checkndctl list
# Create namespacendctl create-namespace
# Mount# As DAX (Direct Access)mkfs.ext4 -F /dev/pmem0mount -o dax /dev/pmem0 /mnt/pmem
# Use in code# Use libpmemQ843: How do you configure storage class for performance?
Section titled “Q843: How do you configure storage class for performance?”Answer:
# Kubernetes StorageClassapiVersion: storage.k8s.io/v1kind: StorageClassmetadata: name: fastprovisioner: kubernetes.io/gce-pdparameters: type: pd-ssd replication-type: regional-pdvolumeBindingMode: WaitForFirstConsumerQ844: How do you implement distributed storage?
Section titled “Q844: How do you implement distributed storage?”Answer:
# Use Ceph# Installceph-deploy install node1 node2 node3ceph-deploy mon create node1ceph-deploy osd create node1:/dev/sdb
# Create poolceph osd pool create mypool 100
# Userbd create mypool/image --size 10GQ845: How do you use minIO?
Section titled “Q845: How do you use minIO?”Answer:
# Installwget https://dl.min.io/server/minio/release/linux-amd64/miniochmod +x minio
# Start./minio server /data
# Use S3 APImc alias set myminio http://localhost:9000 accesskey secretkeymc mb myminio/mybucketQ846: How do you use Rook/Ceph in Kubernetes?
Section titled “Q846: How do you use Rook/Ceph in Kubernetes?”Answer:
# Install Rookkubectl apply -f https://raw.githubusercontent.com/rook/rook/master/cluster/examples/kubernetes/ceph/common.yamlkubectl apply -f https://raw.githubusercontent.com/rook/rook/master/cluster/examples/kubernetes/ceph/cluster.yaml
# Create PVCapiVersion: v1kind: PersistentVolumeClaimmetadata: name: mypvcspec: storageClassName: rook-ceph-block accessModes: - ReadWriteOnce resources: requests: storage: 1GiQ847: How do you configure local PV?
Section titled “Q847: How do you configure local PV?”Answer:
apiVersion: v1kind: PersistentVolumemetadata: name: local-pvspec: capacity: storage: 10Gi accessModes: - ReadWriteOnce persistentVolumeReclaimPolicy: Retain storageClassName: local-storage local: path: /mnt/disks/ssd1 nodeAffinity: required: nodeSelectorTerms: - matchExpressions: - key: kubernetes.io/hostname operator: In values: - node-1Q848: How do you use NFS provisioner?
Section titled “Q848: How do you use NFS provisioner?”Answer:
# Install NFS provisionerhelm install nfs-server stable/nfs-server-provisioner
# Create PVCapiVersion: v1kind: PersistentVolumeClaimmetadata: name: mypvcspec: storageClassName: nfs accessModes: - ReadWriteMany resources: requests: storage: 1GiQ849: How do you configure storage quota?
Section titled “Q849: How do you configure storage quota?”Answer:
# Kubernetes ResourceQuotaapiVersion: v1kind: ResourceQuotametadata: name: storage-quotaspec: hard: requests.storage: 100Gi persistentvolumeclaims: "10"Q850: How do you implement data replication?
Section titled “Q850: How do you implement data replication?”Answer:
# Use GlusterFSgluster volume create replica 2 \ node1:/brick1/brick \ node2:/brick1/brick
# Use Cephceph osd pool create mypool 100 100ceph osd pool set mypool size 3
# Use Rook# Configure in CephCluster CRDspec: storage: useAllNodes: true useAllDevices: true deviceFilter: sd*Linux Advanced Networking
Section titled “Linux Advanced Networking”Q851: How do you configure Cilium?
Section titled “Q851: How do you configure Cilium?”Answer:
# Install Cilium CLIcurl -sL https://raw.githubusercontent.com/cilium/cilium-cli/main/install.sh | bash
# Installcilium install
# Enable Hubblecilium hubble enable
# Check statuscilium statuscilium hubble uiQ852: How do you use Calico eBPF?
Section titled “Q852: How do you use Calico eBPF?”Answer:
# Install Calicokubectl apply -f https://docs.projectcalico.org/manifests/calico.yaml
# Enable eBPF modecalicoctl patch felixdefault -p '{"spec":{"bpfLogLevel":"info","bpfEnabled":true}}'
# Checkcalicoctl node statusQ853: How do you configure network metrics?
Section titled “Q853: How do you configure network metrics?”Answer:
# Use Prometheus with Ciliumcilium metrics enable
# Or use Weave Scopekubectl apply -f https://cloud.weave.works/launch/k8s/weavescope.yaml
# Or use kube-state-metricskubectl apply -f https://github.com/kubernetes/kube-state-metrics/archive/master/examples/standard/deployment.yamlQ854: How do you implement service mesh?
Section titled “Q854: How do you implement service mesh?”Answer:
# Install Istioistioctl install --set profile=demo
# Enable sidecar injectionkubectl label namespace default istio-injection=enabled
# Deploykubectl apply -f deployment.yaml
# View trafficistioctl dashboard kialiQ855: How do you use Envoy?
Section titled “Q855: How do you use Envoy?”Answer:
static_resources: listeners: - name: listener_0 address: socket_address: address: 0.0.0.0 port_value: 8080 filter_chains: - filters: - name: envoy.filters.network.http_connection_manager typed_config: "@type": type.googleapis.com/envoy.extensions.filters.network.http_connection_manager.v3.HttpConnectionManager stat_prefix: ingress_http route_config: name: local_route virtual_hosts: - name: local_service domains: ["*"] routes: - match: prefix: "/" route: cluster: my_service clusters: - name: my_service type: STATIC lb_policy: ROUND_ROBIN hosts: - socket_address: address: 127.0.0.1 port_value: 80Q856: How do you configure DNS for K8s?
Section titled “Q856: How do you configure DNS for K8s?”Answer:
# CoreDNS configapiVersion: v1kind: ConfigMapmetadata: name: coredns namespace: kube-systemdata: Corefile: | .:53 { errors health kubernetes cluster.local in-addr.arpa ip6.arpa { pods insecure fallthrough in-addr.arpa ip6.arpa } forward . /etc/resolv.conf prometheus :9153 cache 30 }Q857: How do you implement ingress controller?
Section titled “Q857: How do you implement ingress controller?”Answer:
# Install NGINX Ingresskubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/controller-v1.5.1/deploy/static/provider/cloud/deploy.yaml
# Create IngressapiVersion: networking.k8s.io/v1kind: Ingressmetadata: name: myapp annotations: nginx.ingress.kubernetes.io/rewrite-target: /spec: rules: - host: myapp.example.com http: paths: - path: / pathType: Prefix backend: service: name: myapp port: number: 80Q858: How do you configure load balancer?
Section titled “Q858: How do you configure load balancer?”Answer:
# MetalLBapiVersion: v1kind: ConfigMapmetadata: namespace: metallb-system name: configdata: config: | address-pools: - name: default protocol: layer2 addresses: - 192.168.1.240-192.168.1.250
# ServiceapiVersion: v1kind: Servicemetadata: name: myappspec: type: LoadBalancer selector: app: myapp ports: - port: 80 targetPort: 80Q859: How do you use service discovery?
Section titled “Q859: How do you use service discovery?”Answer:
# CoreDNS# Use Kubernetes DNS# myservice.mynamespace.svc.cluster.local
# External DNSkubectl apply -f https://github.com/kubernetes-sigs/external-dns/master/releases/download/v0.12.0/provider.yaml
# ConfigureapiVersion: v1kind: ConfigMapmetadata: name: external-dnsdata: config.yaml: | provider: cloudflare source: service policy: syncQ860: How do you implement mTLS?
Section titled “Q860: How do you implement mTLS?”Answer:
# Istio mTLSapiVersion: security.istio.io/v1beta1kind: PeerAuthenticationmetadata: name: default namespace: istio-systemspec: mtls: mode: STRICT
# Or use Linkerd# Linkerd automatically mTLSlinkerd jaeger | kubectl apply -f -Linux Final Topics
Section titled “Linux Final Topics”Q861: How do you set up monitoring stack?
Section titled “Q861: How do you set up monitoring stack?”Answer:
# Use Prometheus + Grafana + Alertmanager# Install via Helmhelm repo add prometheus-community https://prometheus-community.github.io/helm-chartshelm install prometheus prometheus-community/kube-prometheus-stack
# Accesskubectl port-forward svc/prometheus-grafana 3000Q862: How do you configure alerting?
Section titled “Q862: How do you configure alerting?”Answer:
# Prometheus AlertapiVersion: monitoring.coreos.com/v1kind: PrometheusRulemetadata: name: myapp-alertsspec: groups: - name: myapp rules: - alert: HighMemory expr: (container_memory_working_set_bytes / container_spec_memory_limit_bytes) > 0.8 for: 5m labels: severity: warning annotations: summary: "High memory usage"Q863: How do you implement disaster recovery?
Section titled “Q863: How do you implement disaster recovery?”Answer:
# Backup etcdETCDCTL_API=3 etcdctl snapshot save /backup/etcd.db \ --endpoints=https://127.0.0.1:2379 \ --cacert=/etc/kubernetes/pki/etcd/ca.crt \ --cert=/etc/kubernetes/pki/etcd/server.crt \ --key=/etc/kubernetes/pki/etcd/server.key
# RestoreETCDCTL_API=3 etcdctl snapshot restore /backup/etcd.dbQ864: How do you set up GitOps?
Section titled “Q864: How do you set up GitOps?”Answer:
# Install ArgoCDkubectl create namespace argocdkubectl apply -n argocd -f https://raw.githubusercontent.com/argoproj/argo-cd/stable/manifests/install.yaml
# Create applicationapiVersion: argoproj.io/v1alpha1kind: Applicationmetadata: name: myapp namespace: argocdspec: project: default source: repoURL: https://github.com/myorg/myapp targetRevision: HEAD path: deploy destination: server: https://kubernetes.default.svc namespace: default syncPolicy: automated: prune: true selfHeal: trueQ865: How do you implement chaos engineering?
Section titled “Q865: How do you implement chaos engineering?”Answer:
# Install Litmuskubectl apply -f https://litmuschaos.github.io/litmus/2.0.0/litmus-2.0.0.yaml
# Create ChaosEngineapiVersion: litmuschaos.io/v1alpha1kind: ChaosEnginemetadata: name: pod-killspec: appinfo: appns: default applabel: "app=myapp" chaosServiceAccount: litmus-admin experiments: - name: pod-killQ866: How do you set up supply chain security?
Section titled “Q866: How do you set up supply chain security?”Answer:
# Use Sigstore Cosigncosign generate-key-pair
# Sign imagescosign sign --key cosign.key myregistry.com/myimage:v1.0
# Verifycosign verify --key cosign.pub myregistry.com/myimage:v1.0
# Use in CI/CD- name: Verify run: | cosign verify --key cosign.pub $IMAGEQ867: How do you implement observability?
Section titled “Q867: How do you implement observability?”Answer:
# Use OpenTelemetry# Install collectorkubectl apply -f https://github.com/open-telemetry/opentelemetry-collector-releases/releases/download/v0.50.0/otelcol.yaml
# Instrument application# Add OpenTelemetry SDK to application
# Use Jaeger for tracingkubectl apply -f https://github.com/jaegertracing/jaeger-operator/releases/latest/download/jaeger.yamlQ868: How do you configure cost optimization?
Section titled “Q868: How do you configure cost optimization?”Answer:
# Use Kubecostkubectl apply -f https://github.com/kubecost/cost-analyzer-helm-chart/releases/latest/download/kubecost.yaml
# Check costs# Access dashboard
# Use spot instances# Configure node pools with spot/preemptible instances
# Right-size resources# Use VPA (Vertical Pod Autoscaler)Q869: How do you implement compliance as code?
Section titled “Q869: How do you implement compliance as code?”Answer:
# Use OPA/Conftest# policy.regopackage main
deny[msg] { input.kind == "Deployment" not input.spec.template.spec.securityContext msg = "Deployment must have securityContext"}
# Testconftest test deployment.yamlQ870: How do you set up policy enforcement?
Section titled “Q870: How do you set up policy enforcement?”Answer:
# Use OPA Gatekeeperkubectl apply -f https://raw.githubusercontent.com/open-policy-agent/gatekeeper-library/master/library/pod-security-policy/privileged-containers/template.yaml
# Create constraintapiVersion: constraints.gatekeeper.sh/v1beta1kind: K8sPrivilegedContainermetadata: name: psp-privileged-containerspec: match: kinds: - apiGroups: [""] kinds: ["Pod"]Linux Final Questions
Section titled “Linux Final Questions”Q871: How do you use kubectl efficiently?
Section titled “Q871: How do you use kubectl efficiently?”Answer:
# Aliasesalias k=kubectlalias kgp='kubectl get pods'alias kga='kubectl get all'alias kdp='kubectl describe pod'alias klf='kubectl logs -f'
# Contextskubectl config get-contextskubectl config use-context production
# Quick accesskubectl run nginx --image=nginx --restart=Never --dry-run=client -o yaml > nginx.yamlQ872: How do you use Helm efficiently?
Section titled “Q872: How do you use Helm efficiently?”Answer:
# Common commandshelm install myrelease stable/nginxhelm upgrade myrelease stable/nginxhelm rollback myrelease 1
# Templatehelm template myrelease stable/nginx
# Repo managementhelm repo add stable https://charts.helm.sh/stablehelm repo updatehelm search repo nginxQ873: How do you debug Kubernetes issues?
Section titled “Q873: How do you debug Kubernetes issues?”Answer:
# Check eventskubectl get events --sort-by='.lastTimestamp'
# Check logskubectl logs -f deployment/myappkubectl logs -f deployment/myapp --previous
# Describekubectl describe pod myapp-pod
# Exec into containerkubectl exec -it myapp-pod -- /bin/bashQ874: How do you secure containers in production?
Section titled “Q874: How do you secure containers in production?”Answer:
# Use read-only root filesystemsecurityContext: readOnlyRootFilesystem: true
# Drop capabilitiessecurityContext: capabilities: drop: - ALL
# Run as non-rootsecurityContext: runAsNonRoot: true runAsUser: 10000
# Use image scanningtrivy image nginx:latestQ875: How do you optimize Kubernetes costs?
Section titled “Q875: How do you optimize Kubernetes costs?”Answer:
# Use Resource Limitsresources: limits: cpu: "500m" memory: "512Mi" requests: cpu: "200m" memory: "256Mi"
# Use VPA# Vertical Pod Autoscaler
# Use HPA# Horizontal Pod Autoscaler
# Use cluster autoscaler# Enable in cloud providerQ876: How do you handle state in Kubernetes?
Section titled “Q876: How do you handle state in Kubernetes?”Answer:
# Use StatefulSetsapiVersion: apps/v1kind: StatefulSetmetadata: name: myappspec: serviceName: myapp replicas: 3 selector: matchLabels: app: myapp template: spec: containers: - name: myapp image: myapp:latest volumeClaimTemplates: - metadata: name: data spec: accessModes: ["ReadWriteOnce"] resources: requests: storage: 10GiQ877: How do you implement canary deployments?
Section titled “Q877: How do you implement canary deployments?”Answer:
# Using IstioapiVersion: networking.istio.io/v1beta1kind: VirtualServicemetadata: name: myappspec: hosts: - myapp http: - route: - destination: host: myapp subset: v1 weight: 90 - destination: host: myapp subset: v2 weight: 10Q878: How do you implement blue-green deployments?
Section titled “Q878: How do you implement blue-green deployments?”Answer:
# Create blue deploymentkubectl apply -f blue-deployment.yaml
# Switch servicekubectl patch service myapp -p '{"spec":{"selector":{"version":"blue"}}}'
# Or use Ingress# Update ingress to point to new versionQ879: How do you implement rolling updates?
Section titled “Q879: How do you implement rolling updates?”Answer:
# Update deploymentkubectl set image deployment/myapp myapp=myapp:v2
# Check rollout statuskubectl rollout status deployment/myapp
# Pause rolloutkubectl rollout pause deployment/myapp
# Resumekubectl rollout resume deployment/myapp
# Rollbackkubectl rollout undo deployment/myappQ880: How do you implement health checks?
Section titled “Q880: How do you implement health checks?”Answer:
# Liveness probelivenessProbe: httpGet: path: /healthz port: 8080 initialDelaySeconds: 30 periodSeconds: 10 failureThreshold: 3
# Readiness probereadinessProbe: httpGet: path: /ready port: 8080 initialDelaySeconds: 5 periodSeconds: 5 failureThreshold: 3
# Startup probestartupProbe: httpGet: path: /healthz port: 8080 failureThreshold: 30 periodSeconds: 10Q881: How do you use Kustomize?
Section titled “Q881: How do you use Kustomize?”Answer:
# Base kustomization# kustomization.yamlapiVersion: kustomize.config.k8s.io/v1beta1kind: Kustomizationresources:- deployment.yaml- service.yaml
# Overlay# production/kustomization.yamlapiVersion: kustomize.config.k8s.io/v1beta1kind: Kustomizationbases:- ../basepatches:- patch.yaml
# Applykubectl apply -k production/Q882: How do you use Skaffold?
Section titled “Q882: How do you use Skaffold?”Answer:
apiVersion: skaffold/v2beta26kind: Configbuild: artifacts: - image: myappdeploy: kubectl: manifests: - k8s/*.yamlportForward:- resourceType: deployment resourceName: myapp port: 8080 localPort: 8080Q883: How do you use Tilt?
Section titled “Q883: How do you use Tilt?”Answer:
# Tiltfiledocker_build('myapp', '.')k8s_yaml('k8s/deployment.yaml')k8s_resource('myapp', port_forwards=8080)Q884: How do you implement GitOps workflows?
Section titled “Q884: How do you implement GitOps workflows?”Answer:
# 1. Store Kubernetes manifests in Gitgit add k8s/git commit -m "Update deployment"git push
# 2. Use GitOps tool (ArgoCD/Flux)# 3. Tool syncs Git -> Cluster# 4. Automatic drift detection
# Best practices# - Use separate repo for GitOps# - Branch by environment# - Require PRs for changesQ885: How do you manage secrets in Git?
Section titled “Q885: How do you manage secrets in Git?”Answer:
# Use SOPS# Installgo install github.com/mozilla/sops@latest
# Encryptsops -e secrets.yaml > secrets.encrypted.yaml
# Decryptsops -d secrets.encrypted.yaml
# Or use SealedSecrets# Or use external-secrets-operatorQ886: How do you implement backup for K8s?
Section titled “Q886: How do you implement backup for K8s?”Answer:
# Use Velero# Installkubectl apply -f https://raw.githubusercontent.com/vmware-tanzu/velero/main/install/v1.10.0/velero.yaml
# Backupvelero backup create mybackup --include-namespaces default
# Restorevelero restore create --from-backup mybackup
# Schedulevelero schedule create daily --schedule="0 0 * * *" --include-namespaces defaultQ887: How do you use service catalog?
Section titled “Q887: How do you use service catalog?”Answer:
# Install Service Catalogkubectl apply -f https://raw.githubusercontent.com/kubernetes-sigs/service-catalog/master/charts/service-catalog/templates/service-catalog-apiserver.yaml
# Provision service# Use ServiceBindingapiVersion: servicecatalog.k8s.io/v1beta1kind: ServiceBindingmetadata: name: myapp-bindingspec: serviceInstanceRef: name: my-service secretName: myapp-secretQ888: How do you implement multi-cluster?
Section titled “Q888: How do you implement multi-cluster?”Answer:
# Use Federation# Or use ArgoCD with multiple clusters
# Add cluster to ArgoCDargocd cluster add context-name
# Deploy to all clustersapiVersion: argoproj.io/v1alpha1kind: Applicationmetadata: name: myappspec: destination: server: https://kubernetes.default.svc # Or use ClusterResourceQuotaQ889: How do you handle upgrades?
Section titled “Q889: How do you handle upgrades?”Answer:
# Kubernetes upgrade# 1. Upgrade control planekubeadm upgrade plankubeadm upgrade apply v1.26.0
# 2. Upgrade kubeletapt-get install kubelet=1.26.0-*
# 3. Upgrade worker nodeskubectl drain node-1apt-get install kubelet=1.26.0-*kubectl uncordon node-1Q890: How do you implement security scanning?
Section titled “Q890: How do you implement security scanning?”Answer:
# Container scanningtrivy image nginx:latestdocker scout cves myimage
# K8s security scankubescape scan --severity threshold
# Runtime securityfalco --helpQ891: How do you configure audit logging in K8s?
Section titled “Q891: How do you configure audit logging in K8s?”Answer:
# Enable auditapiVersion: audit.k8s.io/v1kind: Policyrules:- level: RequestResponse resources: - group: "" resources: ["pods"] - level: Metadata resources: - group: "" resources: ["pods/log", "pods/status"]
# Configure API server# --audit-policy-file=/etc/kubernetes/audit-policy.yaml# --audit-log-path=/var/log/kubernetes/auditQ892: How do you implement pod security?
Section titled “Q892: How do you implement pod security?”Answer:
# Pod Security Standards# RestrictedapiVersion: v1kind: Podmetadata: name: restricted-podspec: securityContext: seccompProfile: type: RuntimeDefault containers: - name: app securityContext: allowPrivilegeEscalation: false readOnlyRootFilesystem: true capabilities: drop: - ALLQ893: How do you use NetworkPolicies?
Section titled “Q893: How do you use NetworkPolicies?”Answer:
# Allow specific trafficapiVersion: networking.k8s.io/v1kind: NetworkPolicymetadata: name: api-allowspec: podSelector: matchLabels: app: api ingress: - from: - podSelector: matchLabels: app: web ports: - protocol: TCP port: 8080Q894: How do you implement rate limiting?
Section titled “Q894: How do you implement rate limiting?”Answer:
# NGINX Ingress rate limitingapiVersion: networking.k8s.io/v1kind: Ingressmetadata: name: myapp annotations: nginx.ingress.kubernetes.io/limit-rps: "100" nginx.ingress.kubernetes.io/limit-connections: "50"spec: rules: - host: myapp.example.com http: paths: - path: / pathType: Prefix backend: service: name: myapp port: number: 80Q895: How do you use resource quotas?
Section titled “Q895: How do you use resource quotas?”Answer:
apiVersion: v1kind: ResourceQuotametadata: name: myquotaspec: hard: requests.cpu: "10" requests.memory: 20Gi limits.cpu: "20" limits.memory: 40Gi pods: "20" services: "10" persistentvolumeclaims: "5"Q896: How do you configure limit ranges?
Section titled “Q896: How do you configure limit ranges?”Answer:
apiVersion: v1kind: LimitRangemetadata: name: mylimitsspec: limits: - max: cpu: "4" memory: 8Gi min: cpu: 100m memory: 128Mi default: cpu: 500m memory: 1Gi defaultRequest: cpu: 200m memory: 512Mi type: ContainerQ897: How do you use pod disruption budgets?
Section titled “Q897: How do you use pod disruption budgets?”Answer:
apiVersion: policy/v1kind: PodDisruptionBudgetmetadata: name: myapp-pdbspec: minAvailable: 2 selector: matchLabels: app: myappQ898: How do you implement priority classes?
Section titled “Q898: How do you implement priority classes?”Answer:
apiVersion: scheduling.k8s.io/v1kind: PriorityClassmetadata: name: high-priorityvalue: 1000000globalDefault: falsedescription: "Critical workloads"
# Use in podpriorityClassName: high-priorityQ899: How do you handle pod failures?
Section titled “Q899: How do you handle pod failures?”Answer:
# Restart policy# Always, OnFailure, Never
# Liveness probelivenessProbe: httpGet: path: /healthz port: 8080 failureThreshold: 3 periodSeconds: 10
# Resourcesresources: requests: memory: "256Mi" cpu: "200m" limits: memory: "512Mi" cpu: "500m"Q900: How do you implement graceful shutdown?
Section titled “Q900: How do you implement graceful shutdown?”Answer:
# PreStop hooklifecycle: preStop: exec: command: - /bin/sh - -c - "sleep 10 && kill -SIGTERM 1"
# SIGTERM handling# In application, handle SIGTERM# Save state, close connections, graceful shutdownFinal Advanced Questions
Section titled “Final Advanced Questions”Q901: How do you secure etcd?
Section titled “Q901: How do you secure etcd?”Answer:
# Use TLS for etcd# Enable encryption at rest# Use separate etcd cluster# Enable authentication# Backup regularlyQ902: How do you configure API server security?
Section titled “Q902: How do you configure API server security?”Answer:
# Use RBAC# Enable admission controllers# Use TLS for all traffic# Limit network access# Use API aggregation
# Secure flags--authorization-mode=RBAC--enable-admission-plugins=NodeRestriction--encrypt-provider-config=encryption-config.yamlQ903: How do you implement pod security policies?
Section titled “Q903: How do you implement pod security policies?”Answer:
apiVersion: policy/v1beta1kind: PodSecurityPolicymetadata: name: restrictedspec: privileged: false seLinux: rule: RunAsAny runAsUser: rule: MustRunAsNonRoot fsGroup: rule: RunAsAny volumes: - 'secret' - 'configMap' hostNetwork: false hostPID: false hostIPC: falseQ904: How do you secure kubelet?
Section titled “Q904: How do you secure kubelet?”Answer:
# Configure kubeletauthentication: anonymous: enabled: false webhook: enabled: trueauthorization: mode: Webhook
# Use Node Authorizer# Enable NodeRestriction admission pluginQ905: How do you implement network segmentation in K8s?
Section titled “Q905: How do you implement network segmentation in K8s?”Answer:
# Network policies# Deny all by defaultapiVersion: networking.k8s.io/v1kind: NetworkPolicymetadata: name: default-denyspec: podSelector: {} policyTypes: - Ingress - EgressQ906: How do you secure container registry?
Section titled “Q906: How do you secure container registry?”Answer:
# Use TLS# Enable authentication# Use scanning tools# Implement access control# Use signed images# Regular rotation of credentials
# Use Harbor with vulnerability scanning# Use Notary for content trustQ907: How do you implement runtime security?
Section titled “Q907: How do you implement runtime security?”Answer:
# Use Falcokubectl apply -f https://raw.githubusercontent.com/falcosecurity/falco/master/integrations/k8s-using-daemonset/falco-daemonset-configmap.yaml
# Rules# Detect suspicious activities# File access, process execution, network callsQ908: How do you secure service accounts?
Section titled “Q908: How do you secure service accounts?”Answer:
# Use dedicated service accounts# Limit permissions# Disable auto-mount of tokens# Use RBAC
# Best practices# Create SA per application# Don't use default SA# Rotate tokens regularlyQ909: How do you implement secrets encryption?
Section titled “Q909: How do you implement secrets encryption?”Answer:
apiVersion: v1kind: Secretmetadata: name: aes-keydata: <base64-key>
# Configure API server# --encryption-provider-config=encryption-config.yaml
# Verify# Check etcd directlyetcdctl get /registry/secrets/default/secret-nameQ910: How do you secure etcd communication?
Section titled “Q910: How do you secure etcd communication?”Answer:
# Use TLS# etcd-ca.pem# etcd-server.pem# etcd-client.pem
# Configure API server# --etcd-cafile=/etc/kubernetes/pki/etcd/ca.crt# --etcd-certfile=/etc/kubernetes/pki/etcd/server.crt# --etcd-keyfile=/etc/kubernetes/pki/etcd/server.keyQ911: How do you implement cluster disaster recovery?
Section titled “Q911: How do you implement cluster disaster recovery?”Answer:
# 1. Regular etcd backupsETCDCTL_API=3 etcdctl snapshot save /backup/etcd.db
# 2. Regular cluster state backup# Backup all CRDs, Deployments, etc.
# 3. Document recovery procedures# 4. Test recovery regularly
# 5. Use cluster federation for multi-clusterQ912: How do you secure Kubernetes dashboard?
Section titled “Q912: How do you secure Kubernetes dashboard?”Answer:
# Don't expose publicly# Use RBAC# Enable HTTPS# Use token authentication# Enable audit logging# Restrict IP access
# Best practice# Use kubectl proxy or VPNQ913: How do you implement supply chain security?
Section titled “Q913: How do you implement supply chain security?”Answer:
# Use SBOM (Software Bill of Materials)# Sign images with Cosign# Use in-toto attestations# Implement SLSA compliance
# Tools# Syft (generate SBOM)# Cosign (sign images)# Grafeas (store attestations)Q914: How do you secure the control plane?
Section titled “Q914: How do you secure the control plane?”Answer:
# Use separate networks# Enable RBAC# Use TLS everywhere# Encrypt etcd# Limit etcd access# Use admission controllers# Enable audit logging
# Network policies# Isolate control plane from workloadsQ915: How do you implement defense in depth?
Section titled “Q915: How do you implement defense in depth?”Answer:
# Layer 1: Network# Firewalls, WAF, network policies
# Layer 2: Node# Hardened OS, SELinux/AppArmor
# Layer 3: Container# Read-only rootfs, non-root user, capabilities
# Layer 4: Application# Security scanning, secure coding
# Layer 5: Data# Encryption, access controlQ916: How do you handle vulnerabilities?
Section titled “Q916: How do you handle vulnerabilities?”Answer:
# Regular scanning# Use Trivy, Snyk, Clair
# Patch quickly# Automate updates
# Use base image scanning# Scan dependencies
# Quarantine vulnerable images# Use image policiesQ917: How do you implement compliance?
Section titled “Q917: How do you implement compliance?”Answer:
# Use OpenSCAPoscap xccdf eval --profile xccdf_org.ssgproject.content_profile_cis /usr/share/xml/scap/ssg/content/ssg-ubuntu2004-ds.xml
# Use Kyverno# Policy-as-code
# Document compliance# Regular audits# Automated checks in CI/CDQ918: How do you secure CI/CD?
Section titled “Q918: How do you secure CI/CD?”Answer:
# Secrets management# Use Vault, AWS Secrets Manager
# Access control# Principle of least privilege
# Image scanning# Block vulnerable images
# Signed commits# Require code review
# Supply chain security# Use SLSAQ919: How do you implement incident response?
Section titled “Q919: How do you implement incident response?”Answer:
# 1. Detection# Monitoring, alerting
# 2. Containment# Isolate affected systems
# 3. Investigation# Logs, forensics
# 4. Recovery# Restore from backup
# 5. Lessons learned# Post-mortem
# Runbooks# Practice regularlyQ920: How do you secure Kubernetes networking?
Section titled “Q920: How do you secure Kubernetes networking?”Answer:
# Use NetworkPolicies# Default deny# Allow explicit# Use service mesh
# ExamplesapiVersion: networking.k8s.io/v1kind: NetworkPolicymetadata: name: web-to-apispec: podSelector: matchLabels: app: api ingress: - from: - podSelector: matchLabels: app: webQ921: How do you use Kubernetes auditing?
Section titled “Q921: How do you use Kubernetes auditing?”Answer:
# Enable audit# Configure audit policy# --audit-policy-file=/path/to/policy.yaml
# Review logs# Store in secure location# Use SIEM integration# Regular reviewQ922: How do you implement secrets rotation?
Section titled “Q922: How do you implement secrets rotation?”Answer:
# Use external-secrets-operator# Rotate regularly# Use key management services
# Kubernetes# Automatic token rotation# Use short-lived tokens
# Best practice# Rotate every 90 days# Automate the processQ923: How do you secure container orchestration?
Section titled “Q923: How do you secure container orchestration?”Answer:
# Use RBAC# Network policies# Pod security policies# Secrets management# Image scanning# Runtime security# Regular updates
# Tools# Kube-bench# Kubescape# KyvernoQ924: How do you handle compliance frameworks?
Section titled “Q924: How do you handle compliance frameworks?”Answer:
# PCI-DSS# Use specific profiles# HIPAA# GDPR# SOC 2# ISO 27001
# Use OpenSCAP# Use policy engines# Automate compliance checksQ925: How do you implement zero trust in K8s?
Section titled “Q925: How do you implement zero trust in K8s?”Answer:
# mTLS everywhere# Service mesh
# Short-lived certificates# Regular rotation
# Network policies# Microsegmentation
# Verify every request# Use identity-based access# Continuous verificationQ926: How do you secure cluster upgrades?
Section titled “Q926: How do you secure cluster upgrades?”Answer:
# Test in staging# Use canary# Backup first# Document rollback plan# Monitor during upgrade# Quick rollback if issues
# Best practice# Upgrade regularly (quarterly)# Test applicationsQ927: How do you secure cloud-native apps?
Section titled “Q927: How do you secure cloud-native apps?”Answer:
# Security scanning in CI/CD# Use signed images# Secrets management# Secure coding practices# Regular patching# Runtime protection
# Tools# SAST/DAST# Container scanning# Dependency scanningQ928: How do you implement secure defaults?
Section titled “Q928: How do you implement secure defaults?”Answer:
# Pod securitysecurityContext: runAsNonRoot: true runAsUser: 10000 readOnlyRootFilesystem: true capabilities: drop: - ALL
# Network# Default deny# Explicit allow
# RBAC# Least privilege# No default permissionsQ929: How do you secure data in transit?
Section titled “Q929: How do you secure data in transit?”Answer:
# Use TLS 1.3# mTLS in service mesh# Certificate management# Use strong ciphers
# In Kubernetes# Use Istio/Linkerd# Configure Ingress TLS# Service mesh mTLSQ930: How do you secure data at rest?
Section titled “Q930: How do you secure data at rest?”Answer:
# Use encryption# LUKS for volumes# Database encryption# Use key management
# Kubernetes# Use CSI drivers with encryption# Enable encryption at rest# Rotate keys regularlyQ931: How do you implement access control?
Section titled “Q931: How do you implement access control?”Answer:
# RBAC# Create roles# Bind to users/groups# Use ServiceAccounts
# Best practices# Least privilege# Regular review# Audit access
# Use external identity# LDAP, SAML, OIDCQ932: How do you secure Kubernetes API?
Section titled “Q932: How do you secure Kubernetes API?”Answer:
# Use RBAC# Limit access# Use TLS# Enable audit logging# Use admission controllers
# Don't expose publicly# Use VPN/bastion
# Use API aggregation# Rate limitingQ933: How do you secure worker nodes?
Section titled “Q933: How do you secure worker nodes?”Answer:
# Use minimal OS# Apply security patches# Use CIS benchmarks# Enable firewall# Restrict access
# Node hardening# Disable unnecessary services# Use SELinux/AppArmor# Regular updatesQ934: How do you implement secure bootstrapping?
Section titled “Q934: How do you implement secure bootstrapping?”Answer:
# Use TPM# Secure boot# Measure boot# Use remote attestation
# Kubernetes# Use encrypted secrets# Use sealed secrets# Use HSM for keysQ935: How do you secure supply chain?
Section titled “Q935: How do you secure supply chain?”Answer:
# Use SBOM# Sign artifacts# Verify signatures# Use trusted registries# Regular scanning
# Implement SLSA# Build integrity# Provenance
# Tools# Cosign# Grafeas# in-totoQ936: How do you handle security incidents?
Section titled “Q936: How do you handle security incidents?”Answer:
# Detection# Alerts, monitoring
# Containment# Isolate affected pods# Block malicious traffic
# Investigation# Logs, traces
# Recovery# Restore from backup# Patch vulnerabilities
# Post-incident# Lessons learned# Update runbooksQ937: How do you secure multi-tenancy?
Section titled “Q937: How do you secure multi-tenancy?”Answer:
# Use namespaces# Resource quotas# Network policies# Node isolation# Pod security policies
# RBAC per tenant# Quotas per team# Separate etcd# Encrypted namespacesQ938: How do you secure secrets at scale?
Section titled “Q938: How do you secure secrets at scale?”Answer:
# Use Vault# Use external-secrets-operator# Use SealedSecrets# Use AWS Secrets Manager
# Best practices# Rotate regularly# Audit access# Use encryption# Short-lived tokensQ939: How do you implement defense?
Section titled “Q939: How do you implement defense?”Answer:
# Multiple layers# Network, host, container, app
# Monitoring# Real-time alerts
# Quick response# Automated blocking
# Regular testing# Pen testing# Red team
# Updates# Patch quicklyQ940: How do you secure container runtime?
Section titled “Q940: How do you secure container runtime?”Answer:
# Use rootless containers# Drop capabilities# Read-only rootfs# No privileged mode# Seccomp/AppArmor
# Runtime security# Falco, Sysdig
# Isolation# gVisor, Kata Containers# User namespacesQ941: How do you implement continuous security?
Section titled “Q941: How do you implement continuous security?”Answer:
# Security in CI/CD# Scan images# Scan dependencies# Policy enforcement
# Runtime# Monitor behavior# Detect threats
# Compliance# Regular audits# Automated checksQ942: How do you secure the supply chain?
Section titled “Q942: How do you secure the supply chain?”Answer:
# Use SBOM# Sign images# Verify signatures# Use trusted sources
# Implement SLSA# Level 1: Build provenance# Level 2: Hosted build# Level 3: Hardened build
# Tools# Cosign, Notary, in-totoQ943: How do you secure Kubernetes networking?
Section titled “Q943: How do you secure Kubernetes networking?”Answer:
# Default deny# Explicit allow# Use NetworkPolicies
# Service mesh# mTLS everywhere
# Encryption# TLS for ingress# VPN for internal
# Tools# Calico, Cilium, CanalQ944: How do you implement secure coding?
Section titled “Q944: How do you implement secure coding?”Answer:
# Input validation# Output encoding# Authentication# Authorization# Session management# Error handling# Logging
# Dependencies# Regular updates# Scan for CVEs# Use Snyk, DependabotQ945: How do you secure storage?
Section titled “Q945: How do you secure storage?”Answer:
# Encryption# LUKS, dm-crypt
# Access control# RBAC, ACLs
# Backups# Encrypted backups# Offsite storage
# Kubernetes# CSI encryption# Secrets encryption# Encrypted volumesQ946: How do you secure the data plane?
Section titled “Q946: How do you secure the data plane?”Answer:
# Use encryption# mTLS# Network policies# Service mesh
# Container isolation# gVisor, Kata# User namespaces
# Runtime security# Falco# SysdigQ947: How do you implement defense in depth?
Section titled “Q947: How do you implement defense in depth?”Answer:
# Multiple layers# Perimeter, network, host, app
# Zero trust# Never trust, always verify
# Least privilege# Minimal permissions
# Regular assessment# Penetration testing# Vulnerability scanningQ948: How do you secure the control plane?
Section titled “Q948: How do you secure the control plane?”Answer:
# Use RBAC# Limit access# Enable audit logging# Use TLS
# Network isolation# Use separate network# Don't expose publicly
# Updates# Patch quickly# Regular updatesQ949: How do you implement compliance automation?
Section titled “Q949: How do you implement compliance automation?”Answer:
# Use OPA Gatekeeper# Policy-as-code
# Use Kyverno# CRD-based policies
# Use Falco# Runtime policies
# Use OpenSCAP# Automated scanning
# Integrate in CI/CDQ950: How do you secure Kubernetes workloads?
Section titled “Q950: How do you secure Kubernetes workloads?”Answer:
# Pod security contextsecurityContext: runAsNonRoot: true runAsUser: 10000 fsGroup: 2000
# Container securitysecurityContext: allowPrivilegeEscalation: false readOnlyRootFilesystem: true capabilities: drop: - ALLFinal Questions 951-1000
Section titled “Final Questions 951-1000”Q951: How do you use Falco rules?
Section titled “Q951: How do you use Falco rules?”Answer:
- rule: Terminal shell in container desc: notice shell activity condition: container.id != host and proc.name = bash output: "Shell in container (user=%user.name container=%container.id image=%container.image.repository)" priority: WARNING tags: [container, shell]Q952: How do you configure OPA policies?
Section titled “Q952: How do you configure OPA policies?”Answer:
apiVersion: constraints.gatekeeper.sh/v1beta1kind: K8sRequiredLabelsmetadata: name: require-app-labelsspec: match: kinds: - apiGroups: [""] kinds: ["Pod"] parameters: labels: - key: appQ953: How do you use Kyverno policies?
Section titled “Q953: How do you use Kyverno policies?”Answer:
apiVersion: kyverno.io/v1kind: ClusterPolicymetadata: name: add-default-resourcesspec: rules: - name: add-default-resources match: resources: kinds: - Pod mutate: patchStrategicMerge: spec: containers: - resources: requests: memory: "256Mi" cpu: "250m"Q954: How do you implement immutable infrastructure?
Section titled “Q954: How do you implement immutable infrastructure?”Answer:
# Use containers# Don't modify running containers# Replace, don't patch
# Use GitOps# Declarative configs# Version control# Automated deploymentsQ955: How do you secure container builds?
Section titled “Q955: How do you secure container builds?”Answer:
# Use minimal base images# Multi-stage builds# No secrets in images# Scan for vulnerabilities# Sign images
# Best practices# Don't run as root# Use USER directive# Remove unnecessary toolsQ956: How do you implement secure CI/CD?
Section titled “Q956: How do you implement secure CI/CD?”Answer:
# Scan images# Use Trivy in pipeline
# Don't use latest tag# Use specific versions
# Separate CI/CD from production# Use dedicated service accounts
# Sign commits# Require code review
# Use secrets managementQ957: How do you secure Kubernetes secrets?
Section titled “Q957: How do you secure Kubernetes secrets?”Answer:
# Don't use base64 encoding alone# Use encryption at rest
# Use external secrets# HashiCorp Vault# AWS Secrets Manager
# Rotate regularly# Audit access
# Use SealedSecrets# Use SOPSQ958: How do you implement security scanning?
Section titled “Q958: How do you implement security scanning?”Answer:
# Container scanningtrivy image myimage:latest
# K8s scanningkubescape scan
# Code scanningsonarqube
# Dependency scanningnpm auditsnyk testQ959: How do you secure the container registry?
Section titled “Q959: How do you secure the container registry?”Answer:
# Use authentication# Use TLS# Scan images# Use signed images
# Access control# Role-based
# Regular cleanup# Remove old images
# Use private registry# Harbor, NexusQ960: How do you implement secure networking?
Section titled “Q960: How do you implement secure networking?”Answer:
# NetworkPolicyapiVersion: networking.k8s.io/v1kind: NetworkPolicymetadata: name: deny-allspec: podSelector: {} policyTypes: - Ingress - EgressQ961: How do you secure the API server?
Section titled “Q961: How do you secure the API server?”Answer:
# Use RBAC# Enable TLS# Use strong authentication
# Don't expose publicly# Use VPN
# Enable audit logging# Monitor access
# Use admission controllers# Limit what can be createdQ962: How do you implement defense?
Section titled “Q962: How do you implement defense?”Answer:
# Multiple layers# Network, host, container
# Monitoring# Real-time alerts
# Quick response# Automated blocking
# Regular assessment# Vulnerability scanning
# Updates# Patch quicklyQ963: How do you secure workloads?
Section titled “Q963: How do you secure workloads?”Answer:
# Pod Security Standards# Restricted profile
# Use security contextssecurityContext: runAsNonRoot: true readOnlyRootFilesystem: true
# Use NetworkPolicies# Default deny
# Use Secrets# External secretsQ964: How do you implement compliance?
Section titled “Q964: How do you implement compliance?”Answer:
# Use policy engines# OPA, Kyverno
# Use scanning tools# OpenSCAP, Kube-bench
# Use audit logging# Regular reviews
# Automate checks# In CI/CD pipelineQ965: How do you secure the cluster?
Section titled “Q965: How do you secure the cluster?”Answer:
# Use RBAC# Network policies
# Encrypt etcd# Enable audit logging
# Update regularly# Use CIS benchmarks
# Monitor# Use Falco
# Use secrets managementQ966: How do you implement zero trust?
Section titled “Q966: How do you implement zero trust?”Answer:
# Verify everything# Never trust, always verify
# mTLS everywhere# Short-lived certificates
# Network policies# Microsegmentation
# Identity-based# Not IP-based
# Continuous verificationQ967: How do you secure container runtime?
Section titled “Q967: How do you secure container runtime?”Answer:
# Use rootless# Drop capabilities# Read-only rootfs
# Seccomp/AppArmor# Profile
# Runtime security# Falco, Sysdig
# Isolation# gVisor, KataQ968: How do you implement supply chain security?
Section titled “Q968: How do you implement supply chain security?”Answer:
# Use SBOM# Sign images# Verify signatures
# SLSA compliance# Build integrity
# Trusted registries# Use scanning
# Tools# Cosign, Syft, GrafeasQ969: How do you secure data in transit?
Section titled “Q969: How do you secure data in transit?”Answer:
# Use TLS 1.3# mTLS in service mesh
# Certificate management# Use strong ciphers
# Kubernetes# Istio, Linkerd
# Ingress TLS# Service meshQ970: How do you secure data at rest?
Section titled “Q970: How do you secure data at rest?”Answer:
# Encryption# LUKS, dm-crypt
# Key management# Use KMS
# Kubernetes# CSI encryption# Enable at rest
# Rotate keys# Regular rotationQ971: How do you implement access control?
Section titled “Q971: How do you implement access control?”Answer:
# RBAC# Least privilege
# Service accounts# Dedicated per app
# Authentication# OIDC, LDAP
# Regular review# Audit access
# Use external identityQ972: How do you secure Kubernetes API?
Section titled “Q972: How do you secure Kubernetes API?”Answer:
# Use RBAC# Limit access
# Use TLS# Enable audit logging
# Admission controllers# NodeRestriction
# Don't expose publicly# Use VPN
# Rate limitingQ973: How do you secure worker nodes?
Section titled “Q973: How do you secure worker nodes?”Answer:
# Use minimal OS# Apply patches
# CIS benchmarks# Enable firewall
# Use SELinux# Restrict access
# Regular updates# Automated patchingQ974: How do you implement secure bootstrapping?
Section titled “Q974: How do you implement secure bootstrapping?”Answer:
# Use TPM# Secure boot
# Measure boot# Remote attestation
# Encrypted secrets# Sealed secrets
# Use HSM# Key managementQ975: How do you secure supply chain?
Section titled “Q975: How do you secure supply chain?”Answer:
# Use SBOM# Sign artifacts# Verify signatures# Use trusted registries
# Implement SLSA# Build integrity# Provenance
# Tools# Cosign, NotaryQ976: How do you handle security incidents?
Section titled “Q976: How do you handle security incidents?”Answer:
# Detection# Alerts, monitoring
# Containment# Isolate pods
# Investigation# Logs, forensics
# Recovery# Restore from backup
# Post-incident# Lessons learnedQ977: How do you secure multi-tenancy?
Section titled “Q977: How do you secure multi-tenancy?”Answer:
# Use namespaces# Resource quotas
# Network policies# Pod security
# RBAC per tenant# Quotas per team
# Separate etcd# Encrypted namespacesQ978: How do you implement secrets management?
Section titled “Q978: How do you implement secrets management?”Answer:
# Use Vault# External secrets
# Rotate regularly# Audit access
# Use encryption# Short-lived tokens
# Best practices# Use KMSQ979: How do you implement defense?
Section titled “Q979: How do you implement defense?”Answer:
# Multiple layers# Network, host, app
# Monitoring# Real-time alerts
# Quick response# Automated blocking
# Regular testing# Pen testing
# Updates# Patch quicklyQ980: How do you secure container runtime?
Section titled “Q980: How do you secure container runtime?”Answer:
# Rootless containers# Drop capabilities# Read-only rootfs# No privileged mode# Seccomp/AppArmor
# Runtime security# Falco, Sysdig
# Isolation# gVisor, KataQ981: How do you implement continuous security?
Section titled “Q981: How do you implement continuous security?”Answer:
# Security in CI/CD# Scan images
# Runtime# Monitor behavior
# Compliance# Regular audits
# Automation# Policy enforcement# Automated remediationQ982: How do you secure supply chain?
Section titled “Q982: How do you secure supply chain?”Answer:
# Use SBOM# Sign images# Verify signatures# Use trusted sources
# SLSA compliance# Level 1-3
# Tools# Cosign, Grafeas, in-totoQ983: How do you secure Kubernetes networking?
Section titled “Q983: How do you secure Kubernetes networking?”Answer:
# Default deny# Explicit allow# Use NetworkPolicies
# Service mesh# mTLS
# Encryption# TLS for ingress
# Tools# Calico, CiliumQ984: How do you implement secure coding?
Section titled “Q984: How do you implement secure coding?”Answer:
# Input validation# Output encoding# Authentication# Authorization# Error handling# Logging
# Dependencies# Regular updates# Scan for CVEsQ985: How do you secure storage?
Section titled “Q985: How do you secure storage?”Answer:
# Encryption# LUKS, dm-crypt
# Access control# RBAC, ACLs
# Backups# Encrypted backups
# Kubernetes# CSI encryption# Secrets encryptionQ986: How do you secure the data plane?
Section titled “Q986: How do you secure the data plane?”Answer:
# Use encryption# mTLS# Network policies# Service mesh
# Container isolation# gVisor, Kata# User namespaces
# Runtime security# FalcoQ987: How do you implement defense in depth?
Section titled “Q987: How do you implement defense in depth?”Answer:
# Multiple layers# Perimeter, network, host, app
# Zero trust# Never trust
# Least privilege# Minimal permissions
# Regular assessment# Pen testing
# Updates# Patch quicklyQ988: How do you secure the control plane?
Section titled “Q988: How do you secure the control plane?”Answer:
# Use RBAC# Limit access# Enable audit logging# Use TLS
# Network isolation# Separate network
# Updates# Patch quicklyQ989: How do you implement compliance automation?
Section titled “Q989: How do you implement compliance automation?”Answer:
# Use OPA Gatekeeper# Policy-as-code
# Use Kyverno# CRD-based
# Use Falco# Runtime policies
# Use OpenSCAP# Automated scanning
# Integrate in CI/CDQ990: How do you secure Kubernetes workloads?
Section titled “Q990: How do you secure Kubernetes workloads?”Answer:
# Pod security contextsecurityContext: runAsNonRoot: true runAsUser: 10000 fsGroup: 2000
# Container securitysecurityContext: allowPrivilegeEscalation: false readOnlyRootFilesystem: true capabilities: drop: - ALLQ991: How do you use Falco effectively?
Section titled “Q991: How do you use Falco effectively?”Answer:
# Detect container escapes- rule: Container escape attempt desc: Detect container escape attempts condition: (evt.type=unshare and evt.dir=< and proc.name != containerd-shim) priority: CRITICAL tags: [container, security]Q992: How do you implement network policies?
Section titled “Q992: How do you implement network policies?”Answer:
# Allow from specific namespaceapiVersion: networking.k8s.io/v1kind: NetworkPolicymetadata: name: allow-from-namespacespec: podSelector: {} ingress: - from: - namespaceSelector: matchLabels: name: productionQ993: How do you secure the registry?
Section titled “Q993: How do you secure the registry?”Answer:
# Use authentication# Use TLS# Scan images# Use signed images
# Access control# Role-based
# Regular cleanup
# Use private registry# Harbor, NexusQ994: How do you implement secure networking?
Section titled “Q994: How do you implement secure networking?”Answer:
# Default deny allapiVersion: networking.k8s.io/v1kind: NetworkPolicymetadata: name: default-deny-allspec: podSelector: {} policyTypes: - Ingress - EgressQ995: How do you secure the API server?
Section titled “Q995: How do you secure the API server?”Answer:
# Use RBAC# Enable TLS# Use strong auth
# Don't expose publicly# Use VPN
# Enable audit logging# Monitor access
# Use admission controllersQ996: How do you implement defense?
Section titled “Q996: How do you implement defense?”Answer:
# Multiple layers# Network, host, container
# Monitoring# Real-time alerts
# Quick response# Automated blocking
# Regular testing# Pen testing
# Updates# Patch quicklyQ997: How do you secure workloads?
Section titled “Q997: How do you secure workloads?”Answer:
# Pod Security Standards# Restricted profile
# Use security contextssecurityContext: runAsNonRoot: true readOnlyRootFilesystem: true
# Use NetworkPolicies
# Use Secrets# External secretsQ998: How do you implement compliance?
Section titled “Q998: How do you implement compliance?”Answer:
# Use policy engines# OPA, Kyverno
# Use scanning tools# OpenSCAP, Kube-bench
# Use audit logging# Regular reviews
# Automate checks# In CI/CD pipelineQ999: How do you secure the cluster?
Section titled “Q999: How do you secure the cluster?”Answer:
# Use RBAC# Network policies
# Encrypt etcd# Enable audit logging
# Update regularly# Use CIS benchmarks
# Monitor# Use Falco
# Use secrets managementQ1000: How do you implement zero trust?
Section titled “Q1000: How do you implement zero trust?”Answer:
# Verify everything# Never trust, always verify
# mTLS everywhere# Short-lived certificates
# Network policies# Microsegmentation
# Identity-based# Not IP-based
# Continuous verification
# This concludes the 1000 Linux practical interview questions!End of Linux Practical Interview Questions (1-1000)