CNCF Projects: Networking, Security, and Observability
This page covers the CNCF and three of its projects, Istio, Falco, and the Open Policy Agent (OPA), plus Gatekeeper. The practice run needs no cluster, root rights, or cloud account: istioctl and gator check local files, OPA runs locally, and Falco reads audit events from a file. It follows CNCF Projects: Runtime, Scheduling, and Data. For tools that collect metrics, logs, and traces, see Monitoring and Observability.
95 min read95 মিনিটে পড়া যায় · 7 sections7টি সেকশন · 47 sources47টি সোর্স · updated Nov 2026আপডেট: Nov 2026
From permissive to mTLS onlyপারমিসিভ থেকে শুধু mTLS-এ
Move a mesh from permissive to mTLS only and watch the plaintext caller get refused.একটা মেশকে পারমিসিভ থেকে শুধু mTLS-এ নিন আর দেখুন প্লেইনটেক্সট কলার প্রত্যাখ্যাত হয়।
You’ll learnআপনি শিখবেন
- What the sidecars and Istiod doসাইডকার আর Istiod কী করে
- How a mesh call uses mutual TLSমেশের কল কীভাবে mutual TLS চালায়
- Why permissive mode helps onboardingpermissive mode কেন ওঠার কাজ সহজ করে
- What mTLS only does to plaintextশুধু mTLS plaintext-এর সঙ্গে কী করে
- The order CUSTOM, DENY, ALLOWCUSTOM, DENY, ALLOW-এর ক্রম
What it is
The CNCF and its stages. The Cloud Native Computing Foundation (CNCF) hosts critical components of the global technology infrastructure Source 1সোর্স 1. CNCF is part of the nonprofit Linux Foundation Source 1সোর্স 1. Its Technical Oversight Committee (TOC) defines 4 stages of the project lifecycle Source 3সোর্স 3. The CNCF projects page says that graduated and incubating projects are considered stable and are used successfully in production environments Source 2সোর্স 2. The TOC describes Incubation projects as projects gaining adoption, focusing on improving stability and maturity Source 3সোর্স 3. It describes Graduated projects as highly mature, robust projects whose adopters have demonstrated their production-readiness by their deployment to production environments Source 3সোর্স 3.
The three projects. The CNCF page says that Istio was accepted on September 30, 2022 at the Incubating maturity level Source 4সোর্স 4. Istio moved to the Graduated maturity level on July 12, 2023 Source 4সোর্স 4. The CNCF Falco page says that Falco was accepted on October 10, 2018 Source 5সোর্স 5. Falco moved to the Incubating maturity level on January 8, 2020 Source 5সোর্স 5. Falco moved to the Graduated maturity level on February 29, 2024 Source 5সোর্স 5. The CNCF OPA page says that the Open Policy Agent (OPA) was accepted on March 29, 2018 Source 6সোর্স 6. OPA moved to the Incubating maturity level on April 2, 2019 Source 6সোর্স 6. OPA moved to the Graduated maturity level on January 29, 2021 Source 6সোর্স 6. The project pages describe Istio as a service mesh that simplifies observability, traffic management, security, and policy Source 4সোর্স 4. They describe Falco as the cloud-native runtime security project Source 5সোর্স 5, and OPA as an open source, general-purpose policy engine Source 6সোর্স 6.
Istio: a service mesh. The Istio docs define a service mesh as an infrastructure layer that gives applications capabilities like zero-trust security, observability, and advanced traffic management, without code changes Source 7সোর্স 7. Istio is an open source service mesh that layers transparently onto existing distributed applications Source 8সোর্স 8. It uses a proxy to intercept all your network traffic, which allows a broad set of application-aware features based on configuration you set Source 8সোর্স 8. The control plane takes your desired configuration, and its view of the services, and dynamically programs the proxy servers Source 8সোর্স 8. Istio gives you secure service-to-service communication in a cluster with mutual TLS encryption Source 8সোর্স 8. It gives you fine-grained control of traffic behavior with rich routing rules, retries, failovers, and fault injection Source 8সোর্স 8. It also gives you automatic metrics, logs, and traces for all traffic within a cluster Source 8সোর্স 8.
Istio: two data plane modes. Istio supports two data plane modes Source 8সোর্স 8. Sidecar mode deploys an Envoy proxy along with each pod that you start in your cluster, or running alongside services running on VMs Source 8সোর্স 8. Ambient mode uses a per-node Layer 4 proxy, and optionally a per-namespace Envoy proxy for Layer 7 features Source 8সোর্স 8. In ambient mode, the ztunnel secure overlay handles routing and zero trust security for traffic Source 10সোর্স 10. When needed, users can enable L7 waypoint proxies to get access to the full range of Istio features Source 10সোর্স 10. Pods and workloads using sidecar mode can co-exist within the same mesh as pods that use ambient mode Source 10সোর্স 10.
Falco: runtime security. Falco is a cloud native security tool that provides runtime security across hosts, containers, Kubernetes, and cloud environments Source 18সোর্স 18. At its core, Falco is a monitoring and detection agent that observes events and delivers real-time alerts based on custom rules Source 18সোর্স 18. Falco also enhances these events by integrating contextual metadata from container runtimes and Kubernetes Source 18সোর্স 18. Falco uses syscalls to monitor a system's activity Source 18সোর্স 18. Falco ships with a default set of rules that check the kernel for unusual behavior Source 18সোর্স 18. One example of the unusual behavior is privilege escalation using privileged containers Source 18সোর্স 18.
OPA: a policy engine. The OPA docs say that OPA is an open source, general-purpose policy engine that unifies policy enforcement across the stack Source 27সোর্স 27. OPA provides a high-level declarative language that lets you specify policy as code Source 27সোর্স 27. OPA decouples policy decision-making from policy enforcement Source 27সোর্স 27. When your software needs to make policy decisions, it queries OPA and supplies structured data as input Source 27সোর্স 27. OPA generates policy decisions by evaluating the query input against policies and data Source 27সোর্স 27. Policy decisions are not limited to simple yes/no or allow/deny answers Source 27সোর্স 27.
Gatekeeper: OPA for Kubernetes. In Kubernetes, admission controllers enforce policies on objects during create, update, and delete operations Source 34সোর্স 34. OPA Gatekeeper is a specialized project providing first-class integration between OPA and Kubernetes Source 34সোর্স 34. The OPA docs say that Gatekeeper is the recommended project for using OPA for Kubernetes admission control Source 34সোর্স 34. Gatekeeper adds native Kubernetes CRDs for extending the policy library, which are called constraint templates Source 34সোর্স 34. It adds native Kubernetes CRDs for instantiating the policy library, which are called constraints Source 34সোর্স 34. ConstraintTemplates define a way to validate some set of Kubernetes objects in Gatekeeper's Kubernetes admission controller Source 37সোর্স 37.
What the practice run covers. This paragraph describes the tutorial's own run. The run shows one privileged Pod from three sides. OPA and Gatekeeper report it as a policy violation in a local test, and Falco raises an alert for it from an audit event. Istio has no such Pod in the run. For Istio, the run checks files that describe traffic and security with istioctl analyze, and it renders the install manifests of five profiles with istioctl manifest generate.
সহজ English
The CNCF and its stages. The Cloud Native Computing Foundation (CNCF) hosts critical components of the global technology infrastructure Source 1সোর্স 1. CNCF is part of the nonprofit Linux Foundation Source 1সোর্স 1. Its Technical Oversight Committee (TOC) defines 4 stages of the project lifecycle Source 3সোর্স 3. The CNCF projects page says that graduated and incubating projects are considered stable and are used successfully in production environments Source 2সোর্স 2. The TOC describes Incubation projects as projects gaining adoption, focusing on improving stability and maturity Source 3সোর্স 3. It describes Graduated projects as highly mature, robust projects whose adopters have demonstrated their production-readiness by their deployment to production environments Source 3সোর্স 3.
The three projects. The CNCF page says that Istio was accepted on September 30, 2022 at the Incubating maturity level Source 4সোর্স 4. Istio moved to the Graduated maturity level on July 12, 2023 Source 4সোর্স 4. The CNCF Falco page says that Falco was accepted on October 10, 2018 Source 5সোর্স 5. Falco moved to the Incubating maturity level on January 8, 2020 Source 5সোর্স 5. Falco moved to the Graduated maturity level on February 29, 2024 Source 5সোর্স 5. The CNCF OPA page says that the Open Policy Agent (OPA) was accepted on March 29, 2018 Source 6সোর্স 6. OPA moved to the Incubating maturity level on April 2, 2019 Source 6সোর্স 6. OPA moved to the Graduated maturity level on January 29, 2021 Source 6সোর্স 6. The project pages describe Istio as a service mesh that simplifies observability, traffic management, security, and policy Source 4সোর্স 4. They describe Falco as the cloud-native runtime security project Source 5সোর্স 5, and OPA as an open source, general-purpose policy engine Source 6সোর্স 6.
Istio: a service mesh. The Istio docs define a service mesh as an infrastructure layer that gives applications capabilities like zero-trust security, observability, and advanced traffic management, without code changes Source 7সোর্স 7. Istio is an open source service mesh that layers transparently onto existing distributed applications Source 8সোর্স 8. It uses a proxy to intercept all your network traffic, which allows a broad set of application-aware features based on configuration you set Source 8সোর্স 8. The control plane takes your desired configuration, and its view of the services, and dynamically programs the proxy servers Source 8সোর্স 8. Istio gives you secure service-to-service communication in a cluster with mutual TLS encryption Source 8সোর্স 8. It gives you fine-grained control of traffic behavior with rich routing rules, retries, failovers, and fault injection Source 8সোর্স 8. It also gives you automatic metrics, logs, and traces for all traffic within a cluster Source 8সোর্স 8.
Istio: two data plane modes. Istio supports two data plane modes Source 8সোর্স 8. Sidecar mode deploys an Envoy proxy along with each pod that you start in your cluster, or running alongside services running on VMs Source 8সোর্স 8. Ambient mode uses a per-node Layer 4 proxy, and optionally a per-namespace Envoy proxy for Layer 7 features Source 8সোর্স 8. In ambient mode, the ztunnel secure overlay handles routing and zero trust security for traffic Source 10সোর্স 10. When needed, users can enable L7 waypoint proxies to get access to the full range of Istio features Source 10সোর্স 10. Pods and workloads using sidecar mode can co-exist within the same mesh as pods that use ambient mode Source 10সোর্স 10.
Falco: runtime security. Falco is a cloud native security tool that provides runtime security across hosts, containers, Kubernetes, and cloud environments Source 18সোর্স 18. At its core, Falco is a monitoring and detection agent that observes events and delivers real-time alerts based on custom rules Source 18সোর্স 18. Falco also enhances these events by integrating contextual metadata from container runtimes and Kubernetes Source 18সোর্স 18. Falco uses syscalls to monitor a system's activity Source 18সোর্স 18. Falco ships with a default set of rules that check the kernel for unusual behavior Source 18সোর্স 18. One example of the unusual behavior is privilege escalation using privileged containers Source 18সোর্স 18.
OPA: a policy engine. The OPA docs say that OPA is an open source, general-purpose policy engine that unifies policy enforcement across the stack Source 27সোর্স 27. OPA provides a high-level declarative language that lets you specify policy as code Source 27সোর্স 27. OPA decouples policy decision-making from policy enforcement Source 27সোর্স 27. When your software needs to make policy decisions, it queries OPA and supplies structured data as input Source 27সোর্স 27. OPA generates policy decisions by evaluating the query input against policies and data Source 27সোর্স 27. Policy decisions are not limited to simple yes/no or allow/deny answers Source 27সোর্স 27.
Gatekeeper: OPA for Kubernetes. In Kubernetes, admission controllers enforce policies on objects during create, update, and delete operations Source 34সোর্স 34. OPA Gatekeeper is a specialized project providing first-class integration between OPA and Kubernetes Source 34সোর্স 34. The OPA docs say that Gatekeeper is the recommended project for using OPA for Kubernetes admission control Source 34সোর্স 34. Gatekeeper adds native Kubernetes CRDs for extending the policy library, which are called constraint templates Source 34সোর্স 34. It adds native Kubernetes CRDs for instantiating the policy library, which are called constraints Source 34সোর্স 34. ConstraintTemplates define a way to validate some set of Kubernetes objects in Gatekeeper's Kubernetes admission controller Source 37সোর্স 37.
What the practice run covers. This paragraph describes the tutorial's own run. The run shows one privileged Pod from three sides. OPA and Gatekeeper report it as a policy violation in a local test, and Falco raises an alert for it from an audit event. Istio has no such Pod in the run. For Istio, the run checks files that describe traffic and security with istioctl analyze, and it renders the install manifests of five profiles with istioctl manifest generate.
বাংলা ব্যাখ্যা
CNCF আর তার ধাপ। Cloud Native Computing Foundation (CNCF) বিশ্বব্যাপী প্রযুক্তি অবকাঠামোর গুরুত্বপূর্ণ (critical) অংশ host করে Source 1সোর্স 1। CNCF অলাভজনক Linux Foundation-এর অংশ Source 1সোর্স 1। তার Technical Oversight Committee (TOC) project জীবনচক্রের ৪টা ধাপ ঠিক করে Source 3সোর্স 3। CNCF-এর projects page বলে, graduated আর incubating project stable বলে গণ্য হয় আর production পরিবেশে সফলভাবে ব্যবহৃত হয় Source 2সোর্স 2। TOC Incubation project-কে বর্ণনা করে এমন project হিসেবে, যা গ্রহণযোগ্যতা পাচ্ছে আর স্থিতিশীলতা ও পরিপক্বতা বাড়ানোর দিকে মন দিচ্ছে Source 3সোর্স 3। সে Graduated project-কে বর্ণনা করে অত্যন্ত পরিপক্ব, মজবুত project হিসেবে, যাদের ব্যবহারকারীরা production পরিবেশে deploy করে তাদের production-প্রস্তুতি দেখিয়েছেন Source 3সোর্স 3।
তিনটা project। CNCF page বলে, Istio গ্রহণ করা হয়েছে ২০২২ সালের ৩০ সেপ্টেম্বর Incubating স্তরে Source 4সোর্স 4। Istio ২০২৩ সালের ১২ জুলাই Graduated স্তরে উঠেছে Source 4সোর্স 4। CNCF-এর Falco page বলে, Falco গ্রহণ করা হয়েছে ২০১৮ সালের ১০ অক্টোবর Source 5সোর্স 5। Falco Incubating স্তরে উঠেছে ২০২০ সালের ৮ জানুয়ারি Source 5সোর্স 5। Falco Graduated স্তরে উঠেছে ২০২৪ সালের ২৯ ফেব্রুয়ারি Source 5সোর্স 5। CNCF-এর OPA page বলে, Open Policy Agent (OPA) গ্রহণ করা হয়েছে ২০১৮ সালের ২৯ মার্চ Source 6সোর্স 6। OPA Incubating স্তরে উঠেছে ২০১৯ সালের ২ এপ্রিল Source 6সোর্স 6। OPA Graduated স্তরে উঠেছে ২০২১ সালের ২৯ জানুয়ারি Source 6সোর্স 6। project page-গুলো Istio-কে বর্ণনা করে এমন একটা service mesh হিসেবে, যা observability, traffic management, security আর policy সহজ করে Source 4সোর্স 4। তারা Falco-কে বর্ণনা করে cloud-native runtime security project হিসেবে Source 5সোর্স 5, আর OPA-কে একটা open source, general-purpose policy engine হিসেবে Source 6সোর্স 6।
Istio: একটা service mesh। Istio docs service mesh-কে সংজ্ঞায়িত করে এমন একটা অবকাঠামো স্তর হিসেবে, যা application-কে code না বদলিয়ে zero-trust security, observability আর advanced traffic management-এর মতো সামর্থ্য দেয় Source 7সোর্স 7। Istio একটা open source service mesh, যা বিদ্যমান distributed application-এর ওপর স্বচ্ছভাবে বসে Source 8সোর্স 8। সে একটা proxy দিয়ে আপনার সব network traffic আটকায়, যার ফলে আপনার ঠিক করা configuration-এর ভিত্তিতে application-সচেতন features-এর একটা বিস্তৃত সেট পাওয়া যায় Source 8সোর্স 8। control plane আপনার চাওয়া configuration আর service-গুলো সম্পর্কে তার ধারণা নিয়ে proxy server-গুলোকে গতিশীলভাবে program করে Source 8সোর্স 8। Istio আপনাকে দেয় একটা cluster-এর ভেতরে mutual TLS encryption-সহ নিরাপদ service-to-service যোগাযোগ Source 8সোর্স 8। সে দেয় সমৃদ্ধ routing rule, retry, failover আর fault injection দিয়ে traffic আচরণের সূক্ষ্ম নিয়ন্ত্রণ Source 8সোর্স 8। সে আরও দেয় একটা cluster-এর ভেতরের সব traffic-এর জন্য স্বয়ংক্রিয় metrics, logs আর traces Source 8সোর্স 8।
Istio: দুটো data plane mode। Istio দুটো data plane mode সমর্থন করে Source 8সোর্স 8। Sidecar mode আপনার cluster-এ চালু করা প্রতিটা pod-এর সঙ্গে একটা Envoy proxy বসায়, অথবা VM-এ চলা service-এর পাশে চালায় Source 8সোর্স 8। Ambient mode ব্যবহার করে প্রতি node-এ একটা Layer 4 proxy, আর ঐচ্ছিকভাবে Layer 7 features-এর জন্য প্রতি namespace-এ একটা Envoy proxy Source 8সোর্স 8। ambient mode-এ ztunnel secure overlay traffic-এর routing আর zero trust security সামলায় Source 10সোর্স 10। দরকার হলে ব্যবহারকারীরা Istio-র সব features পেতে L7 waypoint proxy চালু করতে পারেন Source 10সোর্স 10। sidecar mode-এর pod আর workload একই mesh-এ ambient mode-এর pod-এর সঙ্গে থাকতে পারে Source 10সোর্স 10।
Falco: runtime security। Falco একটা cloud native security tool, যা host, container, Kubernetes আর cloud পরিবেশ জুড়ে runtime security দেয় Source 18সোর্স 18। মূলে Falco একটা monitoring আর detection agent, যে event লক্ষ করে আর custom rule-এর ভিত্তিতে real-time alert দেয় Source 18সোর্স 18। Falco container runtime আর Kubernetes থেকে প্রাসঙ্গিক metadata যোগ করে এই event-গুলোকে আরও সমৃদ্ধ করে Source 18সোর্স 18। Falco একটা system-এর কার্যকলাপ নজরে রাখতে syscall ব্যবহার করে Source 18সোর্স 18। Falco-র সঙ্গে আসে default rule-এর একটা সেট, যা kernel-এ অস্বাভাবিক আচরণ খোঁজে Source 18সোর্স 18। অস্বাভাবিক আচরণের একটা উদাহরণ হলো privileged container দিয়ে privilege escalation Source 18সোর্স 18।
OPA: একটা policy engine। OPA docs বলে, OPA একটা open source, general-purpose policy engine, যা পুরো stack জুড়ে policy enforcement একীভূত করে Source 27সোর্স 27। OPA একটা উচ্চস্তরের declarative ভাষা দেয়, যাতে আপনি policy-কে code হিসেবে লিখতে পারেন Source 27সোর্স 27। OPA policy সিদ্ধান্ত নেওয়াকে policy প্রয়োগ থেকে আলাদা করে Source 27সোর্স 27। আপনার software-কে policy সিদ্ধান্ত নিতে হলে সে OPA-কে query করে আর structured data input হিসেবে দেয় Source 27সোর্স 27। OPA query input-কে policy আর data-র বিরুদ্ধে মূল্যায়ন করে policy সিদ্ধান্ত তৈরি করে Source 27সোর্স 27। policy সিদ্ধান্ত কেবল সাধারণ yes/no বা allow/deny উত্তরে সীমিত নয় Source 27সোর্স 27।
Gatekeeper: Kubernetes-এর জন্য OPA। Kubernetes-এ admission controller create, update আর delete operation-এর সময় object-এর ওপর policy প্রয়োগ করে Source 34সোর্স 34। OPA Gatekeeper একটা বিশেষায়িত project, যা OPA আর Kubernetes-এর মধ্যে first-class integration দেয় Source 34সোর্স 34। OPA docs বলে, Kubernetes admission control-এর জন্য OPA ব্যবহারে Gatekeeper-ই সুপারিশ করা project Source 34সোর্স 34। Gatekeeper policy library বাড়ানোর জন্য native Kubernetes CRD যোগ করে, যাদের বলা হয় constraint template Source 34সোর্স 34। সে policy library-কে instance বানানোর জন্য native Kubernetes CRD যোগ করে, যাদের বলা হয় constraint Source 34সোর্স 34। ConstraintTemplate Gatekeeper-এর Kubernetes admission controller-এ একগুচ্ছ Kubernetes object যাচাই করার একটা উপায় ঠিক করে Source 37সোর্স 37।
practice run কী কী দেখায়। এই অনুচ্ছেদ টিউটোরিয়ালের নিজের run বর্ণনা করে। run একটা privileged Pod-কে তিন দিক থেকে দেখায়। OPA আর Gatekeeper একটা স্থানীয় test-এ তাকে policy violation হিসেবে জানায়, আর Falco একটা audit event থেকে তার জন্য alert তোলে। run-এ Istio-র এমন কোনো Pod নেই। Istio-র জন্য run istioctl analyze দিয়ে traffic আর security বর্ণনা করা file পরীক্ষা করে, আর istioctl manifest generate দিয়ে পাঁচটা profile-এর install manifest বানায়।
How it works
Istio: the two planes. An Istio service mesh is logically split into a data plane and a control plane Source 9সোর্স 9. In sidecar mode, the data plane is a set of intelligent proxies, Envoy, deployed as sidecars Source 9সোর্স 9. These proxies mediate and control all network communication between microservices Source 9সোর্স 9. They also collect and report telemetry on all mesh traffic Source 9সোর্স 9. Envoy proxies are the only Istio components that interact with data plane traffic Source 9সোর্স 9. The control plane manages and configures the proxies to route traffic Source 9সোর্স 9.
Istiod. Istiod provides service discovery, configuration, and certificate management Source 9সোর্স 9. It converts high level routing rules that control traffic behavior into Envoy-specific configurations, and propagates them to the sidecars at runtime Source 9সোর্স 9. Istiod acts as a Certificate Authority (CA) and generates certificates to allow secure mTLS communication in the data plane Source 9সোর্স 9. The Istio docs say that the sidecar proxy model allows you to add Istio capabilities to an existing deployment without requiring you to rearchitect or rewrite code Source 9সোর্স 9.
Ambient mode. In ambient mode, Istio implements its features using a per-node Layer 4 proxy, and optionally a per-namespace Layer 7 proxy Source 10সোর্স 10. This layered approach lets you adopt Istio in a more incremental fashion Source 10সোর্স 10. Waypoint proxies are heavier than the ztunnel overlay alone Source 10সোর্স 10. They still run as an ambient component of the infrastructure, and they need no modification of the application pods Source 10সোর্স 10.
Traffic routing: virtual services and destination rules. Virtual services, along with destination rules, are the key building blocks of Istio's traffic routing functionality Source 11সোর্স 11. A virtual service lets you configure how requests are routed to a service within an Istio service mesh Source 11সোর্স 11. Each virtual service consists of a set of routing rules that are evaluated in order Source 11সোর্স 11. A virtual service can send traffic to different versions of a service, such as "20% of calls go to the new version" Source 11সোর্স 11. This allows a canary rollout, where you gradually increase the percentage of traffic that is sent to a new service version Source 11সোর্স 11. Destination rules let you customize Envoy's traffic policies when calling the entire destination service or a particular service subset Source 11সোর্স 11. In some cases you also need to configure destination rules to use the features of virtual services, as destination rules are where you specify your service subsets Source 11সোর্স 11.
Gateways. Gateways are primarily used to manage ingress traffic, but you can also configure egress gateways Source 11সোর্স 11. An egress gateway lets you configure a dedicated exit node for the traffic leaving the mesh Source 11সোর্স 11. Istio provides some preconfigured gateway proxy deployments that you can use, istio-ingressgateway and istio-egressgateway Source 11সোর্স 11. Both are deployed if you use the demo installation Source 11সোর্স 11. Just the ingress gateway is deployed with the default profile Source 11সোর্স 11.
Resilience: timeouts, retries, and circuit breakers. A timeout is the amount of time that an Envoy proxy should wait for replies from a given service Source 11সোর্স 11. The Envoy timeout for HTTP requests is disabled in Istio by default Source 11সোর্স 11. A retry setting specifies the maximum number of times an Envoy proxy attempts to connect to a service if the initial call fails Source 11সোর্স 11. The default retry behavior for HTTP requests is to retry twice before returning the error Source 11সোর্স 11. In a circuit breaker, you set limits for calls to individual hosts within a service Source 11সোর্স 11. Once that limit has been reached, the circuit breaker "trips" and stops further connections to that host Source 11সোর্স 11. You configure circuit breaker thresholds in destination rules Source 11সোর্স 11.
Fault injection. Fault injection is a testing method that introduces errors into a system to ensure that it can withstand and recover from error conditions Source 11সোর্স 11. Istio lets you inject faults at the application layer, unlike delaying packets or killing pods at the network layer Source 11সোর্স 11. You can inject two types of faults, both configured using a virtual service Source 11সোর্স 11. Delays are timing failures that mimic increased network latency or an overloaded upstream service Source 11সোর্স 11. Aborts are crash failures that mimic failures in upstream services Source 11সোর্স 11. Currently, the fault injection configuration can not be combined with retry or timeout configuration on the same virtual service Source 11সোর্স 11. Istio failure recovery features are completely transparent to the application Source 11সোর্স 11. If you also set failure recovery policies in your application code, both work independently and therefore might conflict Source 11সোর্স 11.
Mutual TLS and identity. Peer authentication is used for service-to-service authentication to verify the client making the connection Source 12সোর্স 12. Istio offers mutual TLS as a full stack solution for transport authentication, which can be enabled without requiring service code changes Source 12সোর্স 12. With mutual TLS, Istio re-routes the outbound traffic from a client to the client's local sidecar Envoy Source 12সোর্স 12. The client side Envoy starts a mutual TLS handshake with the server side Envoy Source 12সোর্স 12. The server side Envoy authorizes the request Source 12সোর্স 12. Istio configures TLSv1_2 as the minimum TLS version for both client and server Source 12সোর্স 12.
Permissive mode. Istio mutual TLS has a permissive mode, which allows a service to accept both plaintext traffic and mutual TLS traffic at the same time Source 12সোর্স 12. The docs say that this feature greatly improves the mutual TLS onboarding experience Source 12সোর্স 12. The operator can gradually install and configure the client's Istio sidecars to send mutual TLS traffic Source 12সোর্স 12. Once the configuration of the clients is complete, the operator can configure the server to mutual TLS only mode Source 12সোর্স 12.
Authorization policies. Authorization policies support ALLOW, DENY, and CUSTOM actions Source 12সোর্স 12. Istio checks for matching policies in layers, in this order: CUSTOM, DENY, and then ALLOW Source 12সোর্স 12. When you apply multiple authorization policies to the same workload, Istio applies them additively Source 12সোর্স 12. The deny policy takes precedence over the allow policy Source 12সোর্স 12. An authorization policy includes a selector, an action, and a list of rules Source 12সোর্স 12. If the selector is not set, the policy applies to all workloads in the same namespace as the policy Source 12সোর্স 12. The "deny by default" behavior applies only if the workload has at least one authorization policy with the ALLOW action Source 12সোর্স 12. The docs call it a good security practice to start with the allow-nothing policy and incrementally add more ALLOW policies to open more access to the workload Source 12সোর্স 12.
Telemetry. Istio generates detailed telemetry for all service communications within a mesh Source 13সোর্স 13. It generates metrics, distributed traces, and access logs Source 13সোর্স 13. The four golden signals of monitoring are latency, traffic, errors, and saturation Source 13সোর্স 13. The standard Istio metrics are exported to Prometheus by default Source 13সোর্স 13. Istio supports distributed tracing through the Envoy proxies Source 13সোর্স 13. The proxies automatically generate trace spans on behalf of the applications they proxy, requiring only that the applications forward the appropriate request context Source 13সোর্স 13. Istio supports a number of tracing backends, including Zipkin, Jaeger, and many tools and services that support OpenTelemetry Source 13সোর্স 13. By default, Istio enables only a small subset of the Envoy-generated statistics Source 13সোর্স 13.
Profiles. The built-in deployment profiles are just sets of Helm values overrides Source 14সোর্স 14. The default profile enables components according to the default settings of the IstioOperator API Source 14সোর্স 14. The demo profile is designed to showcase Istio functionality with modest resource requirements Source 14সোর্স 14. The demo profile enables high levels of tracing and access logging, so it is not suitable for performance tests Source 14সোর্স 14. The minimal profile is the same as the default profile, but only the control plane components are installed Source 14সোর্স 14. The ambient profile is designed to help you get started with ambient mode Source 14সোর্স 14. The empty profile deploys nothing Source 14সোর্স 14. The istioctl manifest generate command generates an Istio install manifest and outputs it to the console by default Source 16সোর্স 16.
Checking the configuration: istioctl analyze. istioctl analyze is a diagnostic tool that can detect potential issues with your Istio configuration Source 15সোর্স 15. It can run against a live cluster or a set of local configuration files Source 15সোর্স 15. It can also run against a combination of the two, which allows you to catch problems before you apply changes to a cluster Source 15সোর্স 15. When you analyze a set of local files, the file-set is expected to be fully self-contained Source 15সোর্স 15. To analyze local files, add the --use-kube=false flag Source 15সোর্স 15. The reference lists --all-namespaces (-A) to analyze all namespaces and --namespace (-n) for one Source 16সোর্স 16. The --failure-threshold option sets the severity level of analysis at which to set a non-zero exit code Source 16সোর্স 16. The --output option takes one of log, json, or yaml, with log as the default Source 16সোর্স 16. The -L option lists the analyzers that are available to run Source 16সোর্স 16.
Analysis messages. The message IST0101 has the level Error, and it occurs when an Istio resource references another resource that does not exist Source 17সোর্স 17. The docs say that this will lead to errors when Istio tries to look up the referenced resource but cannot find it Source 17সোর্স 17. For example, a VirtualService refers to a gateway that does not exist Source 17সোর্স 17. The docs also describe an experimental feature, which is intended for evaluation purposes only Source 15সোর্স 15. In it, Istio can be set up to perform the analysis alongside the configuration distribution Source 15সোর্স 15. In that case, the validation messages are written to the status subresource of the affected Istio resource Source 15সোর্স 15. The docs say that this is not a replacement for istioctl analyze Source 15সোর্স 15.
Falco: events in, alerts out. Falco uses syscalls to monitor a system's activity Source 18সোর্স 18. It parses the Linux syscalls from the kernel at runtime Source 18সোর্স 18. It asserts the stream against a rules engine, and it alerts when a rule is violated Source 18সোর্স 18. Falco's monitoring capabilities are not limited to syscalls, because it can be extended via plugins to ingest data from many more types of sources Source 18সোর্স 18. The userspace program handles signals, parses information from a Falco driver, and sends alerts Source 18সোর্স 18. The configuration defines how Falco is run, what rules to assert, and how to perform alerts Source 18সোর্স 18.
Event sources. Falco natively supports the syscall event source, which is enabled by default, consuming events from the Linux Kernel via drivers Source 19সোর্স 19. The plugin system allows Falco to extend its capabilities with new event sources Source 19সোর্স 19. Each event source operates in an isolated thread Source 19সোর্স 19. Rules are partitioned by event source, meaning each rule applies to a specific source and is triggered exclusively by events from that source Source 19সোর্স 19. Falco does not support correlating events from different sources Source 19সোর্স 19. By default, Falco enables event collection from all known sources Source 19সোর্স 19. For plugin-based deployments, you disable the syscall source explicitly, or enable only the plugin-based sources that you want Source 19সোর্স 19. Attempting to disable unknown sources or all sources results in an error Source 19সোর্স 19.
Drivers and privileges. A driver runs in kernelspace Source 20সোর্স 20. The driver provides the syscall event source Source 20সোর্স 20. The docs say that there are several supported drivers Source 20সোর্স 20. They list the modern eBPF probe, which is the default, and the kernel module Source 20সোর্স 20. The kernel module requires full privileges and cannot run with Linux capabilities Source 20সোর্স 20. The modern eBPF probe doesn't require a specific kernel version Source 20সোর্স 20. Usually, all versions at or above 5.8 are enough Source 20সোর্স 20. The 2 main required features are BPF ring buffer support and a kernel that exposes BTF Source 20সোর্স 20. The tarball page says that by default Falco consumes events from the Linux Kernel, which requires Falco to be privileged Source 26সোর্স 26. To use the syscall source without a driver, you run Falco with -o engine.kind=nodriver Source 19সোর্স 19. In that mode Falco continues to process syscall events, but it does not use a driver to capture them Source 19সোর্স 19.
Rules files. A Falco rules file is a YAML file containing mainly three types of elements Source 22সোর্স 22. Rules are the conditions under which an alert should be generated Source 22সোর্স 22. A rule is accompanied by a descriptive output string that is sent with the alert Source 22সোর্স 22. Macros are rule condition snippets that can be re-used inside rules and even other macros Source 22সোর্স 22. Lists are collections of items that can be included in rules, macros, or other lists Source 22সোর্স 22. Unlike rules and macros, lists cannot be parsed as filtering expressions Source 22সোর্স 22. A rules file can also hold required_engine_version, which tracks compatibility between rules content and the Falco engine version Source 22সোর্স 22.
A rule. A rule is a YAML object, part of the rules file, whose definition contains at least the fields rule, desc, condition, output, and priority Source 23সোর্স 23. The key part of a rule is the condition field Source 23সোর্স 23. A condition is a Boolean predicate expressed using the condition syntax Source 23সোর্স 23. A rule output is a string that can use the same fields that conditions can use, prepended by % to perform interpolation, akin to printf Source 23সোর্স 23. Every Falco rule has a priority which indicates how serious a violation of the rule is Source 23সোর্স 23. The available priorities are EMERGENCY, ALERT, CRITICAL, ERROR, WARNING, NOTICE, INFORMATIONAL, and DEBUG Source 23সোর্স 23. In a rule, the priority has nothing to do with overriding another rule or choosing the order in which rules will be triggered Source 23সোর্স 23. The way to control that order is to change the order in which the rules are defined, and therefore loaded Source 23সোর্স 23.
Conditions and event types. The docs give an example of a condition that alerts whenever a bash shell is run inside a container, container.id != host and proc.name = bash Source 23সোর্স 23. Since this condition does not include a clause with a system call, it will only check event metadata Source 23সোর্স 23. Because of that, if a bash shell does start up in a container, Falco outputs events for every syscall that is performed by that shell Source 23সোর্স 23. To be alerted only for each successful spawn of a shell in a container, you add the appropriate event types to the condition Source 23সোর্স 23. In the example of the docs, if the connection happens outside a container, the field %container.image.repository would not be set, and <NA> is displayed instead Source 23সোর্স 23.
First match wins. The Falco docs say that Falco by default applies rules per event type on a "first match wins" basis Source 24সোর্স 24. Starting from Falco Release 0.36.0, you can change the configuration to rule_matching: all Source 24সোর্স 24. This change ensures that rules sharing the same event type cannot override each other, which prevents inconsistent logging Source 24সোর্স 24. The docs warn that this modification may lead to increased CPU usage Source 24সোর্স 24.
Command line. The -c option sets the configuration file, and the default is /etc/falco/falco.yaml Source 25সোর্স 25. The -V (--validate) option reads the specified rules files, validates the loaded rules, and exits Source 25সোর্স 25. You can pass it several times to validate several files Source 25সোর্স 25. The --dry-run option runs Falco without processing events, and it can help check that the configuration and rules do not have any errors Source 25সোর্স 25. The -L option shows the name and description of all rules and exits Source 25সোর্স 25. The -r option sets a rules file or directory to be loaded, and only files with a .yml or .yaml extension are considered Source 25সোর্স 25. The -o option sets the value of a configuration option, and it overrides the values in the configuration file Source 25সোর্স 25. The --list option lists all defined fields and exits Source 25সোর্স 25.
Plugins, falcoctl, and outputs. Plugins are shared libraries that conform to a documented API Source 21সোর্স 21. They can add new event sources that can be evaluated using filtering expressions or Falco rules Source 21সোর্স 21. They can add the ability to define new fields that can extract information from events Source 21সোর্স 21. The k8s_audit source is provided by the k8saudit plugin Source 19সোর্স 19. The docs say that the plugins for this source all share the same set of rules Source 19সোর্স 19. Falcoctl allows you to easily install rules and plugins and perform administrative tasks with Falco Source 18সোর্স 18. It is bundled together with Falco Source 18সোর্স 18. Alerts are configurable downstream actions that can be as simple as logging to stdout or as complex as delivering an HTTP request to an endpoint Source 18সোর্স 18.
The tarball. Falco runs on Linux and is available for the x86_64 and aarch64 architectures Source 26সোর্স 26. Falco with its bundled plugins requires GLIBC 2.28 or newer Source 26সোর্স 26. The tarball page installs Falco by unpacking the archive and copying it to / Source 26সোর্স 26. The Falco .tar.gz archive doesn't include the Systemd setup Source 26সোর্স 26. The configuration file is located at /etc/falco/falco.yaml Source 26সোর্স 26. You can also override the default configuration by passing options to the falco binary Source 26সোর্স 26. The tutorial did not copy the archive to /. It unpacked the archive in the run folder and passed -c and -o.
Rules, maturity levels, and the event-generator. The Falco rules repository says that the maturity_stable rules in the falco_rules.yaml file are included in the Falco release package Source 40সোর্স 40. Other maturity-level rules are released separately, and they require explicit installation and possible customization Source 40সোর্স 40. The repository adds that the Rules Maturity Framework is a best effort on the part of the community, and that you have to decide if any rules are useful for your use cases Source 40সোর্স 40. The event-generator tool generates a variety of suspect actions that are detected by Falco rulesets Source 39সোর্স 39. Its k8saudit events collection is maintained on a best-effort basis and may not fully work Source 39সোর্স 39.
OPA: policy apart from the service. The OPA docs say that today policy is often a hard-coded feature of the software service that it governs Source 28সোর্স 28. OPA lets you decouple policy from that software service, so that the people responsible for policy can read, write, analyze, version, distribute, and manage it separately from the service Source 28সোর্স 28. Software services should allow policies to be specified declaratively, updated at any time without recompiling or redeploying, and enforced automatically Source 28সোর্স 28. Authorization is sometimes confused with authentication Source 28সোর্স 28.
Rego. Rego is declarative, so policy authors can focus on what queries should return rather than how queries should be executed Source 29সোর্স 29. All modules contain implicit statements which import the data and input documents Source 29সোর্স 29. Expressions that refer to undefined values are also undefined Source 29সোর্স 29. The default keyword allows policies to define a default value for documents produced by rules with complete definitions Source 29সোর্স 29. The with keyword allows queries to programmatically specify values nested under the input document or the data document, or built-in functions Source 29সোর্স 29. Variables in Rego are existentially quantified by default Source 29সোর্স 29.
Rego v1 and v0. The OPA CLI reference lists the options --v0-compatible and --v1-compatible Source 31সোর্স 31. For opa fmt, v1 Rego is formatted to v1, and v0 Rego is rejected Source 31সোর্স 31. With opa fmt --v0-compatible, v0 Rego is formatted to v0, and v1 Rego is rejected Source 31সোর্স 31. The Gatekeeper docs say that using Rego v1 syntax in a ConstraintTemplate is opt-in, and that by default only Rego v0 is allowed Source 37সোর্স 37.
Testing policies. OPA gives you a framework that you can use to write tests for your policies Source 30সোর্স 30. Tests are expressed as standard Rego rules with a convention that the rule name is prefixed with test_ Source 30সোর্স 30. The opa test subcommand runs all of the tests found in Rego files passed on the command line Source 30সোর্স 30. If the test rule is undefined or generates a non-true value, the test result is reported as FAIL Source 30সোর্স 30. If the test encounters a runtime error, the result is marked as an ERROR Source 30সোর্স 30. Tests prefixed with todo_ are reported as SKIPPED Source 30সোর্স 30. When you misspell a test name or run no test by accident, opa test still succeeds Source 30সোর্স 30. The docs say that --fail-on-empty is also useful in CI/CD pipelines to ensure that tests are actually being executed Source 30সোর্স 30. opa test can also report coverage for the policies under test Source 30সোর্স 30.
The command line. The opa eval option --fail exits with a non-zero exit code on an undefined or empty result and on errors Source 31সোর্স 31. The option --fail-defined exits with a non-zero exit code on a defined or non-empty result and on errors Source 31সোর্স 31. opa check checks Rego source files for parse and compilation errors Source 31সোর্স 31. If it succeeds, it produces no output Source 31সোর্স 31. If it fails, it outputs the errors and exits with a non-zero exit code Source 31সোর্স 31. The reference lists --strict, which enables compiler strict mode Source 31সোর্স 31. opa fmt --fail returns a non-zero exit code if a file would be reformatted Source 31সোর্স 31. opa fmt -l outputs the names of files that would change if formatted Source 31সোর্স 31.
The server and the REST API. The Data API takes POST /v1/data/{path} with a JSON body of the form {"input": ...} Source 32সোর্স 32. The request body contains an object that specifies a value for the input document Source 32সোর্স 32. Any additional top-level keys in the request body beyond input are treated as request metadata Source 32সোর্স 32. The server returns 200 if the path refers to an undefined document Source 32সোর্স 32. In that case, the response does not contain a result property Source 32সোর্স 32. If decision logging is enabled, the response has a decision_id field that uniquely identifies the decision Source 32সোর্স 32. Callers can use the identifier for correlation purposes Source 32সোর্স 32.
Decision logs. OPA can report decision logs to remote HTTP servers, using custom plugins, or to the console output, or to any combination of these Source 33সোর্স 33. The decision logs contain events that describe policy queries Source 33সোর্স 33. Each event includes the policy that was queried, the input to the query, bundle metadata, and other information that enables auditing and offline debugging of policy decisions Source 33সোর্স 33. When decision logging is enabled, the OPA server includes a decision_id field in API calls that return policy decisions Source 33সোর্স 33. The path field of an event holds the hierarchical policy decision path Source 33সোর্স 33. The input field holds the input data provided in the policy query Source 33সোর্স 33. The result field holds the policy decision returned to the client Source 33সোর্স 33.
OPA in Kubernetes admission control. With plain OPA, the Kubernetes API Server is configured to query OPA for admission control decisions when objects are created, updated, or deleted Source 34সোর্স 34. The API Server sends the entire Kubernetes object in the webhook request to OPA Source 34সোর্স 34. OPA evaluates the policies it has loaded using the admission review as input Source 34সোর্স 34. In that input, input.request.object contains the entire Kubernetes object Source 34সোর্স 34. Gatekeeper adds an extensible, parameterized policy library Source 34সোর্স 34. It also adds audit functionality Source 34সোর্স 34. Plain OPA and Kube-mgmt are alternatives that can be reached for if you want to use the management features of OPA, such as status logs, decision logs, and bundles Source 34সোর্স 34.
Gatekeeper constraint templates. ConstraintTemplates are made of two main elements Source 37সোর্স 37. One is the Rego or CEL policy code that defines the policy violation logic Source 37সোর্স 37. The other is the schema of the accompanying Constraint object, which represents an instantiation of a ConstraintTemplate Source 37সোর্স 37. The Gatekeeper docs show a violation rule that has a msg Source 37সোর্স 37. The docs say that Rego v1 syntax can only be used under targets[_].code[_] with engine: Rego and version: "v1" Source 37সোর্স 37.
gator. The gator CLI is a tool for evaluating Gatekeeper ConstraintTemplates and Constraints in a local environment Source 38সোর্স 38. gator test tests a set of Kubernetes objects against a set of Templates and Constraints Source 38সোর্স 38. The command returns violations when found and communicates success or failure via its exit status Source 38সোর্স 38. gator verify organizes tests into three levels: Suites, Tests, and Cases Source 38সোর্স 38. A Case defines an object to validate and whether the object is expected to pass validation Source 38সোর্স 38. The value of violations is either "yes", "no", or a non-negative integer Source 38সোর্স 38. If it is a non-negative integer, exactly that many violations must match Source 38সোর্স 38. The message field is a regular expression used to match the violation message Source 38সোর্স 38. To be valid, a Suite file must declare kind: Suite and an apiVersion Source 38সোর্স 38. gator verify silently ignores files which do not declare these Source 38সোর্স 38. The docs note that audit and gator test are different enforcement points, and that they do not have the AdmissionReview request metadata Source 38সোর্স 38.
OPA with Envoy and Istio. Envoy supports an External Authorization filter which calls an authorization service to check if the incoming request is authorized or not Source 35সোর্স 35. The OPA-Envoy plugin extends OPA with a gRPC server that implements the Envoy External Authorization API Source 35সোর্স 35. You can use it to enforce fine-grained, context-aware access control policies with Envoy without modifying your microservice Source 35সোর্স 35. The plugin has a dry-run option Source 35সোর্স 35. Its default is false Source 35সোর্স 35.
OPA with Terraform. OPA makes it possible to write policies that check the changes Terraform is about to make before it makes them Source 36সোর্স 36. OPA policies operate on the JSON plan generated by Terraform, which has certain limitations Source 36সোর্স 36. Some information may not be available at plan time Source 36সোর্স 36. The docs name unknown values, dynamic blocks, and function calls Source 36সোর্স 36. Before writing policies, you confirm that the information you need is available in the plan JSON output Source 36সোর্স 36. Terraform and Infrastructure as Code explains the plan. The tutorial did not run OPA on a Terraform plan.
সহজ English
Istio: the two planes. An Istio service mesh is logically split into a data plane and a control plane Source 9সোর্স 9. In sidecar mode, the data plane is a set of intelligent proxies, Envoy, deployed as sidecars Source 9সোর্স 9. These proxies mediate and control all network communication between microservices Source 9সোর্স 9. They also collect and report telemetry on all mesh traffic Source 9সোর্স 9. Envoy proxies are the only Istio components that interact with data plane traffic Source 9সোর্স 9. The control plane manages and configures the proxies to route traffic Source 9সোর্স 9.
Istiod. Istiod provides service discovery, configuration, and certificate management Source 9সোর্স 9. It converts high level routing rules that control traffic behavior into Envoy-specific configurations, and propagates them to the sidecars at runtime Source 9সোর্স 9. Istiod acts as a Certificate Authority (CA) and generates certificates to allow secure mTLS communication in the data plane Source 9সোর্স 9. The Istio docs say that the sidecar proxy model allows you to add Istio capabilities to an existing deployment without requiring you to rearchitect or rewrite code Source 9সোর্স 9.
Ambient mode. In ambient mode, Istio implements its features using a per-node Layer 4 proxy, and optionally a per-namespace Layer 7 proxy Source 10সোর্স 10. This layered approach lets you adopt Istio in a more incremental fashion Source 10সোর্স 10. Waypoint proxies are heavier than the ztunnel overlay alone Source 10সোর্স 10. They still run as an ambient component of the infrastructure, and they need no modification of the application pods Source 10সোর্স 10.
Traffic routing: virtual services and destination rules. Virtual services, along with destination rules, are the key building blocks of Istio's traffic routing functionality Source 11সোর্স 11. A virtual service lets you configure how requests are routed to a service within an Istio service mesh Source 11সোর্স 11. Each virtual service consists of a set of routing rules that are evaluated in order Source 11সোর্স 11. A virtual service can send traffic to different versions of a service, such as "20% of calls go to the new version" Source 11সোর্স 11. This allows a canary rollout, where you gradually increase the percentage of traffic that is sent to a new service version Source 11সোর্স 11. Destination rules let you customize Envoy's traffic policies when calling the entire destination service or a particular service subset Source 11সোর্স 11. In some cases you also need to configure destination rules to use the features of virtual services, as destination rules are where you specify your service subsets Source 11সোর্স 11.
Gateways. Gateways are primarily used to manage ingress traffic, but you can also configure egress gateways Source 11সোর্স 11. An egress gateway lets you configure a dedicated exit node for the traffic leaving the mesh Source 11সোর্স 11. Istio provides some preconfigured gateway proxy deployments that you can use, istio-ingressgateway and istio-egressgateway Source 11সোর্স 11. Both are deployed if you use the demo installation Source 11সোর্স 11. Just the ingress gateway is deployed with the default profile Source 11সোর্স 11.
Resilience: timeouts, retries, and circuit breakers. A timeout is the amount of time that an Envoy proxy should wait for replies from a given service Source 11সোর্স 11. The Envoy timeout for HTTP requests is disabled in Istio by default Source 11সোর্স 11. A retry setting specifies the maximum number of times an Envoy proxy attempts to connect to a service if the initial call fails Source 11সোর্স 11. The default retry behavior for HTTP requests is to retry twice before returning the error Source 11সোর্স 11. In a circuit breaker, you set limits for calls to individual hosts within a service Source 11সোর্স 11. Once that limit has been reached, the circuit breaker "trips" and stops further connections to that host Source 11সোর্স 11. You configure circuit breaker thresholds in destination rules Source 11সোর্স 11.
Fault injection. Fault injection is a testing method that introduces errors into a system to ensure that it can withstand and recover from error conditions Source 11সোর্স 11. Istio lets you inject faults at the application layer, unlike delaying packets or killing pods at the network layer Source 11সোর্স 11. You can inject two types of faults, both configured using a virtual service Source 11সোর্স 11. Delays are timing failures that mimic increased network latency or an overloaded upstream service Source 11সোর্স 11. Aborts are crash failures that mimic failures in upstream services Source 11সোর্স 11. Currently, the fault injection configuration can not be combined with retry or timeout configuration on the same virtual service Source 11সোর্স 11. Istio failure recovery features are completely transparent to the application Source 11সোর্স 11. If you also set failure recovery policies in your application code, both work independently and therefore might conflict Source 11সোর্স 11.
Mutual TLS and identity. Peer authentication is used for service-to-service authentication to verify the client making the connection Source 12সোর্স 12. Istio offers mutual TLS as a full stack solution for transport authentication, which can be enabled without requiring service code changes Source 12সোর্স 12. With mutual TLS, Istio re-routes the outbound traffic from a client to the client's local sidecar Envoy Source 12সোর্স 12. The client side Envoy starts a mutual TLS handshake with the server side Envoy Source 12সোর্স 12. The server side Envoy authorizes the request Source 12সোর্স 12. Istio configures TLSv1_2 as the minimum TLS version for both client and server Source 12সোর্স 12.
Permissive mode. Istio mutual TLS has a permissive mode, which allows a service to accept both plaintext traffic and mutual TLS traffic at the same time Source 12সোর্স 12. The docs say that this feature greatly improves the mutual TLS onboarding experience Source 12সোর্স 12. The operator can gradually install and configure the client's Istio sidecars to send mutual TLS traffic Source 12সোর্স 12. Once the configuration of the clients is complete, the operator can configure the server to mutual TLS only mode Source 12সোর্স 12.
Authorization policies. Authorization policies support ALLOW, DENY, and CUSTOM actions Source 12সোর্স 12. Istio checks for matching policies in layers, in this order: CUSTOM, DENY, and then ALLOW Source 12সোর্স 12. When you apply multiple authorization policies to the same workload, Istio applies them additively Source 12সোর্স 12. The deny policy takes precedence over the allow policy Source 12সোর্স 12. An authorization policy includes a selector, an action, and a list of rules Source 12সোর্স 12. If the selector is not set, the policy applies to all workloads in the same namespace as the policy Source 12সোর্স 12. The "deny by default" behavior applies only if the workload has at least one authorization policy with the ALLOW action Source 12সোর্স 12. The docs call it a good security practice to start with the allow-nothing policy and incrementally add more ALLOW policies to open more access to the workload Source 12সোর্স 12.
Telemetry. Istio generates detailed telemetry for all service communications within a mesh Source 13সোর্স 13. It generates metrics, distributed traces, and access logs Source 13সোর্স 13. The four golden signals of monitoring are latency, traffic, errors, and saturation Source 13সোর্স 13. The standard Istio metrics are exported to Prometheus by default Source 13সোর্স 13. Istio supports distributed tracing through the Envoy proxies Source 13সোর্স 13. The proxies automatically generate trace spans on behalf of the applications they proxy, requiring only that the applications forward the appropriate request context Source 13সোর্স 13. Istio supports a number of tracing backends, including Zipkin, Jaeger, and many tools and services that support OpenTelemetry Source 13সোর্স 13. By default, Istio enables only a small subset of the Envoy-generated statistics Source 13সোর্স 13.
Profiles. The built-in deployment profiles are just sets of Helm values overrides Source 14সোর্স 14. The default profile enables components according to the default settings of the IstioOperator API Source 14সোর্স 14. The demo profile is designed to showcase Istio functionality with modest resource requirements Source 14সোর্স 14. The demo profile enables high levels of tracing and access logging, so it is not suitable for performance tests Source 14সোর্স 14. The minimal profile is the same as the default profile, but only the control plane components are installed Source 14সোর্স 14. The ambient profile is designed to help you get started with ambient mode Source 14সোর্স 14. The empty profile deploys nothing Source 14সোর্স 14. The istioctl manifest generate command generates an Istio install manifest and outputs it to the console by default Source 16সোর্স 16.
Checking the configuration: istioctl analyze. istioctl analyze is a diagnostic tool that can detect potential issues with your Istio configuration Source 15সোর্স 15. It can run against a live cluster or a set of local configuration files Source 15সোর্স 15. It can also run against a combination of the two, which allows you to catch problems before you apply changes to a cluster Source 15সোর্স 15. When you analyze a set of local files, the file-set is expected to be fully self-contained Source 15সোর্স 15. To analyze local files, add the --use-kube=false flag Source 15সোর্স 15. The reference lists --all-namespaces (-A) to analyze all namespaces and --namespace (-n) for one Source 16সোর্স 16. The --failure-threshold option sets the severity level of analysis at which to set a non-zero exit code Source 16সোর্স 16. The --output option takes one of log, json, or yaml, with log as the default Source 16সোর্স 16. The -L option lists the analyzers that are available to run Source 16সোর্স 16.
Analysis messages. The message IST0101 has the level Error, and it occurs when an Istio resource references another resource that does not exist Source 17সোর্স 17. The docs say that this will lead to errors when Istio tries to look up the referenced resource but cannot find it Source 17সোর্স 17. For example, a VirtualService refers to a gateway that does not exist Source 17সোর্স 17. The docs also describe an experimental feature, which is intended for evaluation purposes only Source 15সোর্স 15. In it, Istio can be set up to perform the analysis alongside the configuration distribution Source 15সোর্স 15. In that case, the validation messages are written to the status subresource of the affected Istio resource Source 15সোর্স 15. The docs say that this is not a replacement for istioctl analyze Source 15সোর্স 15.
Falco: events in, alerts out. Falco uses syscalls to monitor a system's activity Source 18সোর্স 18. It parses the Linux syscalls from the kernel at runtime Source 18সোর্স 18. It asserts the stream against a rules engine, and it alerts when a rule is violated Source 18সোর্স 18. Falco's monitoring capabilities are not limited to syscalls, because it can be extended via plugins to ingest data from many more types of sources Source 18সোর্স 18. The userspace program handles signals, parses information from a Falco driver, and sends alerts Source 18সোর্স 18. The configuration defines how Falco is run, what rules to assert, and how to perform alerts Source 18সোর্স 18.
Event sources. Falco natively supports the syscall event source, which is enabled by default, consuming events from the Linux Kernel via drivers Source 19সোর্স 19. The plugin system allows Falco to extend its capabilities with new event sources Source 19সোর্স 19. Each event source operates in an isolated thread Source 19সোর্স 19. Rules are partitioned by event source, meaning each rule applies to a specific source and is triggered exclusively by events from that source Source 19সোর্স 19. Falco does not support correlating events from different sources Source 19সোর্স 19. By default, Falco enables event collection from all known sources Source 19সোর্স 19. For plugin-based deployments, you disable the syscall source explicitly, or enable only the plugin-based sources that you want Source 19সোর্স 19. Attempting to disable unknown sources or all sources results in an error Source 19সোর্স 19.
Drivers and privileges. A driver runs in kernelspace Source 20সোর্স 20. The driver provides the syscall event source Source 20সোর্স 20. The docs say that there are several supported drivers Source 20সোর্স 20. They list the modern eBPF probe, which is the default, and the kernel module Source 20সোর্স 20. The kernel module requires full privileges and cannot run with Linux capabilities Source 20সোর্স 20. The modern eBPF probe doesn't require a specific kernel version Source 20সোর্স 20. Usually, all versions at or above 5.8 are enough Source 20সোর্স 20. The 2 main required features are BPF ring buffer support and a kernel that exposes BTF Source 20সোর্স 20. The tarball page says that by default Falco consumes events from the Linux Kernel, which requires Falco to be privileged Source 26সোর্স 26. To use the syscall source without a driver, you run Falco with -o engine.kind=nodriver Source 19সোর্স 19. In that mode Falco continues to process syscall events, but it does not use a driver to capture them Source 19সোর্স 19.
Rules files. A Falco rules file is a YAML file containing mainly three types of elements Source 22সোর্স 22. Rules are the conditions under which an alert should be generated Source 22সোর্স 22. A rule is accompanied by a descriptive output string that is sent with the alert Source 22সোর্স 22. Macros are rule condition snippets that can be re-used inside rules and even other macros Source 22সোর্স 22. Lists are collections of items that can be included in rules, macros, or other lists Source 22সোর্স 22. Unlike rules and macros, lists cannot be parsed as filtering expressions Source 22সোর্স 22. A rules file can also hold required_engine_version, which tracks compatibility between rules content and the Falco engine version Source 22সোর্স 22.
A rule. A rule is a YAML object, part of the rules file, whose definition contains at least the fields rule, desc, condition, output, and priority Source 23সোর্স 23. The key part of a rule is the condition field Source 23সোর্স 23. A condition is a Boolean predicate expressed using the condition syntax Source 23সোর্স 23. A rule output is a string that can use the same fields that conditions can use, prepended by % to perform interpolation, akin to printf Source 23সোর্স 23. Every Falco rule has a priority which indicates how serious a violation of the rule is Source 23সোর্স 23. The available priorities are EMERGENCY, ALERT, CRITICAL, ERROR, WARNING, NOTICE, INFORMATIONAL, and DEBUG Source 23সোর্স 23. In a rule, the priority has nothing to do with overriding another rule or choosing the order in which rules will be triggered Source 23সোর্স 23. The way to control that order is to change the order in which the rules are defined, and therefore loaded Source 23সোর্স 23.
Conditions and event types. The docs give an example of a condition that alerts whenever a bash shell is run inside a container, container.id != host and proc.name = bash Source 23সোর্স 23. Since this condition does not include a clause with a system call, it will only check event metadata Source 23সোর্স 23. Because of that, if a bash shell does start up in a container, Falco outputs events for every syscall that is performed by that shell Source 23সোর্স 23. To be alerted only for each successful spawn of a shell in a container, you add the appropriate event types to the condition Source 23সোর্স 23. In the example of the docs, if the connection happens outside a container, the field %container.image.repository would not be set, and <NA> is displayed instead Source 23সোর্স 23.
First match wins. The Falco docs say that Falco by default applies rules per event type on a "first match wins" basis Source 24সোর্স 24. Starting from Falco Release 0.36.0, you can change the configuration to rule_matching: all Source 24সোর্স 24. This change ensures that rules sharing the same event type cannot override each other, which prevents inconsistent logging Source 24সোর্স 24. The docs warn that this modification may lead to increased CPU usage Source 24সোর্স 24.
Command line. The -c option sets the configuration file, and the default is /etc/falco/falco.yaml Source 25সোর্স 25. The -V (--validate) option reads the specified rules files, validates the loaded rules, and exits Source 25সোর্স 25. You can pass it several times to validate several files Source 25সোর্স 25. The --dry-run option runs Falco without processing events, and it can help check that the configuration and rules do not have any errors Source 25সোর্স 25. The -L option shows the name and description of all rules and exits Source 25সোর্স 25. The -r option sets a rules file or directory to be loaded, and only files with a .yml or .yaml extension are considered Source 25সোর্স 25. The -o option sets the value of a configuration option, and it overrides the values in the configuration file Source 25সোর্স 25. The --list option lists all defined fields and exits Source 25সোর্স 25.
Plugins, falcoctl, and outputs. Plugins are shared libraries that conform to a documented API Source 21সোর্স 21. They can add new event sources that can be evaluated using filtering expressions or Falco rules Source 21সোর্স 21. They can add the ability to define new fields that can extract information from events Source 21সোর্স 21. The k8s_audit source is provided by the k8saudit plugin Source 19সোর্স 19. The docs say that the plugins for this source all share the same set of rules Source 19সোর্স 19. Falcoctl allows you to easily install rules and plugins and perform administrative tasks with Falco Source 18সোর্স 18. It is bundled together with Falco Source 18সোর্স 18. Alerts are configurable downstream actions that can be as simple as logging to stdout or as complex as delivering an HTTP request to an endpoint Source 18সোর্স 18.
The tarball. Falco runs on Linux and is available for the x86_64 and aarch64 architectures Source 26সোর্স 26. Falco with its bundled plugins requires GLIBC 2.28 or newer Source 26সোর্স 26. The tarball page installs Falco by unpacking the archive and copying it to / Source 26সোর্স 26. The Falco .tar.gz archive doesn't include the Systemd setup Source 26সোর্স 26. The configuration file is located at /etc/falco/falco.yaml Source 26সোর্স 26. You can also override the default configuration by passing options to the falco binary Source 26সোর্স 26. The tutorial did not copy the archive to /. It unpacked the archive in the run folder and passed -c and -o.
Rules, maturity levels, and the event-generator. The Falco rules repository says that the maturity_stable rules in the falco_rules.yaml file are included in the Falco release package Source 40সোর্স 40. Other maturity-level rules are released separately, and they require explicit installation and possible customization Source 40সোর্স 40. The repository adds that the Rules Maturity Framework is a best effort on the part of the community, and that you have to decide if any rules are useful for your use cases Source 40সোর্স 40. The event-generator tool generates a variety of suspect actions that are detected by Falco rulesets Source 39সোর্স 39. Its k8saudit events collection is maintained on a best-effort basis and may not fully work Source 39সোর্স 39.
OPA: policy apart from the service. The OPA docs say that today policy is often a hard-coded feature of the software service that it governs Source 28সোর্স 28. OPA lets you decouple policy from that software service, so that the people responsible for policy can read, write, analyze, version, distribute, and manage it separately from the service Source 28সোর্স 28. Software services should allow policies to be specified declaratively, updated at any time without recompiling or redeploying, and enforced automatically Source 28সোর্স 28. Authorization is sometimes confused with authentication Source 28সোর্স 28.
Rego. Rego is declarative, so policy authors can focus on what queries should return rather than how queries should be executed Source 29সোর্স 29. All modules contain implicit statements which import the data and input documents Source 29সোর্স 29. Expressions that refer to undefined values are also undefined Source 29সোর্স 29. The default keyword allows policies to define a default value for documents produced by rules with complete definitions Source 29সোর্স 29. The with keyword allows queries to programmatically specify values nested under the input document or the data document, or built-in functions Source 29সোর্স 29. Variables in Rego are existentially quantified by default Source 29সোর্স 29.
Rego v1 and v0. The OPA CLI reference lists the options --v0-compatible and --v1-compatible Source 31সোর্স 31. For opa fmt, v1 Rego is formatted to v1, and v0 Rego is rejected Source 31সোর্স 31. With opa fmt --v0-compatible, v0 Rego is formatted to v0, and v1 Rego is rejected Source 31সোর্স 31. The Gatekeeper docs say that using Rego v1 syntax in a ConstraintTemplate is opt-in, and that by default only Rego v0 is allowed Source 37সোর্স 37.
Testing policies. OPA gives you a framework that you can use to write tests for your policies Source 30সোর্স 30. Tests are expressed as standard Rego rules with a convention that the rule name is prefixed with test_ Source 30সোর্স 30. The opa test subcommand runs all of the tests found in Rego files passed on the command line Source 30সোর্স 30. If the test rule is undefined or generates a non-true value, the test result is reported as FAIL Source 30সোর্স 30. If the test encounters a runtime error, the result is marked as an ERROR Source 30সোর্স 30. Tests prefixed with todo_ are reported as SKIPPED Source 30সোর্স 30. When you misspell a test name or run no test by accident, opa test still succeeds Source 30সোর্স 30. The docs say that --fail-on-empty is also useful in CI/CD pipelines to ensure that tests are actually being executed Source 30সোর্স 30. opa test can also report coverage for the policies under test Source 30সোর্স 30.
The command line. The opa eval option --fail exits with a non-zero exit code on an undefined or empty result and on errors Source 31সোর্স 31. The option --fail-defined exits with a non-zero exit code on a defined or non-empty result and on errors Source 31সোর্স 31. opa check checks Rego source files for parse and compilation errors Source 31সোর্স 31. If it succeeds, it produces no output Source 31সোর্স 31. If it fails, it outputs the errors and exits with a non-zero exit code Source 31সোর্স 31. The reference lists --strict, which enables compiler strict mode Source 31সোর্স 31. opa fmt --fail returns a non-zero exit code if a file would be reformatted Source 31সোর্স 31. opa fmt -l outputs the names of files that would change if formatted Source 31সোর্স 31.
The server and the REST API. The Data API takes POST /v1/data/{path} with a JSON body of the form {"input": ...} Source 32সোর্স 32. The request body contains an object that specifies a value for the input document Source 32সোর্স 32. Any additional top-level keys in the request body beyond input are treated as request metadata Source 32সোর্স 32. The server returns 200 if the path refers to an undefined document Source 32সোর্স 32. In that case, the response does not contain a result property Source 32সোর্স 32. If decision logging is enabled, the response has a decision_id field that uniquely identifies the decision Source 32সোর্স 32. Callers can use the identifier for correlation purposes Source 32সোর্স 32.
Decision logs. OPA can report decision logs to remote HTTP servers, using custom plugins, or to the console output, or to any combination of these Source 33সোর্স 33. The decision logs contain events that describe policy queries Source 33সোর্স 33. Each event includes the policy that was queried, the input to the query, bundle metadata, and other information that enables auditing and offline debugging of policy decisions Source 33সোর্স 33. When decision logging is enabled, the OPA server includes a decision_id field in API calls that return policy decisions Source 33সোর্স 33. The path field of an event holds the hierarchical policy decision path Source 33সোর্স 33. The input field holds the input data provided in the policy query Source 33সোর্স 33. The result field holds the policy decision returned to the client Source 33সোর্স 33.
OPA in Kubernetes admission control. With plain OPA, the Kubernetes API Server is configured to query OPA for admission control decisions when objects are created, updated, or deleted Source 34সোর্স 34. The API Server sends the entire Kubernetes object in the webhook request to OPA Source 34সোর্স 34. OPA evaluates the policies it has loaded using the admission review as input Source 34সোর্স 34. In that input, input.request.object contains the entire Kubernetes object Source 34সোর্স 34. Gatekeeper adds an extensible, parameterized policy library Source 34সোর্স 34. It also adds audit functionality Source 34সোর্স 34. Plain OPA and Kube-mgmt are alternatives that can be reached for if you want to use the management features of OPA, such as status logs, decision logs, and bundles Source 34সোর্স 34.
Gatekeeper constraint templates. ConstraintTemplates are made of two main elements Source 37সোর্স 37. One is the Rego or CEL policy code that defines the policy violation logic Source 37সোর্স 37. The other is the schema of the accompanying Constraint object, which represents an instantiation of a ConstraintTemplate Source 37সোর্স 37. The Gatekeeper docs show a violation rule that has a msg Source 37সোর্স 37. The docs say that Rego v1 syntax can only be used under targets[_].code[_] with engine: Rego and version: "v1" Source 37সোর্স 37.
gator. The gator CLI is a tool for evaluating Gatekeeper ConstraintTemplates and Constraints in a local environment Source 38সোর্স 38. gator test tests a set of Kubernetes objects against a set of Templates and Constraints Source 38সোর্স 38. The command returns violations when found and communicates success or failure via its exit status Source 38সোর্স 38. gator verify organizes tests into three levels: Suites, Tests, and Cases Source 38সোর্স 38. A Case defines an object to validate and whether the object is expected to pass validation Source 38সোর্স 38. The value of violations is either "yes", "no", or a non-negative integer Source 38সোর্স 38. If it is a non-negative integer, exactly that many violations must match Source 38সোর্স 38. The message field is a regular expression used to match the violation message Source 38সোর্স 38. To be valid, a Suite file must declare kind: Suite and an apiVersion Source 38সোর্স 38. gator verify silently ignores files which do not declare these Source 38সোর্স 38. The docs note that audit and gator test are different enforcement points, and that they do not have the AdmissionReview request metadata Source 38সোর্স 38.
OPA with Envoy and Istio. Envoy supports an External Authorization filter which calls an authorization service to check if the incoming request is authorized or not Source 35সোর্স 35. The OPA-Envoy plugin extends OPA with a gRPC server that implements the Envoy External Authorization API Source 35সোর্স 35. You can use it to enforce fine-grained, context-aware access control policies with Envoy without modifying your microservice Source 35সোর্স 35. The plugin has a dry-run option Source 35সোর্স 35. Its default is false Source 35সোর্স 35.
OPA with Terraform. OPA makes it possible to write policies that check the changes Terraform is about to make before it makes them Source 36সোর্স 36. OPA policies operate on the JSON plan generated by Terraform, which has certain limitations Source 36সোর্স 36. Some information may not be available at plan time Source 36সোর্স 36. The docs name unknown values, dynamic blocks, and function calls Source 36সোর্স 36. Before writing policies, you confirm that the information you need is available in the plan JSON output Source 36সোর্স 36. Terraform and Infrastructure as Code explains the plan. The tutorial did not run OPA on a Terraform plan.
বাংলা ব্যাখ্যা
Istio: দুটো plane। একটা Istio service mesh যৌক্তিকভাবে একটা data plane আর একটা control plane-এ ভাগ করা Source 9সোর্স 9। sidecar mode-এ data plane হলো sidecar হিসেবে বসানো বুদ্ধিমান proxy-র একটা সেট, Envoy Source 9সোর্স 9। এই proxy-গুলো microservice-গুলোর মধ্যে সব network যোগাযোগ মধ্যস্থতা আর নিয়ন্ত্রণ করে Source 9সোর্স 9। তারা mesh-এর সব traffic-এর telemetry-ও সংগ্রহ আর জানায় Source 9সোর্স 9। data plane traffic-এর সঙ্গে কেবল Envoy proxy-ই যোগাযোগ করে, Istio-র আর কোনো component নয় Source 9সোর্স 9। control plane traffic routing-এর জন্য proxy-গুলোকে পরিচালনা আর configure করে Source 9সোর্স 9।
Istiod। Istiod service discovery, configuration আর certificate management দেয় Source 9সোর্স 9। সে traffic আচরণ নিয়ন্ত্রণ করা উচ্চস্তরের routing rule-কে Envoy-নির্দিষ্ট configuration-এ রূপান্তর করে আর runtime-এ sidecar-গুলোতে ছড়িয়ে দেয় Source 9সোর্স 9। Istiod একটা Certificate Authority (CA)-র মতো কাজ করে আর data plane-এ নিরাপদ mTLS যোগাযোগের জন্য certificate তৈরি করে Source 9সোর্স 9। Istio docs বলে, sidecar proxy model আপনাকে একটা বিদ্যমান deployment-এ Istio-র সামর্থ্য যোগ করতে দেয়, architecture নতুন করে সাজাতে বা code নতুন করে লিখতে হয় না Source 9সোর্স 9।
Ambient mode। ambient mode-এ Istio তার features চালায় প্রতি node-এ একটা Layer 4 proxy দিয়ে, আর ঐচ্ছিকভাবে প্রতি namespace-এ একটা Layer 7 proxy দিয়ে Source 10সোর্স 10। এই স্তরভিত্তিক পদ্ধতিতে আপনি Istio ধাপে ধাপে গ্রহণ করতে পারেন Source 10সোর্স 10। Waypoint proxy শুধু ztunnel overlay-র চেয়ে ভারী Source 10সোর্স 10। তারা তবু অবকাঠামোর ambient component হিসেবে চলে, আর application pod বদলাতে হয় না Source 10সোর্স 10।
Traffic routing: virtual service আর destination rule। Virtual service আর destination rule হলো Istio-র traffic routing সামর্থ্যের মূল গাঁথুনি Source 11সোর্স 11। একটা virtual service আপনাকে ঠিক করতে দেয়, একটা Istio service mesh-এর ভেতরে কোনো service-এ request কীভাবে routing হবে Source 11সোর্স 11। প্রতিটা virtual service-এ থাকে এক সেট routing rule, যেগুলো ক্রমানুসারে মূল্যায়ন হয় Source 11সোর্স 11। একটা virtual service একটা service-এর বিভিন্ন সংস্করণে traffic পাঠাতে পারে, যেমন "২০% call নতুন সংস্করণে যায়" Source 11সোর্স 11। এতে একটা canary rollout সম্ভব হয়, যেখানে আপনি নতুন service সংস্করণে পাঠানো traffic-এর শতাংশ ধীরে ধীরে বাড়ান Source 11সোর্স 11। Destination rule আপনাকে পুরো destination service বা একটা নির্দিষ্ট service subset-কে call করার সময় Envoy-র traffic policy নিজের মতো সাজাতে দেয় Source 11সোর্স 11। কিছু ক্ষেত্রে virtual service-এর এই বৈশিষ্ট্যগুলো ব্যবহার করতে আপনাকে destination rule-ও সাজাতে হয়, কারণ destination rule-এই আপনি service subset ঠিক করেন Source 11সোর্স 11।
Gateway। Gateway প্রধানত ingress traffic পরিচালনায় ব্যবহৃত হয়, তবে আপনি egress gateway-ও সাজাতে পারেন Source 11সোর্স 11। একটা egress gateway আপনাকে mesh ছেড়ে যাওয়া traffic-এর জন্য একটা নির্দিষ্ট প্রস্থান node সাজাতে দেয় Source 11সোর্স 11। Istio কিছু আগে থেকে সাজানো gateway proxy deployment দেয়, যেগুলো আপনি ব্যবহার করতে পারেন, istio-ingressgateway আর istio-egressgateway Source 11সোর্স 11। demo installation ব্যবহার করলে দুটোই deploy হয় Source 11সোর্স 11। default profile-এ শুধু ingress gateway deploy হয় Source 11সোর্স 11।
Resilience: timeout, retry আর circuit breaker। timeout হলো একটা নির্দিষ্ট service-এর উত্তরের জন্য Envoy proxy-র যতক্ষণ অপেক্ষা করা উচিত, সেই সময় Source 11সোর্স 11। Istio-তে HTTP request-এর জন্য Envoy timeout ডিফল্টভাবে বন্ধ Source 11সোর্স 11। retry setting ঠিক করে, প্রথম call ব্যর্থ হলে Envoy proxy সর্বোচ্চ কতবার service-এ সংযোগের চেষ্টা করবে Source 11সোর্স 11। HTTP request-এর ডিফল্ট retry আচরণ হলো ত্রুটি ফেরত দেওয়ার আগে দুবার retry করা Source 11সোর্স 11। circuit breaker-এ আপনি একটা service-এর ভেতরের আলাদা আলাদা host-এ call-এর সীমা ঠিক করেন Source 11সোর্স 11। সেই সীমায় পৌঁছালে circuit breaker "trip" করে আর ওই host-এ আর সংযোগ দেয় না Source 11সোর্স 11। আপনি circuit breaker-এর threshold ঠিক করেন destination rule-এ Source 11সোর্স 11।
Fault injection। fault injection হলো এমন একটা পরীক্ষার পদ্ধতি, যা একটা system-এ ত্রুটি ঢোকায়, যাতে নিশ্চিত হওয়া যায় সে ত্রুটির অবস্থা সইতে আর সেখান থেকে সেরে উঠতে পারে Source 11সোর্স 11। network স্তরে packet দেরি করানো বা pod মেরে ফেলার মতো অন্য উপায়ের উল্টো, Istio আপনাকে application স্তরে fault ঢোকাতে দেয় Source 11সোর্স 11। আপনি দুই ধরনের fault ঢোকাতে পারেন, দুটোই একটা virtual service দিয়ে সাজানো Source 11সোর্স 11। Delay হলো সময়ের ব্যর্থতা, যা বাড়ানো network latency বা অতিভারাক্রান্ত upstream service-এর নকল করে Source 11সোর্স 11। Abort হলো crash-এর ব্যর্থতা, যা upstream service-এর ব্যর্থতার নকল করে Source 11সোর্স 11। বর্তমানে fault injection configuration একই virtual service-এ retry বা timeout configuration-এর সঙ্গে একত্র করা যায় না Source 11সোর্স 11। Istio-র failure recovery features application-এর কাছে সম্পূর্ণ স্বচ্ছ Source 11সোর্স 11। আপনি application code-এও failure recovery policy ঠিক করলে দুটো স্বাধীনভাবে কাজ করে, তাই সংঘাত বাধতে পারে Source 11সোর্স 11।
Mutual TLS আর identity। Peer authentication service-to-service authentication-এর জন্য ব্যবহৃত হয়, সংযোগকারী client-কে যাচাই করতে Source 12সোর্স 12। Istio transport authentication-এর জন্য mutual TLS দেয় একটা full stack সমাধান হিসেবে, যা service code না বদলেই চালু করা যায় Source 12সোর্স 12। mutual TLS-এ Istio একটা client-এর বাইরে যাওয়া traffic client-এর স্থানীয় sidecar Envoy-তে ঘুরিয়ে দেয় Source 12সোর্স 12। client-পক্ষের Envoy server-পক্ষের Envoy-র সঙ্গে একটা mutual TLS handshake শুরু করে Source 12সোর্স 12। server-পক্ষের Envoy request অনুমোদন করে Source 12সোর্স 12। Istio client আর server দুই পক্ষের জন্য ন্যূনতম TLS সংস্করণ হিসেবে TLSv1_2 ঠিক করে Source 12সোর্স 12।
Permissive mode। Istio mutual TLS-এর একটা permissive mode আছে, যা একটা service-কে একই সময়ে plaintext traffic আর mutual TLS traffic দুটোই নিতে দেয় Source 12সোর্স 12। docs বলে, এই feature mutual TLS-এ ওঠার অভিজ্ঞতা অনেক ভালো করে Source 12সোর্স 12। operator ধীরে ধীরে client-এর Istio sidecar বসিয়ে আর সাজিয়ে সেগুলোকে mutual TLS traffic পাঠানোর উপযোগী করতে পারেন Source 12সোর্স 12। client-এর configuration শেষ হলে operator server-কে শুধু mutual TLS mode-এ সাজাতে পারেন Source 12সোর্স 12।
Authorization policy। Authorization policy ALLOW, DENY আর CUSTOM action সমর্থন করে Source 12সোর্স 12। Istio মিলে যাওয়া policy খোঁজে স্তরে স্তরে, এই ক্রমে: CUSTOM, DENY, তারপর ALLOW Source 12সোর্স 12। আপনি একই workload-এ একাধিক authorization policy প্রয়োগ করলে Istio সেগুলোকে যোগ করে প্রয়োগ করে Source 12সোর্স 12। deny policy allow policy-র ওপর অগ্রাধিকার পায় Source 12সোর্স 12। একটা authorization policy-তে থাকে একটা selector, একটা action আর rule-এর একটা তালিকা Source 12সোর্স 12। selector ঠিক না করা থাকলে policy-টা তার নিজের namespace-এর সব workload-এ প্রযোজ্য হয় Source 12সোর্স 12। "deny by default" আচরণ কেবল তখনই প্রযোজ্য, যখন workload-এ ALLOW action-সহ অন্তত একটা authorization policy আছে Source 12সোর্স 12। docs বলে, allow-nothing policy দিয়ে শুরু করে workload-এ আরও বেশি প্রবেশাধিকার খুলতে ধাপে ধাপে আরও ALLOW policy যোগ করা একটা ভালো security অনুশীলন Source 12সোর্স 12।
Telemetry। Istio একটা mesh-এর ভেতরের সব service যোগাযোগের জন্য বিস্তারিত telemetry তৈরি করে Source 13সোর্স 13। সে metrics, distributed trace আর access log তৈরি করে Source 13সোর্স 13। monitoring-এর চার "golden signal" হলো latency, traffic, errors আর saturation Source 13সোর্স 13। Istio-র standard metrics ডিফল্টভাবে Prometheus-এ export হয় Source 13সোর্স 13। Istio Envoy proxy-র মাধ্যমে distributed tracing সমর্থন করে Source 13সোর্স 13। proxy-গুলো যে application-গুলোর হয়ে কাজ করে, তাদের হয়ে স্বয়ংক্রিয়ভাবে trace span তৈরি করে, শুধু চায় application যেন উপযুক্ত request context এগিয়ে দেয় Source 13সোর্স 13। Istio বেশ কিছু tracing backend সমর্থন করে, যার মধ্যে আছে Zipkin, Jaeger আর OpenTelemetry সমর্থন করা অনেক tool ও service Source 13সোর্স 13। ডিফল্টভাবে Istio Envoy-র তৈরি statistics-এর কেবল একটা ছোট উপসেট চালু রাখে Source 13সোর্স 13।
Profile। built-in deployment profile শুধু Helm values override-এর সেট Source 14সোর্স 14। default profile IstioOperator API-র default setting অনুযায়ী component চালু করে Source 14সোর্স 14। demo profile Istio-র কার্যকারিতা দেখানোর জন্য বানানো, সীমিত resource দিয়ে Source 14সোর্স 14। demo profile উচ্চমাত্রার tracing আর access logging চালু করে, তাই performance test-এর উপযোগী নয় Source 14সোর্স 14। minimal profile default profile-এর মতোই, কিন্তু শুধু control plane component install হয় Source 14সোর্স 14। ambient profile ambient mode দিয়ে শুরু করতে সাহায্য করার জন্য বানানো Source 14সোর্স 14। empty profile কিছুই deploy করে না Source 14সোর্স 14। istioctl manifest generate command একটা Istio install manifest তৈরি করে আর ডিফল্টভাবে console-এ ছাপে Source 16সোর্স 16।
configuration পরীক্ষা: istioctl analyze। istioctl analyze একটা diagnostic tool, যা আপনার Istio configuration-এর সম্ভাব্য সমস্যা ধরতে পারে Source 15সোর্স 15। সে একটা চালু cluster-এর বিরুদ্ধে বা স্থানীয় configuration file-এর একটা সেটের বিরুদ্ধে চলতে পারে Source 15সোর্স 15। সে দুটোর সমন্বয়ের বিরুদ্ধেও চলতে পারে, যাতে cluster-এ পরিবর্তন প্রয়োগের আগেই সমস্যা ধরা যায় Source 15সোর্স 15। স্থানীয় file-এর একটা সেট বিশ্লেষণ করার সময় file-সেটটা সম্পূর্ণ স্বয়ংসম্পূর্ণ হওয়ার কথা Source 15সোর্স 15। স্থানীয় file বিশ্লেষণ করতে --use-kube=false flag যোগ করুন Source 15সোর্স 15। reference-এ আছে সব namespace বিশ্লেষণের জন্য --all-namespaces (-A), আর একটা namespace-এর জন্য --namespace (-n) Source 16সোর্স 16। --failure-threshold option ঠিক করে বিশ্লেষণের কোন severity স্তরে একটা শূন্য-নয় exit code বসবে Source 16সোর্স 16। --output option নেয় log, json বা yaml-এর একটা, ডিফল্ট log Source 16সোর্স 16। -L option চালানোর জন্য পাওয়া analyzer-গুলোর তালিকা দেয় Source 16সোর্স 16।
analysis message। IST0101 message-এর level Error, আর সে ঘটে যখন একটা Istio resource এমন আরেকটা resource-এর কথা বলে, যা নেই Source 17সোর্স 17। docs বলে, Istio যখন উল্লিখিত resource খুঁজে পায় না, তখন এটা ত্রুটি ঘটায় Source 17সোর্স 17। যেমন একটা VirtualService এমন একটা gateway-র কথা বলে, যা নেই Source 17সোর্স 17। docs একটা পরীক্ষামূলক feature-ও বর্ণনা করে, যা কেবল মূল্যায়নের উদ্দেশ্যে তৈরি Source 15সোর্স 15। তাতে Istio-কে configuration বিতরণের পাশাপাশি বিশ্লেষণ চালাতে সাজানো যায় Source 15সোর্স 15। সেক্ষেত্রে validation message প্রভাবিত Istio resource-এর status subresource-এ লেখা হয় Source 15সোর্স 15। docs বলে, এটা istioctl analyze-এর বিকল্প নয় Source 15সোর্স 15।
Falco: event ঢোকে, alert বের হয়। Falco একটা system-এর কার্যকলাপ নজরে রাখতে syscall ব্যবহার করে Source 18সোর্স 18। সে runtime-এ kernel থেকে Linux syscall পার্স করে Source 18সোর্স 18। সে stream-কে একটা rules engine-এর বিরুদ্ধে যাচাই করে, আর কোনো rule ভাঙলে alert দেয় Source 18সোর্স 18। Falco-র নজরদারির সামর্থ্য syscall-এ সীমিত নয়, কারণ plugin দিয়ে তাকে আরও অনেক ধরনের source থেকে data নিতে বাড়ানো যায় Source 18সোর্স 18। userspace program signal সামলায়, Falco driver থেকে তথ্য পার্স করে আর alert পাঠায় Source 18সোর্স 18। configuration ঠিক করে Falco কীভাবে চলবে, কোন rule যাচাই করবে আর alert কীভাবে দেবে Source 18সোর্স 18।
Event source। Falco স্বাভাবিকভাবে syscall event source সমর্থন করে, যা ডিফল্টভাবে চালু আর driver-এর মাধ্যমে Linux Kernel থেকে event নেয় Source 19সোর্স 19। plugin system Falco-কে নতুন event source দিয়ে তার সামর্থ্য বাড়াতে দেয় Source 19সোর্স 19। প্রতিটা event source একটা আলাদা thread-এ চলে Source 19সোর্স 19। rule-গুলো event source অনুযায়ী ভাগ করা, অর্থাৎ প্রতিটা rule একটা নির্দিষ্ট source-এ প্রযোজ্য আর কেবল সেই source-এর event-এ চালু হয় Source 19সোর্স 19। Falco আলাদা source-এর event-কে পরস্পরের সঙ্গে সম্পর্কিত করা সমর্থন করে না Source 19সোর্স 19। ডিফল্টভাবে Falco সব পরিচিত source থেকে event সংগ্রহ চালু রাখে Source 19সোর্স 19। plugin-ভিত্তিক deployment-এ আপনি syscall source স্পষ্ট করে বন্ধ করেন, অথবা শুধু যে plugin-ভিত্তিক source চান সেগুলো চালু করেন Source 19সোর্স 19। অচেনা source বা সব source বন্ধ করার চেষ্টা ত্রুটি ঘটায় Source 19সোর্স 19।
Driver আর privilege। একটা driver kernelspace-এ চলে Source 20সোর্স 20। driver syscall event source দেয় Source 20সোর্স 20। docs বলে, কয়েকটা driver সমর্থিত Source 20সোর্স 20। তারা তালিকা দেয় modern eBPF probe, যা ডিফল্ট, আর kernel module-এর Source 20সোর্স 20। kernel module-এর পূর্ণ privilege লাগে, আর সে Linux capability নিয়ে চলতে পারে না Source 20সোর্স 20। modern eBPF probe-এর জন্য কোনো নির্দিষ্ট kernel সংস্করণ লাগে না Source 20সোর্স 20। সাধারণত ৫.৮ বা তার ওপরের সব সংস্করণ যথেষ্ট Source 20সোর্স 20। দুটো প্রধান প্রয়োজনীয় feature হলো BPF ring buffer সমর্থন আর BTF প্রকাশ করা একটা kernel Source 20সোর্স 20। tarball page বলে, ডিফল্টভাবে Falco Linux Kernel থেকে event নেয়, যার জন্য Falco-কে privileged হতে হয় Source 26সোর্স 26। driver ছাড়া syscall source ব্যবহার করতে আপনি Falco চালান -o engine.kind=nodriver দিয়ে Source 19সোর্স 19। এই mode-এ Falco syscall event প্রক্রিয়া করে চলে, কিন্তু সেগুলো ধরতে driver ব্যবহার করে না Source 19সোর্স 19।
Rules file। একটা Falco rules file হলো একটা YAML file, যাতে প্রধানত তিন ধরনের উপাদান থাকে Source 22সোর্স 22। Rule হলো সেই শর্ত, যার অধীনে একটা alert তৈরি হওয়া উচিত Source 22সোর্স 22। প্রতিটা rule-এর সঙ্গে থাকে একটা বর্ণনামূলক output string, যা alert-এর সঙ্গে পাঠানো হয় Source 22সোর্স 22। Macro হলো rule-এর condition-এর টুকরো, যা rule-এর ভেতরে আর এমনকি অন্য macro-র ভেতরেও আবার ব্যবহার করা যায় Source 22সোর্স 22। List হলো item-এর সংগ্রহ, যা rule, macro বা অন্য list-এ রাখা যায় Source 22সোর্স 22। rule আর macro-র উল্টো, list-কে filtering expression হিসেবে পার্স করা যায় না Source 22সোর্স 22। একটা rules file-এ required_engine_version-ও থাকতে পারে, যা rules content আর Falco engine সংস্করণের সামঞ্জস্য ট্র্যাক করে Source 22সোর্স 22।
একটা rule। একটা rule হলো rules file-এর অংশ একটা YAML object, যার সংজ্ঞায় অন্তত rule, desc, condition, output আর priority field থাকে Source 23সোর্স 23। rule-এর মূল অংশ হলো condition field Source 23সোর্স 23। condition হলো condition syntax দিয়ে লেখা একটা Boolean predicate Source 23সোর্স 23। rule output হলো একটা string, যাতে condition-এর একই field % চিহ্ন দিয়ে বসানো যায়, printf-এর মতো interpolation-এর জন্য Source 23সোর্স 23। প্রতিটা Falco rule-এর একটা priority আছে, যা জানায় rule ভাঙাটা কতটা গুরুতর Source 23সোর্স 23। পাওয়া priority-গুলো হলো EMERGENCY, ALERT, CRITICAL, ERROR, WARNING, NOTICE, INFORMATIONAL আর DEBUG Source 23সোর্স 23। একটা rule-এ priority-র সঙ্গে অন্য rule-কে override করা বা কোন ক্রমে rule চালু হবে তা বাছার কোনো সম্পর্ক নেই Source 23সোর্স 23। সেই ক্রম নিয়ন্ত্রণের উপায় হলো rule-গুলো যে ক্রমে সংজ্ঞায়িত হয়, আর তাই load হয়, সেই ক্রম বদলানো Source 23সোর্স 23।
Condition আর event type। docs একটা condition-এর উদাহরণ দেয়, যা কোনো container-এ bash shell চালালেই alert তোলে, container.id != host and proc.name = bash Source 23সোর্স 23। যেহেতু এই condition-এ কোনো system call-এর clause নেই, সে কেবল event-এর metadata যাচাই করবে Source 23সোর্স 23। সেই কারণে একটা container-এ bash shell চালু হলে Falco সেই shell-এর চালানো প্রতিটা syscall-এর জন্য event ছাপে Source 23সোর্স 23। একটা container-এ shell সফলভাবে চালু হওয়ার প্রতিটা ঘটনার জন্যই শুধু alert পেতে হলে আপনি condition-এ উপযুক্ত event type যোগ করেন Source 23সোর্স 23। docs-এর উদাহরণে connection কোনো container-এর বাইরে ঘটলে %container.image.repository field ঠিক করা হতো না, আর তার জায়গায় <NA> দেখানো হয় Source 23সোর্স 23।
প্রথম মিলই জেতে। Falco docs বলে, ডিফল্টভাবে Falco প্রতিটা event type-এর জন্য rule প্রয়োগ করে "first match wins" ভিত্তিতে Source 24সোর্স 24। Falco Release 0.36.0 থেকে আপনি configuration বদলে rule_matching: all করতে পারেন Source 24সোর্স 24। এই বদল নিশ্চিত করে যে একই event type-এর rule-গুলো একে অপরকে override করতে পারে না, ফলে অসংগত logging এড়ানো যায় Source 24সোর্স 24। docs সতর্ক করে, এই বদলে CPU ব্যবহার বাড়তে পারে Source 24সোর্স 24।
Command line। -c option configuration file ঠিক করে, আর ডিফল্ট /etc/falco/falco.yaml Source 25সোর্স 25। -V (--validate) option নির্দিষ্ট rules file পড়ে, load হওয়া rule যাচাই করে আর বেরিয়ে যায় Source 25সোর্স 25। একাধিক file যাচাই করতে আপনি তাকে কয়েকবার দিতে পারেন Source 25সোর্স 25। --dry-run option event প্রক্রিয়া না করে Falco চালায়, আর configuration ও rule-এ কোনো ত্রুটি আছে কি না যাচাই করতে সাহায্য করতে পারে Source 25সোর্স 25। -L option সব rule-এর নাম আর বর্ণনা দেখায় আর বেরিয়ে যায় Source 25সোর্স 25। -r option লোড করার একটা rules file বা directory ঠিক করে, আর শুধু .yml বা .yaml extension-এর file বিবেচনা করা হয় Source 25সোর্স 25। -o option একটা configuration option-এর মান ঠিক করে, আর সে configuration file-এর মান override করে Source 25সোর্স 25। --list option সংজ্ঞায়িত সব field-এর তালিকা দেয় আর বেরিয়ে যায় Source 25সোর্স 25।
Plugin, falcoctl আর output। Plugin হলো shared library, যা একটা নথিভুক্ত API মেনে চলে Source 21সোর্স 21। তারা নতুন event source যোগ করতে পারে, যেগুলো filtering expression বা Falco rule দিয়ে মূল্যায়ন করা যায় Source 21সোর্স 21। তারা নতুন field সংজ্ঞায়িত করার সামর্থ্য যোগ করতে পারে, যা event থেকে তথ্য বের করে Source 21সোর্স 21। k8s_audit source দেয় k8saudit plugin Source 19সোর্স 19। docs বলে, এই source-এর plugin-গুলো সবাই একই rule-এর সেট ব্যবহার করে Source 19সোর্স 19। Falcoctl আপনাকে সহজে rule আর plugin install করতে আর Falco-র প্রশাসনিক কাজ করতে দেয় Source 18সোর্স 18। সে Falco-র সঙ্গেই বান্ডল করা Source 18সোর্স 18। Alert হলো সাজানো যায় এমন downstream action, যা stdout-এ log করার মতো সরল থেকে একটা endpoint-এ HTTP request পাঠানোর মতো জটিল পর্যন্ত হতে পারে Source 18সোর্স 18।
tarball। Falco Linux-এ চলে আর x86_64 ও aarch64 architecture-এর জন্য পাওয়া যায় Source 26সোর্স 26। Falco তার সঙ্গের bundled plugin-সহ GLIBC 2.28 বা নতুন সংস্করণ চায় Source 26সোর্স 26। tarball page Falco install করে archive খুলে /-এ কপি করে Source 26সোর্স 26। Falco .tar.gz archive-এ Systemd setup নেই Source 26সোর্স 26। configuration file থাকে /etc/falco/falco.yaml-এ Source 26সোর্স 26। আপনি falco binary-তে option দিয়েও default configuration override করতে পারেন Source 26সোর্স 26। টিউটোরিয়াল archive /-এ কপি করেনি। সে archive run folder-এ খুলেছে আর -c ও -o দিয়েছে।
Rule, maturity-স্তর আর event-generator। Falco rules repository বলে, falco_rules.yaml file-এর maturity_stable rule Falco release package-এ থাকে Source 40সোর্স 40। অন্য maturity-স্তরের rule আলাদাভাবে release হয়, আর তাদের স্পষ্ট install আর সম্ভবত নিজের মতো সাজানো লাগে Source 40সোর্স 40। repository যোগ করে, Rules Maturity Framework সম্প্রদায়ের পক্ষ থেকে একটা best-effort চেষ্টা, আর কোনো rule আপনার ব্যবহারের জন্য কাজের কি না তা শেষ পর্যন্ত আপনাকেই ঠিক করতে হবে Source 40সোর্স 40। event-generator tool এমন নানা সন্দেহজনক কাজ তৈরি করে, যা Falco ruleset ধরে Source 39সোর্স 39। তার k8saudit events collection best-effort ভিত্তিতে রক্ষণাবেক্ষণ হয় আর পুরোপুরি কাজ নাও করতে পারে Source 39সোর্স 39।
OPA: service থেকে আলাদা policy। OPA docs বলে, আজকাল policy প্রায়ই সেই software service-এর hard-coded একটা feature, যাকে সে নিয়ন্ত্রণ করে Source 28সোর্স 28। OPA আপনাকে policy-কে সেই software service থেকে আলাদা করতে দেয়, যাতে policy-র দায়িত্বে থাকা মানুষ service থেকে আলাদাভাবে তা পড়তে, লিখতে, বিশ্লেষণ করতে, version করতে, বিতরণ করতে আর পরিচালনা করতে পারেন Source 28সোর্স 28। software service-এর উচিত policy declarative উপায়ে ঠিক করতে দেওয়া, recompile বা redeploy ছাড়াই যেকোনো সময় হালনাগাদ করতে দেওয়া, আর স্বয়ংক্রিয়ভাবে প্রয়োগ করা Source 28সোর্স 28। Authorization-কে মাঝে মাঝে Authentication-এর সঙ্গে গুলিয়ে ফেলা হয় Source 28সোর্স 28।
Rego। Rego declarative, তাই policy লেখকরা মন দিতে পারেন query কী ফেরত দেওয়া উচিত তাতে, query কীভাবে চালানো উচিত তাতে নয় Source 29সোর্স 29। সব module-এ data আর input document import করার অন্তর্নিহিত statement আছে Source 29সোর্স 29। যে expression কোনো undefined মান নিয়ে কথা বলে, সেও undefined Source 29সোর্স 29। default keyword policy-কে পূর্ণ সংজ্ঞার rule থেকে তৈরি document-এর একটা default মান ঠিক করতে দেয় Source 29সোর্স 29। with keyword query-কে input document বা data document-এর ভেতরের মান, অথবা built-in function, প্রোগ্রাম করে ঠিক করতে দেয় Source 29সোর্স 29। Rego-তে variable ডিফল্টভাবে existentially quantified Source 29সোর্স 29।
Rego v1 আর v0। OPA CLI reference-এ --v0-compatible আর --v1-compatible option আছে Source 31সোর্স 31। opa fmt-এর ক্ষেত্রে v1 Rego v1-এ formatted হয়, আর v0 Rego প্রত্যাখ্যাত হয় Source 31সোর্স 31। opa fmt --v0-compatible দিলে v0 Rego v0-তে formatted হয়, আর v1 Rego প্রত্যাখ্যাত হয় Source 31সোর্স 31। Gatekeeper docs বলে, ConstraintTemplate-এ Rego v1 syntax ব্যবহার ঐচ্ছিক, আর ডিফল্টভাবে কেবল Rego v0 অনুমোদিত Source 37সোর্স 37।
policy পরীক্ষা। OPA আপনাকে আপনার policy-র জন্য test লেখার একটা framework দেয় Source 30সোর্স 30। test লেখা হয় সাধারণ Rego rule হিসেবে, এই রীতিতে যে rule-এর নামের আগে test_ থাকে Source 30সোর্স 30। opa test subcommand command line-এ দেওয়া Rego file-এ পাওয়া সব test চালায় Source 30সোর্স 30। test rule undefined হলে বা non-true মান তৈরি করলে test-এর ফল FAIL বলে জানানো হয় Source 30সোর্স 30। test-এ runtime error হলে ফল ERROR চিহ্নিত হয় Source 30সোর্স 30। todo_ দিয়ে শুরু হওয়া test SKIPPED বলে জানানো হয় Source 30সোর্স 30। আপনি কোনো test-এর নাম ভুল লিখলে বা ভুলে কোনো test না চালালে opa test তবু সফল হয় Source 30সোর্স 30। docs বলে, --fail-on-empty CI/CD pipeline-এও কাজে লাগে, যাতে নিশ্চিত হওয়া যায় test আসলেই চলছে Source 30সোর্স 30। opa test পরীক্ষাধীন policy-র coverage-ও জানাতে পারে Source 30সোর্স 30।
command line। opa eval-এর --fail option undefined বা খালি ফলে আর ত্রুটিতে শূন্য-নয় exit code দিয়ে বেরোয় Source 31সোর্স 31। --fail-defined option defined বা খালি-নয় ফলে আর ত্রুটিতে শূন্য-নয় exit code দিয়ে বেরোয় Source 31সোর্স 31। opa check Rego source file-এ parse আর compile-এর ত্রুটি খোঁজে Source 31সোর্স 31। সফল হলে সে কোনো output দেয় না Source 31সোর্স 31। ব্যর্থ হলে সে ত্রুটি ছাপে আর শূন্য-নয় exit code দিয়ে বেরোয় Source 31সোর্স 31। reference-এ --strict আছে, যা compiler strict mode চালু করে Source 31সোর্স 31। কোনো file নতুন করে format করা হতো এমন হলে opa fmt --fail শূন্য-নয় exit code ফেরত দেয় Source 31সোর্স 31। opa fmt -l formatting করলে যে file-গুলো বদলে যেত তাদের নাম ছাপে Source 31সোর্স 31।
server আর REST API। Data API নেয় POST /v1/data/{path}, যার JSON body-র রূপ {"input": ...} Source 32সোর্স 32। request body-তে থাকে একটা object, যা input document-এর মান ঠিক করে Source 32সোর্স 32। request body-তে input-এর বাইরে বাড়তি যেকোনো top-level key request metadata হিসেবে গণ্য হয় Source 32সোর্স 32। path কোনো undefined document-কে নির্দেশ করলে server 200 ফেরত দেয় Source 32সোর্স 32। সেক্ষেত্রে response-এ result property থাকে না Source 32সোর্স 32। decision logging চালু থাকলে response-এ decision_id field থাকে, যা সিদ্ধান্তটাকে অনন্যভাবে শনাক্ত করে Source 32সোর্স 32। caller সম্পর্ক মেলানোর জন্য এই identifier ব্যবহার করতে পারে Source 32সোর্স 32।
decision log। OPA decision log রিপোর্ট করতে পারে remote HTTP server-এ, custom plugin দিয়ে, অথবা console output-এ, অথবা এগুলোর যেকোনো সমন্বয়ে Source 33সোর্স 33। decision log-এ থাকে এমন event, যা policy query বর্ণনা করে Source 33সোর্স 33। প্রতিটা event-এ থাকে কোন policy query হয়েছে, query-র input, bundle metadata আর অন্য তথ্য, যা policy সিদ্ধান্তের audit আর offline debugging সম্ভব করে Source 33সোর্স 33। decision logging চালু থাকলে OPA server যে API call policy সিদ্ধান্ত ফেরত দেয় তাতে decision_id field যোগ করে Source 33সোর্স 33। event-এর path field-এ থাকে policy সিদ্ধান্তের স্তরবদ্ধ path Source 33সোর্স 33। input field-এ থাকে policy query-তে দেওয়া input data Source 33সোর্স 33। result field-এ থাকে client-কে ফেরত দেওয়া policy সিদ্ধান্ত Source 33সোর্স 33।
Kubernetes admission control-এ OPA। plain OPA-র ক্ষেত্রে Kubernetes API Server এমনভাবে সাজানো হয়, যাতে object তৈরি, হালনাগাদ বা মোছার সময় সে admission control সিদ্ধান্তের জন্য OPA-কে query করে Source 34সোর্স 34। API Server webhook request-এ পুরো Kubernetes object OPA-কে পাঠায় Source 34সোর্স 34। OPA তার load করা policy মূল্যায়ন করে admission review-কে input হিসেবে নিয়ে Source 34সোর্স 34। সেই input-এ input.request.object-এ থাকে পুরো Kubernetes object Source 34সোর্স 34। Gatekeeper যোগ করে একটা বাড়ানো যায় এমন, parameter-যুক্ত policy library Source 34সোর্স 34। সে audit functionality-ও যোগ করে Source 34সোর্স 34। OPA-র management feature, যেমন status log, decision log আর bundle, ব্যবহার করতে চাইলে plain OPA আর Kube-mgmt-কে বিকল্প হিসেবে বেছে নেওয়া যেতে পারে Source 34সোর্স 34।
Gatekeeper constraint template। ConstraintTemplate দুটো প্রধান উপাদান দিয়ে তৈরি Source 37সোর্স 37। একটা হলো Rego বা CEL policy code, যা policy ভাঙার যুক্তি ঠিক করে Source 37সোর্স 37। অন্যটা হলো সঙ্গের Constraint object-এর schema, যা একটা ConstraintTemplate-এর instance প্রকাশ করে Source 37সোর্স 37। Gatekeeper docs একটা violation rule দেখায়, যাতে একটা msg আছে Source 37সোর্স 37। docs বলে, Rego v1 syntax কেবল targets[_].code[_]-এর অধীনে engine: Rego আর version: "v1" দিয়ে ব্যবহার করা যায় Source 37সোর্স 37।
gator। gator CLI হলো একটা স্থানীয় পরিবেশে Gatekeeper ConstraintTemplate আর Constraint মূল্যায়নের tool Source 38সোর্স 38। gator test একগুচ্ছ Kubernetes object-কে একগুচ্ছ Template আর Constraint-এর বিরুদ্ধে পরীক্ষা করে Source 38সোর্স 38। command violation পেলে তা ফেরত দেয় আর exit status দিয়ে সাফল্য বা ব্যর্থতা জানায় Source 38সোর্স 38। gator verify test-কে তিন স্তরে সাজায়: Suite, Test আর Case Source 38সোর্স 38। একটা Case ঠিক করে কোন object যাচাই হবে আর object-টা যাচাইয়ে পাস করবে বলে আশা করা হয় কি না Source 38সোর্স 38। violations-এর মান হয় "yes", "no" অথবা একটা অঋণাত্মক পূর্ণসংখ্যা Source 38সোর্স 38। মান পূর্ণসংখ্যা হলে ঠিক ততগুলো violation মিলতে হবে Source 38সোর্স 38। message হলো violation message মেলানোর একটা regular expression Source 38সোর্স 38। বৈধ হতে হলে একটা Suite file-এ kind: Suite আর একটা apiVersion ঘোষণা করতে হবে Source 38সোর্স 38। যে file-এ এগুলো ঘোষণা নেই, gator verify সেগুলো নীরবে উপেক্ষা করে Source 38সোর্স 38। docs উল্লেখ করে, audit আর gator test আলাদা enforcement point, আর তাদের কাছে AdmissionReview request metadata নেই Source 38সোর্স 38।
Envoy আর Istio-র সঙ্গে OPA। Envoy একটা External Authorization filter সমর্থন করে, যা একটা authorization service-কে ডেকে দেখে আসা request অনুমোদিত কি না Source 35সোর্স 35। OPA-Envoy plugin OPA-কে বাড়ায় একটা gRPC server দিয়ে, যা Envoy External Authorization API বাস্তবায়ন করে Source 35সোর্স 35। আপনি তাকে ব্যবহার করে আপনার microservice না বদলে Envoy-র সঙ্গে সূক্ষ্ম, context-সচেতন access control policy প্রয়োগ করতে পারেন Source 35সোর্স 35। plugin-এ একটা dry-run option আছে Source 35সোর্স 35। তার default false Source 35সোর্স 35।
Terraform-এর সঙ্গে OPA। OPA এমন policy লেখা সম্ভব করে, যা Terraform যে পরিবর্তন করতে যাচ্ছে তা করার আগেই যাচাই করে Source 36সোর্স 36। OPA policy কাজ করে Terraform-এর তৈরি JSON plan-এর ওপর, যার কিছু সীমাবদ্ধতা আছে Source 36সোর্স 36। plan করার সময় কিছু তথ্য নাও পাওয়া যেতে পারে Source 36সোর্স 36। docs নাম দেয় unknown value, dynamic block আর function call-এর Source 36সোর্স 36। policy লেখার আগে আপনি নিশ্চিত করেন, আপনার দরকারি তথ্য plan JSON output-এ পাওয়া যায় Source 36সোর্স 36। Terraform and Infrastructure as Code plan ব্যাখ্যা করে। টিউটোরিয়াল কোনো Terraform plan-এর ওপর OPA চালায়নি।
Try it
The tutorial ran steps 1 to 15 on 2026-11-20 at 02:24 (+06) on Linux 7.0.0-43-generic. The versions were istioctl 1.32.0, OPA 1.22.4, gator v3.23.1, Falco 0.45.2, and falcoctl 0.14.3. The helpers were Python 3.14.4, curl 8.18.0, and bash 5.3.9. The output on this page is from the tutorial's run. Each step ran in a subshell of the runner, in one new folder, with a new, empty HOME. The page shows the folder of the run as /work.
The run needs no cluster, no Docker, and no root rights. istioctl reads local files only (--use-kube=false). OPA and gator work on local files. The OPA server listens on 127.0.0.1:18181 only. Falco reads audit events from a file, and it loads no kernel driver. Step 14 pulls three artifacts from ghcr.io. After the run, the real home folder had no new entry, and the folder of the tools had no new or removed file. The port 18181 was free, and the run left no opa or falco process. The empty home folder of the run held one entry after the steps: .sigstore, with 23 files. The tutorial did not check which command made it.
The choices that no source gives are the tutorial's own. They are the Istio files (the namespace shop, the service reviews, and the subsets v1 and v2), the policy pods.rego and its tests, the Gatekeeper template qanoprivileged, the rule QA write to a sensitive file, the three audit events, and the port 18181. The tutorial did not run Istio in a cluster. The run has no sidecar, no ambient data plane, no traffic, and no mutual TLS handshake. It did not run the admission webhook or the audit of Gatekeeper in a cluster. It did not run OPA with Envoy or with a Terraform plan. It did not run Falco with a driver. No syscall event was read. It did not run the event-generator. It ran on Linux only.
Install the tools. The tutorial's install script put the four tools in the home folder of the user, with no sudo. It took each archive from the release place of its project. istioctl and gator came from GitHub releases, OPA from openpolicyagent.org/downloads, and Falco from download.falco.org. The OPA docs say that checksums for all binaries are available in the download path Source 27সোর্স 27. The script compared the SHA-256 of the OPA binary with that file. For istioctl and gator, it compared the SHA-256 of the archive with the checksum file of the same GitHub release. That choice is the tutorial's own.
The tutorial found no checksum file for the Falco archive. The runner asked for ten file names next to the archive on download.falco.org, and only the archive and its .asc file answered with 200:
200 falco-0.45.2-x86_64.tar.gz
200 falco-0.45.2-x86_64.tar.gz.asc
404 falco-0.45.2-x86_64.tar.gz.sig
404 falco-0.45.2-x86_64.tar.gz.sha256
404 falco-0.45.2-x86_64.tar.gz.sha256sum
404 falco-0.45.2-x86_64.tar.gz.sha512
404 falco-0.45.2-x86_64.tar.gz.md5
404 falco-0.45.2-x86_64.tar.gz.cert
404 falco-0.45.2-x86_64.tar.gz.pem
404 falco-0.45.2-x86_64.tar.gz.bundleThe Falco packages page tells you to trust the falcosecurity GPG key Source 41সোর্স 41. It gives the key file at https://falco.org/repo/falcosecurity-packages.asc Source 41সোর্স 41. The script imported that key into a throw-away GnuPG home and checked the .asc file against the archive. The signature was good, and its primary key was 478B2FBBC75F4237B731DA4365106822B35B1B1F. The script did not compare that fingerprint with a second source. For istioctl, OPA, and gator, the checksum file and the archive come from the same host. For Falco, the key comes from falco.org and the archive from download.falco.org. The tutorial treats these checks as a way to find a damaged or swapped archive, and not as proof of who built it. The record of the install is:
istioctl 1.32.0; sha256 4771175dec92527cd90ddc7edb3b3abcb32ca2f3bc32b31aa31e0b12ad36f897
opa v1.22.4; sha256 b76461cf4db0f77946ef557d727a1da5d7a22ba930844678c9be0bebd2c9d0f6
gator v3.23.1; sha256 c268d7b809c9fe59a110ab0bf7c296ab00b0b6c894c209cd15e94194590291bb
falco 0.45.2; sha256 b2e9961e51601095765c6c644329673e6af2f06c02357d0e77da0f680e4910da; signature good, primary key 478B2FBBC75F4237B731DA4365106822B35B1B1FIn your own terminal, put istioctl, opa, and gator on your PATH. Unpack the Falco archive in the folder of the practice, and put its usr/bin folder on your PATH. The steps call falco and falcoctl by name. The tarball page of the Falco docs unpacks the archive with tar and copies it to / Source 26সোর্স 26. The tutorial did not copy anything to /. The page also says that Falco with its bundled plugins requires GLIBC 2.28 or newer Source 26সোর্স 26. The glibc of the tutorial's machine is 2.43.
1. Check the tools. Run this in the folder of the practice. The first command unpacks the Falco archive:
tar -xzf falco-0.45.2-x86_64.tar.gz
istioctl version --remote=false
opa version | head -n 1
gator --version
falco --version
falcoctl versionOutput of the tutorial's run:
client version: 1.32.0
Version: 1.22.4
gator version v3.23.1 (Feature State: beta), opa/v1.17.1, frameworks/v0.0.0-20260616163050-e1eaa1bf6d62
Falco version: 0.45.2
Libs version: 0.26.1
Plugin API: 3.12.0
Engine: 0.65.0
Driver:
API version: 11.0.0
Schema version: 4.3.0
Default driver: 11.0.1+driver
Client Version: 0.14.3istioctl version --remote=falseprintedclient version: 1.32.0. The reference says to use--remote=falseto suppress the control plane check Source 16সোর্স 16.opa versionprintedVersion: 1.22.4on its first line. The step cut the output there withhead -n 1.gator --versionprintedv3.23.1 (Feature State: beta), and the same line hasopa/v1.17.1. Theopabinary of the run is 1.22.4. The two numbers differ, and the tutorial did not find out what theopa/v1.17.1in the gator line stands for.falco --versionprinted 0.45.2 with the version of the libs, the plugin API, and the engine.falcoctl versionprintedClient Version: 0.14.3.- These commands print versions only. The Falco docs say that falcoctl is bundled together with Falco Source 18সোর্স 18.
2. Render the install manifests of five profiles. Run:
for p in default demo minimal ambient empty; do
istioctl manifest generate --set profile=$p > manifest-$p.yaml
echo "$p: $(grep -c '^kind:' manifest-$p.yaml) objects; workloads: $(awk '/^kind: (Deployment|DaemonSet)$/ {k=$2; w=1; next} w && /^ name:/ {print k "/" $2; w=0}' manifest-$p.yaml | tr '\n' ' ')"
doneOutput of the tutorial's run:
default: 39 objects; workloads: Deployment/istio-ingressgateway Deployment/istiod
demo: 42 objects; workloads: Deployment/istio-egressgateway Deployment/istio-ingressgateway Deployment/istiod
minimal: 33 objects; workloads: Deployment/istiod
ambient: 44 objects; workloads: DaemonSet/istio-cni-node DaemonSet/ztunnel Deployment/istiod
empty: 0 objects; workloads: - The loop wrote the manifest of each profile to a file and counted the lines that start with
kind:. The count of objects and the list of workloads are the tutorial's own way to compare profiles. - The reference says that
istioctl manifest generategenerates an Istio install manifest and outputs to the console by default Source 16সোর্স 16. The step wrote the output to files, and it applied nothing. - The
emptyprofile gave 0 objects. The docs say that the empty profile deploys nothing Source 14সোর্স 14. - The
minimalprofile gave 33 objects, and its only workload isistiod. The docs say that the minimal profile is the same as the default profile, but only the control plane components are installed Source 14সোর্স 14. - The
defaultprofile gave 39 objects, withistio-ingressgatewayandistiod. Thedemoprofile gave 42 objects, withistio-egressgatewayadded. The traffic management page says that both gateways are deployed with the demo installation, and just the ingress gateway with the default profile Source 11সোর্স 11. - The
ambientprofile gave 44 objects. Its workloads are the DaemonSetsistio-cni-nodeandztunnel, andistiod. The ambient overview names the ztunnel secure overlay as the base of ambient mode Source 10সোর্স 10.
3. Check a good Istio file. The command block writes mesh-good.yaml, and then it analyzes the file:
cat > mesh-good.yaml <<'EOF'
apiVersion: v1
kind: Namespace
metadata:
name: shop
labels:
istio-injection: enabled
---
apiVersion: v1
kind: Service
metadata:
name: reviews
namespace: shop
spec:
selector:
app: reviews
ports:
- name: http
port: 9080
---
apiVersion: networking.istio.io/v1
kind: Gateway
metadata:
name: shop-gateway
namespace: shop
spec:
selector:
istio: ingressgateway
servers:
- port:
number: 80
name: http
protocol: HTTP
hosts:
- "shop.example.com"
---
apiVersion: networking.istio.io/v1
kind: VirtualService
metadata:
name: reviews
namespace: shop
spec:
hosts:
- reviews
http:
- route:
- destination:
host: reviews
subset: v1
weight: 80
- destination:
host: reviews
subset: v2
weight: 20
---
apiVersion: networking.istio.io/v1
kind: DestinationRule
metadata:
name: reviews
namespace: shop
spec:
host: reviews
subsets:
- name: v1
labels:
version: v1
- name: v2
labels:
version: v2
EOF
cat > mesh-bad.yaml <<'EOF'
apiVersion: v1
kind: Namespace
metadata:
name: shop
---
apiVersion: v1
kind: Service
metadata:
name: reviews
namespace: shop
spec:
selector:
app: reviews
ports:
- name: http
port: 9080
---
apiVersion: networking.istio.io/v1
kind: VirtualService
metadata:
name: reviews
namespace: shop
spec:
hosts:
- reviews
gateways:
- bogus-gateway
http:
- route:
- destination:
host: reviews
subset: v3
---
apiVersion: networking.istio.io/v1
kind: DestinationRule
metadata:
name: reviews
namespace: shop
spec:
host: reviews
subsets:
- name: v1
labels:
version: v1
EOF
istioctl analyze --use-kube=false -A mesh-good.yaml
echo "exit=$?"Output of the tutorial's run:
✔ No validation issues found when analyzing mesh-good.yaml.
exit=0- The file has a Namespace
shopwith the labelistio-injection: enabled, a Servicereviews, a Gateway, a VirtualService, and a DestinationRule. The VirtualService sends 80 % of the requests to the subsetv1and 20 % tov2. The DestinationRule defines both subsets. - The file also has the Namespace and the Service that the other objects refer to. The docs say that a set of local files is expected to be fully self-contained Source 15সোর্স 15.
istioctl analyze --use-kube=false -A mesh-good.yamlprintedNo validation issues found when analyzing mesh-good.yaml.and exited with 0. The docs show the same kind of message for a namespace Source 15সোর্স 15.- The tutorial's files are its own. They are small, and they are not a model of a real mesh.
4. Check a bad file, with and without a namespace option. Step 3 wrote mesh-bad.yaml as well. Run:
echo "--- no namespace option"
istioctl analyze --use-kube=false mesh-bad.yaml
echo "exit=$?"
echo "--- -A (all namespaces)"
istioctl analyze --use-kube=false -A mesh-bad.yaml
echo "exit=$?"
echo "--- -n shop"
istioctl analyze --use-kube=false -n shop mesh-bad.yaml
echo "exit=$?"Output of the tutorial's run:
--- no namespace option
✔ No validation issues found when analyzing mesh-bad.yaml.
exit=0
--- -A (all namespaces)
Error [IST0101] (VirtualService shop/reviews mesh-bad.yaml:27) Referenced gateway not found: "bogus-gateway"
Error [IST0101] (VirtualService shop/reviews mesh-bad.yaml:31) Referenced host+subset in destinationrule not found: "reviews+v3"
Warning [IST0132] (VirtualService shop/reviews mesh-bad.yaml:27) one or more host [reviews] defined in VirtualService shop/reviews not found in Gateway shop/bogus-gateway.
Error: Analyzers found issues when analyzing all namespaces.
See https://istio.io/v1.32/docs/reference/config/analysis for more information about causes and resolutions.
exit=79
--- -n shop
Error [IST0101] (VirtualService shop/reviews mesh-bad.yaml:27) Referenced gateway not found: "bogus-gateway"
Error [IST0101] (VirtualService shop/reviews mesh-bad.yaml:31) Referenced host+subset in destinationrule not found: "reviews+v3"
Warning [IST0132] (VirtualService shop/reviews mesh-bad.yaml:27) one or more host [reviews] defined in VirtualService shop/reviews not found in Gateway shop/bogus-gateway.
Error: Analyzers found issues when analyzing namespace: shop.
See https://istio.io/v1.32/docs/reference/config/analysis for more information about causes and resolutions.
exit=79mesh-bad.yamlhas a VirtualService that names the gatewaybogus-gatewayand the subsetv3. Its DestinationRule has the subsetv1only.- With no namespace option,
istioctl analyze --use-kube=false mesh-bad.yamlprintedNo validation issues found when analyzing mesh-bad.yaml.and exited with 0. The tutorial did not find out why. The reference lists--namespacewith an empty default Source 16সোর্স 16. - With
-A, it printed three messages andError: Analyzers found issues when analyzing all namespaces.The exit code was 79. The docs show the same sentence for one namespace Source 15সোর্স 15. - With
-n shop, it printed the same three messages andError: Analyzers found issues when analyzing namespace: shop.The exit code was 79. - Each message has a level, a code, the kind and the name of the resource, the file and the line, and a text.
- The two
IST0101errors name a gateway and a host with a subset that do not exist. The docs say that this message occurs when an Istio resource references another resource that does not exist Source 17সোর্স 17. The list of messages names it ReferencedResourceNotFound Source 42সোর্স 42. - The list of messages names
IST0132VirtualServiceHostNotFoundInGateway Source 42সোর্স 42. - The exit code was 79 in the tutorial's run. The tutorial did not look up the meaning of the number.
5. Severity, exit codes, and JSON output. Run:
# A copy of the good file in which the VirtualService names the gateway shop-gateway, which does not list the host "reviews".
sed 's/^ - reviews$/&\n gateways:\n - shop-gateway/' mesh-good.yaml > mesh-warn.yaml
istioctl analyze --use-kube=false -A mesh-warn.yaml
for level in Error Warning Info; do
istioctl analyze --use-kube=false -A --failure-threshold $level mesh-warn.yaml > /dev/null 2>&1
echo "mesh-warn.yaml, --failure-threshold $level: exit=$?"
done
istioctl analyze --use-kube=false -A mesh-bad.yaml > /dev/null 2>&1
echo "mesh-bad.yaml, default output: exit=$?"
istioctl analyze --use-kube=false -A -o json mesh-bad.yaml > bad.json 2> bad.err
echo "mesh-bad.yaml, -o json: exit=$?"
python3 -c 'import json; print([(m["code"], m["level"]) for m in json.load(open("bad.json"))])'
echo "analyzers: $(istioctl analyze -L | grep -c '^\* ')"Output of the tutorial's run:
Warning [IST0132] (VirtualService shop/reviews mesh-warn.yaml:45) one or more host [reviews] defined in VirtualService shop/reviews not found in Gateway shop/shop-gateway.
mesh-warn.yaml, --failure-threshold Error: exit=0
mesh-warn.yaml, --failure-threshold Warning: exit=79
mesh-warn.yaml, --failure-threshold Info: exit=79
mesh-bad.yaml, default output: exit=79
mesh-bad.yaml, -o json: exit=0
[('IST0101', 'Error'), ('IST0101', 'Error'), ('IST0132', 'Warning')]
analyzers: 54mesh-warn.yamlismesh-good.yamlwith two more lines in the VirtualService. They name the gatewayshop-gateway, which does not list the hostreviews. The analysis printed one warning,IST0132, at line 45.- The reference says that
--failure-thresholdsets the severity level of analysis at which to set a non-zero exit code Source 16সোর্স 16. The valid values are Info, Warning, and Error, and the default isErrorSource 16সোর্স 16. - On the file with the warning only, the threshold
Errorgave the exit code 0. The thresholdsWarningandInfogave 79. Onmesh-bad.yaml, the default threshold gave 79. - With
-o json, the exit code formesh-bad.yamlwas 0 in the tutorial's run. The filebad.jsonhad the same three messages:IST0101with the levelErrortwice, andIST0132with the levelWarning. The tutorial did not find out why the exit code was 0. In this run, the exit code of the JSON output did not show the errors, and the level of each message did. istioctl analyze -Llisted 54 analyzers in this version. The reference says that-Llists the analyzers available to run Source 16সোর্স 16. The step counted the lines that start with*, which is the tutorial's own way to count.
6. Security files: mutual TLS and authorization policies. The block writes mesh-security.yaml and a copy with a typo, and it analyzes both:
cat > mesh-security.yaml <<'EOF'
apiVersion: v1
kind: Namespace
metadata:
name: shop
labels:
istio-injection: enabled
---
apiVersion: security.istio.io/v1
kind: PeerAuthentication
metadata:
name: default
namespace: shop
spec:
mtls:
mode: STRICT
---
apiVersion: security.istio.io/v1
kind: AuthorizationPolicy
metadata:
name: allow-frontend-get
namespace: shop
spec:
selector:
matchLabels:
app: reviews
action: ALLOW
rules:
- from:
- source:
namespaces: ["frontend"]
to:
- operation:
methods: ["GET"]
---
apiVersion: security.istio.io/v1
kind: AuthorizationPolicy
metadata:
name: deny-admin
namespace: shop
spec:
selector:
matchLabels:
app: reviews
action: DENY
rules:
- to:
- operation:
paths: ["/admin"]
EOF
istioctl analyze --use-kube=false -A mesh-security.yaml
echo "exit=$?"
# A copy in which the action of the last policy is misspelled. sed removes the date and time of the log line, so that the output is the same in each run.
sed 's/action: DENY/action: DENYY/' mesh-security.yaml > mesh-security-typo.yaml
istioctl analyze --use-kube=false -A mesh-security-typo.yaml 2>&1 | sed -E 's/^[0-9T:.Z-]+\t//'
echo "exit=${PIPESTATUS[0]}"Output of the tutorial's run:
Warning [IST0133] (AuthorizationPolicy shop/deny-admin mesh-security.yaml:35) Schema validation warning: configured AuthorizationPolicy will deny all traffic to TCP ports under its scope due to the use of only HTTP attributes in a DENY rule; it is recommended to explicitly specify the port
exit=0
warn file error processing mesh-security-typo.yaml[3]: failed parsing JSON for built-in type: unknown value "\"DENYY\"" for enum istio.security.v1beta1.AuthorizationPolicy.Action - skipping
Error(s) adding files: 1 error occurred:
* errors parsing content "mesh-security-typo.yaml": 1 error occurred:
* error processing mesh-security-typo.yaml[3]: failed parsing JSON for built-in type: unknown value "\"DENYY\"" for enum istio.security.v1beta1.AuthorizationPolicy.Action
No validation issues found when analyzing all namespaces (but 1 file could not be parsed).
Error: Some files couldn't be parsed.
exit=65mesh-security.yamlhas the namespaceshopwith injection enabled, a PeerAuthentication nameddefaultwith the modeSTRICT, an ALLOW policy namedallow-frontend-get, and a DENY policy nameddeny-admin. Both policies select the workload with the labelapp: reviews. The ALLOW policy lets in the GET requests from the namespacefrontend. The DENY policy has the path/admin.- The analysis printed one warning,
IST0133, for the DENY policy at line 35, and it exited with 0. The list of messages namesIST0133SchemaWarning Source 42সোর্স 42. The text of the message says that the policy will deny all traffic to TCP ports under its scope due to the use of only HTTP attributes in a DENY rule. It recommends to specify the port explicitly. - The security page says that certain fields and conditions are only applicable to HTTP workloads Source 12সোর্স 12. The
pathsfield in theoperationsection is one of them Source 12সোর্স 12. The page also says that Istio will ignore the HTTP-only fields if you use any of them for a TCP workload Source 12সোর্স 12. The tutorial sent no traffic. It did not check what the policy does with TCP traffic. - The ALLOW policy uses the field
namespacesundersource. The page says that mutual TLS must be enabled before using any of the following fields in the authorization policy Source 12সোর্স 12. They are theprincipalsandnotPrincipalsfields and thenamespacesandnotNamespacesfields, all under thesourcesection Source 12সোর্স 12. The file has the PeerAuthentication in the modeSTRICTin the same namespace. The analysis printed no message about the ALLOW policy. - In the copy
mesh-security-typo.yaml, the action of the DENY policy isDENYY.istioctlprinted awarnline. It says that it failed parsing JSON formesh-security-typo.yaml[3], with an unknown value for the enum of the action, and that it was skipping it. Then it printedNo validation issues found when analyzing all namespaces (but 1 file could not be parsed).andError: Some files couldn't be parsed.The exit code was 65. - The line
No validation issues foundwas printed although the policy with the typo was not analyzed. Only the last line and the exit code showed the problem. - The reference has the option
--ignore-unknown, which does not complain about un-parseable input documents, for cases where analyze should run only on k8s compliant inputs Source 16সোর্স 16. The tutorial did not use it.
7. Write a policy and ask OPA. The block writes the policy pods.rego and two Pods as JSON, and it runs opa eval:
cat > pods.rego <<'EOF'
package qa.pods
# A pod is denied when one of its containers runs privileged.
deny contains msg if {
some c in input.spec.containers
c.securityContext.privileged == true
msg := sprintf("container %v must not run privileged", [c.name])
}
default allow := false
allow if count(deny) == 0
EOF
cat > bad-pod.json <<'EOF'
{"apiVersion": "v1", "kind": "Pod", "metadata": {"name": "qa-privileged", "namespace": "default"}, "spec": {"containers": [{"name": "c1", "image": "busybox:1.36", "securityContext": {"privileged": true}}]}}
EOF
sed 's/qa-privileged/qa-plain/; s/"privileged": true/"privileged": false/' bad-pod.json > good-pod.json
opa eval --format pretty -d pods.rego -i bad-pod.json 'data.qa.pods.deny'
opa eval --format pretty -d pods.rego -i bad-pod.json 'data.qa.pods.allow'
opa eval --format pretty -d pods.rego -i good-pod.json 'data.qa.pods.allow'
opa eval --fail-defined -d pods.rego -i bad-pod.json 'data.qa.pods.deny[_]' > /dev/null
echo "--fail-defined, bad pod: exit=$?"
opa eval --fail-defined -d pods.rego -i good-pod.json 'data.qa.pods.deny[_]' > /dev/null
echo "--fail-defined, good pod: exit=$?"Output of the tutorial's run:
[
"container c1 must not run privileged"
]
false
true
--fail-defined, bad pod: exit=1
--fail-defined, good pod: exit=0pods.regois the tutorial's own policy. Its ruledenyis a set with one message for each container that hasprivileged == true. Its ruleallowisfalseby default, and it istruewhendenyis empty. The docs say that thedefaultkeyword lets a policy define a default value for documents produced by rules with complete definitions Source 29সোর্স 29.- The input of the query is the Pod that
-igives. The docs say that all modules contain implicit statements which import the data and input documents Source 29সোর্স 29. - For
bad-pod.json,data.qa.pods.denyprinted a list with one message,container c1 must not run privileged, anddata.qa.pods.allowprintedfalse. Forgood-pod.json,allowprintedtrue. - The reference says that
--fail-definedexits with a non-zero exit code on a defined or non-empty result Source 31সোর্স 31. The querydata.qa.pods.deny[_]has a result for the bad Pod, and the exit code was 1. For the good Pod it has no result, and the exit code was 0.
8. Test the policy. The block writes the tests pods_test.rego, then it runs opa test on the good tests, on a failing copy, and on a copy with misspelled tests:
cat > pods_test.rego <<'EOF'
package qa.pods_test
import data.qa.pods
test_privileged_pod_is_denied if {
not pods.allow with input as {"spec": {"containers": [{"name": "c1", "securityContext": {"privileged": true}}]}}
}
test_plain_pod_is_allowed if {
pods.allow with input as {"spec": {"containers": [{"name": "c1", "securityContext": {"privileged": false}}]}}
}
test_pod_without_security_context_is_allowed if {
pods.allow with input as {"spec": {"containers": [{"name": "c1"}]}}
}
EOF
# The run times are removed with sed and the lines are sorted, so that the output is the same in each run.
opa test -v pods.rego pods_test.rego | grep -E 'PASS|FAIL' | sed -E 's/ \([^)]*\)$//' | sort
echo "opa test: exit=${PIPESTATUS[0]}"
# The same policy with a test that expects the wrong answer.
mkdir failing
cp pods.rego failing/
sed 's/^\tnot pods.allow with input/\tpods.allow with input/' pods_test.rego > failing/pods_test.rego
opa test failing/ | sed -E 's/ \([^)]*\)$//'
echo "opa test failing/: exit=${PIPESTATUS[0]}"
# A copy in which the tests are misspelled: the prefix is tset_ and not test_.
mkdir misspelled
cp pods.rego misspelled/
sed 's/^test_/tset_/' pods_test.rego > misspelled/pods_test.rego
opa test misspelled/
echo "opa test misspelled/: exit=$?"
opa test --fail-on-empty misspelled/
echo "opa test --fail-on-empty misspelled/: exit=$?"
# Coverage of the policy file by the tests
opa test --coverage pods.rego pods_test.rego | python3 -c 'import json, sys; d = json.load(sys.stdin)["files"]["pods.rego"]; print("pods.rego covered lines:", d["covered_lines"], "not covered:", d.get("not_covered_lines", 0), "coverage:", d["coverage"])'Output of the tutorial's run:
PASS: 3/3
data.qa.pods_test.test_plain_pod_is_allowed: PASS
data.qa.pods_test.test_pod_without_security_context_is_allowed: PASS
data.qa.pods_test.test_privileged_pod_is_denied: PASS
opa test: exit=0
failing/pods_test.rego:5:
data.qa.pods_test.test_privileged_pod_is_denied: FAIL
--------------------------------------------------------------------------------
PASS: 2/3
FAIL: 1/3
opa test failing/: exit=2
opa test misspelled/: exit=0
no tests were run
opa test --fail-on-empty misspelled/: exit=1
pods.rego covered lines: 6 not covered: 0 coverage: 100pods_test.regohas three tests. A privileged Pod is not allowed, a plain Pod is allowed, and a Pod with nosecurityContextis allowed. The docs say that tests are standard Rego rules with a name that has the prefixtest_Source 30সোর্স 30. Each test sets the input withwith input as. Thewithkeyword lets queries specify values nested under the input document Source 29সোর্স 29.opa test -v pods.rego pods_test.regoprintedPASS: 3/3and onePASSline for each test, and it exited with 0. The step removed the run times and sorted the lines.- In
failing/, the first test expects the privileged Pod to be allowed.opa testprintedFAILfor that test, withFAIL: 1/3andPASS: 2/3, and it exited with 2. The docs say that the result of a test is FAIL when the test rule is undefined or generates a non-true value Source 30সোর্স 30. - In
misspelled/, the prefix istset_.opa testprinted nothing and exited with 0. The docs say that when you misspell a test name or run no test by accident,opa testwill still succeed, and that--fail-on-emptymakes it fail Source 30সোর্স 30. With--fail-on-empty, it printedno tests were runand exited with 1. opa test --coverageprinted a JSON report. The step read three numbers forpods.regofrom it: 6 covered lines, 0 lines not covered, and a coverage of 100. The docs say that the coverage report includes all of the lines evaluated and not evaluated in the Rego files provided on the command line Source 30সোর্স 30.
9. Check, format, and the old syntax. Run:
cat > unused.rego <<'EOF'
package qa.unused
import data.qa.nothing
allow if {
x := 1
input.ok == true
}
EOF
opa check unused.rego
echo "opa check: exit=$?"
opa check --strict unused.rego
echo "opa check --strict: exit=$?"
printf 'package qa.fmt\n\nallow if {\ninput.ok == true\n}\n' > unformatted.rego
opa fmt --fail --list unformatted.rego
echo "opa fmt --fail --list, unformatted file: exit=$?"
opa fmt --fail --list pods.rego
echo "opa fmt --fail --list, formatted file: exit=$?"
# A policy in the old (v0) syntax: no "if" before the body, no "contains" in the set rule.
cat > v0.rego <<'EOF'
package qa.v0
deny[msg] {
c := input.spec.containers[_]
c.securityContext.privileged == true
msg := sprintf("container %v must not run privileged", [c.name])
}
EOF
opa eval --format pretty -d v0.rego -i bad-pod.json 'data.qa.v0.deny'
echo "opa eval, v0 file: exit=$?"
opa eval --v0-compatible --format pretty -d v0.rego -i bad-pod.json 'data.qa.v0.deny'
echo "opa eval --v0-compatible, v0 file: exit=$?"Output of the tutorial's run:
opa check: exit=0
2 errors occurred:
unused.rego:3: rego_compile_error: import data.qa.nothing unused
unused.rego:6: rego_compile_error: assigned var x unused
opa check --strict: exit=1
unformatted.rego
unexpected diff
opa fmt --fail --list, unformatted file: exit=2
opa fmt --fail --list, formatted file: exit=0
2 errors occurred:
v0.rego:3: rego_parse_error: `if` keyword is required before rule body
v0.rego:3: rego_parse_error: `contains` keyword is required for partial set rules
opa eval, v0 file: exit=2
[
"container c1 must not run privileged"
]
opa eval --v0-compatible, v0 file: exit=0unused.regoimportsdata.qa.nothing, and it assignsx := 1, and it uses neither.opa check unused.regoprinted nothing and exited with 0. The reference says that ifchecksucceeds in parsing and compiling the files, no output is produced Source 31সোর্স 31.opa check --strictprinted two errors,import data.qa.nothing unusedandassigned var x unused, and it exited with 1. The reference lists--strictas the option that enables the compiler strict mode Source 31সোর্স 31.opa fmt --fail --liston an unformatted file printed the file name andunexpected diff, and it exited with 2. Onpods.regoit printed nothing and exited with 0. The reference says that with--fail, the commandfmtreturns a non-zero exit code if a file would be reformatted Source 31সোর্স 31. It says that-loutputs the names of files that would change Source 31সোর্স 31.v0.regouses the old syntax. It has noifbefore the rule body and nocontainsin the rule of a set. OPA 1.22.4 printed two parse errors and exited with 2. With--v0-compatible, the same file worked, and it printed the message. The reference lists--v0-compatibleas the option that opts in to the OPA features and behaviors prior to the OPA v1.0 release Source 31সোর্স 31.- The Gatekeeper docs say that using Rego v1 syntax in a ConstraintTemplate is opt-in, and that by default only Rego v0 is allowed Source 37সোর্স 37. The template of step 11 uses the old syntax.
10. Run the OPA server and read its decision log. The step starts the server in the background, sends four requests with curl, stops the server, and reads the log:
opa run --server --addr 127.0.0.1:18181 --set decision_logs.console=true --log-level error pods.rego > opa-server.log 2>&1 &
OPA_PID=$!
for i in $(seq 1 50); do curl -s -o /dev/null http://127.0.0.1:18181/health && break; sleep 0.1; done
echo "health: $(curl -s http://127.0.0.1:18181/health)"
echo "--- bad pod, wrapped in the input key"
curl -s -X POST http://127.0.0.1:18181/v1/data/qa/pods -H 'Content-Type: application/json' -d "{\"input\": $(cat bad-pod.json)}" | sed -E 's/"decision_id":"[^"]*"/"decision_id":"..."/'
echo
echo "--- good pod, wrapped in the input key"
curl -s -X POST http://127.0.0.1:18181/v1/data/qa/pods/allow -H 'Content-Type: application/json' -d "{\"input\": $(cat good-pod.json)}" | sed -E 's/"decision_id":"[^"]*"/"decision_id":"..."/'
echo
echo "--- bad pod, NOT wrapped in the input key"
curl -s -X POST http://127.0.0.1:18181/v1/data/qa/pods/allow -H 'Content-Type: application/json' -d "$(cat bad-pod.json)" | sed -E 's/"decision_id":"[^"]*"/"decision_id":"..."/'
echo
echo "--- a path that no policy defines"
curl -s -X POST http://127.0.0.1:18181/v1/data/qa/nothing -H 'Content-Type: application/json' -d '{"input": {}}' | sed -E 's/"decision_id":"[^"]*"/"decision_id":"..."/'
echo
kill $OPA_PID
wait $OPA_PID 2> /dev/null
echo "--- decision log (the console lines of the server)"
python3 -c '
import json
for line in open("opa-server.log"):
d = json.loads(line)
print(d["msg"], "| path:", d["path"], "| result:", json.dumps(d.get("result", "undefined")), "| input logged:", "input" in d, "| custom.request_metadata logged:", "request_metadata" in d.get("custom", {}))
'Output of the tutorial's run:
health: {}
--- bad pod, wrapped in the input key
{"decision_id":"...","result":{"allow":false,"deny":["container c1 must not run privileged"]}}
--- good pod, wrapped in the input key
{"decision_id":"...","result":true}
--- bad pod, NOT wrapped in the input key
{"decision_id":"...","result":true,"warning":{"code":"api_usage_warning","message":"'input' key missing from the request"}}
--- a path that no policy defines
{"decision_id":"..."}
--- decision log (the console lines of the server)
Decision Log | path: qa/pods | result: {"allow": false, "deny": ["container c1 must not run privileged"]} | input logged: True | custom.request_metadata logged: False
Decision Log | path: qa/pods/allow | result: true | input logged: True | custom.request_metadata logged: False
Decision Log | path: qa/pods/allow | result: true | input logged: False | custom.request_metadata logged: True
Decision Log | path: qa/nothing | result: "undefined" | input logged: True | custom.request_metadata logged: False- The server listens on
127.0.0.1:18181. The docs say that local console logging of decisions can be enabled via theconsoleconfig option Source 33সোর্স 33. They showdecision_logs: console: truefor it Source 33সোর্স 33. The tutorial gave the same setting with--set decision_logs.console=true. It set--log-level errortoo, and the log file held decision log lines only. The step waited for/health, which printed{}. - The Data API takes
POST /v1/data/{path}with a JSON body of the form{"input": ...}Source 32সোর্স 32. The first request sent the bad Pod ininputto/v1/data/qa/pods. The result had both rules:allowwasfalse, anddenyhad the message. The step replaced eachdecision_idwith.... - The second request sent the good Pod to
/v1/data/qa/pods/allow, and the result wastrue. - The third request sent the bad Pod as the whole body, with no
inputkey. The result wastrue, with the warning'input' key missing from the request. The policy allowed a privileged Pod in this request. The REST page says that any additional top-level keys in the request body beyondinputare treated as request metadata Source 32সোর্স 32. The tutorial did not trace the query, and it does not say why the policy answeredtrue. - The fourth request asked for a path that no policy defines, and the response had no
resultkey. The docs say that the server returns 200 if the path refers to an undefined document Source 32সোর্স 32. They say that the response will not contain a result property in this case Source 32সোর্স 32. The step did not print the status code. - The decision log had four lines, one for each request. The
pathfield holds the hierarchical policy decision path Source 33সোর্স 33. Theinputfield holds the input data provided in the policy query Source 33সোর্স 33. Theresultfield holds the policy decision returned to the client Source 33সোর্স 33. - The third line had no
inputand hadcustom.request_metadata. The REST page says that request metadata is included in decision log events under the custom.request_metadata field Source 32সোর্স 32. The fourth line had noresultkey, and the step printedundefinedfor it. - The step stopped the server with
killandwait. After the run, the port 18181 was free, and noopaprocess was left.
11. Test a Gatekeeper template with gator. The block writes a ConstraintTemplate, a Constraint, two Pods, and three more files, and it runs gator test and gator verify:
cat > template.yaml <<'EOF'
apiVersion: templates.gatekeeper.sh/v1
kind: ConstraintTemplate
metadata:
name: qanoprivileged
spec:
crd:
spec:
names:
kind: QANoPrivileged
targets:
- target: admission.k8s.gatekeeper.sh
rego: |
package qanoprivileged
violation[{"msg": msg}] {
c := input.review.object.spec.containers[_]
c.securityContext.privileged == true
msg := sprintf("container <%v> must not run privileged", [c.name])
}
EOF
cat > constraint.yaml <<'EOF'
apiVersion: constraints.gatekeeper.sh/v1beta1
kind: QANoPrivileged
metadata:
name: no-privileged-pods
spec:
match:
kinds:
- apiGroups: [""]
kinds: ["Pod"]
EOF
cat > bad-pod.yaml <<'EOF'
apiVersion: v1
kind: Pod
metadata:
name: qa-privileged
namespace: default
spec:
containers:
- name: c1
image: busybox:1.36
securityContext:
privileged: true
EOF
sed 's/qa-privileged/qa-plain/; s/privileged: true/privileged: false/' bad-pod.yaml > good-pod.yaml
gator test -f template.yaml -f constraint.yaml -f bad-pod.yaml
echo "gator test, bad pod: exit=$?"
gator test -f template.yaml -f constraint.yaml -f good-pod.yaml
echo "gator test, good pod: exit=$?"
cat > suite.yaml <<'EOF'
kind: Suite
apiVersion: test.gatekeeper.sh/v1alpha1
tests:
- name: no-privileged
template: template.yaml
constraint: constraint.yaml
cases:
- name: privileged-pod
object: bad-pod.yaml
assertions:
- violations: 1
message: must not run privileged
- name: plain-pod
object: good-pod.yaml
assertions:
- violations: no
EOF
# A copy in which the second case expects a violation that does not happen.
sed 's/violations: no/violations: yes/' suite.yaml > suite-wrong.yaml
# A file that is not a Suite.
printf 'tests: []\n' > not-a-suite.yaml
# The run times are removed with sed, so that the output is the same in each run.
for f in suite.yaml suite-wrong.yaml not-a-suite.yaml; do
echo "--- gator verify $f"
gator verify $f 2>&1 | sed -E 's/\t\([0-9.]+s\)$//; s/\t[0-9.]+s$//'
echo "exit=${PIPESTATUS[0]}"
doneOutput of the tutorial's run:
v1/Pod default/qa-privileged: ["no-privileged-pods"] Message: "container <c1> must not run privileged"
gator test, bad pod: exit=1
gator test, good pod: exit=0
--- gator verify suite.yaml
ok suite.yaml
PASS
exit=0
--- gator verify suite-wrong.yaml
--- FAIL: plain-pod
unexpected number of violations: got 0 violations but want at least 1: got messages []
--- FAIL: no-privileged
FAIL suite-wrong.yaml
FAIL
Error: FAIL
exit=1
--- gator verify not-a-suite.yaml
PASS
exit=0template.yamlis a ConstraintTemplate namedqanoprivilegedwith the kindQANoPrivileged. It has one target,admission.k8s.gatekeeper.sh, and a Rego ruleviolationin the old syntax.constraint.yamlis a Constraint namedno-privileged-podsthat matches Pods. The docs say that ConstraintTemplates are made of two main elements Source 37সোর্স 37. One is the policy code, and the other is the schema of the Constraint Source 37সোর্স 37. In the Rego, the object under review isinput.review.object. The docs listinput.reviewas the variable that contains the input request object under review Source 37সোর্স 37.gator testtests a set of Kubernetes objects against a set of Templates and Constraints Source 38সোর্স 38. For the bad Pod, it printed one violation line with the messagecontainer <c1> must not run privileged, and the exit code was 1. For the good Pod, it printed nothing, and the exit code was 0. The docs say that the command returns violations when found and communicates success or failure via its exit status Source 38সোর্স 38.suite.yamlhas one test with two cases. The caseprivileged-podexpectsviolations: 1and the messagemust not run privileged. The caseplain-podexpectsviolations: no. The docs say thatviolationsis either "yes", "no", or a non-negative integer Source 38সোর্স 38. They say thatmessageis a regular expression used to match the violation message Source 38সোর্স 38.gator verify suite.yamlprintedok suite.yamlandPASS, and the exit code was 0.- In
suite-wrong.yaml, the second case expectsviolations: yes.gator verifyprintedFAILfor the caseplain-podwith the textunexpected number of violations: got 0 violations but want at least 1. It printedError: FAIL, and the exit code was 1. not-a-suite.yamlis the texttests: [].gator verifyprintedPASSand exited with 0. The docs say that a valid Suite file must declarekind: Suiteand anapiVersion, and thatgator verifysilently ignores files which do not declare these Source 38সোর্স 38. The tutorial did not check whatgator verifydid with this file.
12. Validate Falco rules. The block prints a few lines of the shipped rules file, validates it with and without the container plugin, writes the tutorial's own rules file, validates it, and lists its rules:
FALCO_ETC=falco-0.45.2-x86_64/etc/falco
FALCO_PLUGINS=$PWD/falco-0.45.2-x86_64/usr/share/falco/plugins
# The Falco log lines start with a time stamp. sed removes it, so that the output is the same in each run.
# The "System info" line is left out as well.
NOSTAMP='s/^[A-Z][a-z]{2} [A-Z][a-z]{2} +[0-9]+ [0-9:]+ [0-9]{4}: //'
echo "--- what the rules file of the archive asks for (lines 28 to 32)"
sed -n '28,32p' $FALCO_ETC/falco_rules.yaml
echo "--- the load_plugins line of the configuration file of the archive"
grep -n '^load_plugins:' $FALCO_ETC/falco.yaml
echo "--- the rules file of the archive, with the default configuration"
falco -c $FALCO_ETC/falco.yaml -V $FALCO_ETC/falco_rules.yaml 2>&1 | grep -v 'System info' | sed -E "$NOSTAMP"
echo "exit=${PIPESTATUS[0]}"
echo "--- the rules file of the archive, with the container plugin loaded"
falco -c $FALCO_ETC/falco.yaml -o load_plugins[0]=container -o plugins[0].library_path=$FALCO_PLUGINS/libcontainer.so -V $FALCO_ETC/falco_rules.yaml > shipped.log 2>&1
echo "exit=$?"
echo "log lines from the container plugin, left out below: $(grep -c '\[libs\]' shipped.log)"
grep -v -e '\[libs\]' -e 'System info' shipped.log | sed -E "$NOSTAMP"
cat > qa_rules.yaml <<'EOF'
- list: qa_sensitive_files
items: [/etc/shadow, /etc/sudoers]
- macro: qa_open_write
condition: >
evt.type in (open, openat, openat2) and evt.is_open_write=true and fd.typechar='f'
- rule: QA write to a sensitive file
desc: A process opened a sensitive file for writing. The rule is the tutorial's own.
condition: qa_open_write and fd.name in (qa_sensitive_files)
output: Sensitive file opened for writing (file=%fd.name process=%proc.name command=%proc.cmdline user=%user.name)
priority: WARNING
tags: [qa, filesystem]
EOF
echo "--- the tutorial's own rules file"
falco -c $FALCO_ETC/falco.yaml -V qa_rules.yaml 2>&1 | grep -v 'System info' | sed -E "$NOSTAMP"
echo "exit=${PIPESTATUS[0]}"
echo "--- the rule list"
falco -c $FALCO_ETC/falco.yaml -r qa_rules.yaml -L 2>/dev/null
echo "exit=$?"Output of the tutorial's run:
--- what the rules file of the archive asks for (lines 28 to 32)
- required_engine_version: 0.57.0
- required_plugin_versions:
- name: container
version: 0.4.0
--- the load_plugins line of the configuration file of the archive
588:load_plugins: []
--- the rules file of the archive, with the default configuration
Falco version: 0.45.2 (x86_64)
Falco initialized with configuration files:
falco-0.45.2-x86_64/etc/falco/falco.yaml | schema validation: ok
Validating rules file(s):
falco-0.45.2-x86_64/etc/falco/falco_rules.yaml
Error: Plugin requirement not satisfied, must load one of: container (>= 0.4.0)
exit=1
--- the rules file of the archive, with the container plugin loaded
exit=0
log lines from the container plugin, left out below: 14
Falco version: 0.45.2 (x86_64)
Falco initialized with configuration files:
falco-0.45.2-x86_64/etc/falco/falco.yaml | schema validation: ok
Loaded plugin 'container@0.7.6' from file /work/falco-0.45.2-x86_64/usr/share/falco/plugins/libcontainer.so
Validating rules file(s):
falco-0.45.2-x86_64/etc/falco/falco_rules.yaml
falco-0.45.2-x86_64/etc/falco/falco_rules.yaml: Ok
--- the tutorial's own rules file
Falco version: 0.45.2 (x86_64)
Falco initialized with configuration files:
falco-0.45.2-x86_64/etc/falco/falco.yaml | schema validation: ok
Validating rules file(s):
qa_rules.yaml
qa_rules.yaml: Ok
exit=0
--- the rule list
Rule Description
---- -----------
QA write to a sensitive file A process opened a sensitive file for writing. The rule is
the tutorial's own.
exit=0- Lines 28 to 32 of the shipped
falco_rules.yamlholdrequired_engine_version: 0.57.0and arequired_plugin_versionsentry for the plugincontainerin version0.4.0. The docs say thatrequired_engine_versionis used to track compatibility between rules content and the falco engine version Source 22সোর্স 22. The Falco of the run has the engine version 0.65.0 (step 1). - The docs say that rules files can have a top-level field
required_plugin_versions, to document the plugin versions that they are compatible with Source 46সোর্স 46. They say that if a plugin is loaded and an entry has a matching name, the loaded version must be semver compatible with the version of the entry Source 46সোর্স 46. falco -Vwith the default configuration printedError: Plugin requirement not satisfied, must load one of: container (>= 0.4.0)and exited with 1. Thefalco.yamlof the archive hasload_plugins: []at line 588.- The second command loaded the plugin with two
-ooptions. The docs say that any configuration option can be overridden on the command line with-o/--option key=valueSource 44সোর্স 44. They say that you can override a specific entry of a list by index, as in--option key.subkey[0]=valueSource 44সোর্স 44. The docs say that thepluginsproperty defines the set of plugins that Falco can load, and that theload_pluginsproperty controls which plugins are loaded when Falco starts Source 46সোর্স 46. - With the plugin, Falco printed
Loaded plugin 'container@0.7.6'andfalco_rules.yaml: Ok, and it exited with 0. The step left out 14 log lines of the plugin. - The packages page says that on RHEL 8 / UBI 8 systems with glibc older than 2.34, the container plugin bundled with Falco 0.42 to 0.44.x may fail to load with an undefined symbol, and that Falco 0.45.0 bundles a fixed version Source 41সোর্স 41. The glibc of the tutorial's machine is 2.43.
qa_rules.yamlis the tutorial's own file. It has a list, a macro, and a rule with the priorityWARNING. The docs say that a rules file is a YAML file with mainly three types of elements Source 22সোর্স 22. Falco validated it withqa_rules.yaml: Okand exit code 0. A rule has at least the fieldsrule,desc,condition,output, andprioritySource 23সোর্স 23.falco -r qa_rules.yaml -Lprinted the name and the description of the rule. The reference says that-Lshows the name and description of all rules and exits Source 25সোর্স 25.
13. Break the rule on purpose. The block makes three copies of qa_rules.yaml, each with one mistake, and it validates each copy with -V:
FALCO_ETC=falco-0.45.2-x86_64/etc/falco
# Three copies of the rules file, each with one mistake.
sed 's/fd.name in (qa_sensitive_files)/fd.nam in (qa_sensitive_files)/' qa_rules.yaml > qa_bad_field.yaml
sed 's/qa_open_write and/qa_open_writes and/' qa_rules.yaml > qa_bad_macro.yaml
sed 's/priority: WARNING/priority: LOUD/' qa_rules.yaml > qa_bad_priority.yaml
# stdout only (stderr is dropped).
for f in qa_bad_field.yaml qa_bad_macro.yaml qa_bad_priority.yaml; do
echo "--- $f"
falco -c $FALCO_ETC/falco.yaml -V $f 2> /dev/null
echo "exit=$?"
doneOutput of the tutorial's run:
--- qa_bad_field.yaml
qa_bad_field.yaml: Invalid
1 Errors:
In rules content: (qa_bad_field.yaml:0:0)
rule 'QA write to a sensitive file': (qa_bad_field.yaml:7:2)
rule condition: (qa_bad_field.yaml:9:13)
condition expression: ("qa_open_write and...":10:32)
------
qa_open_write and fd.nam in (qa_sensitive_files)
^
------
LOAD_ERR_COMPILE_CONDITION (Error compiling condition): filter_check called with nonexistent field fd.nam
exit=1
--- qa_bad_macro.yaml
qa_bad_macro.yaml: Invalid
1 Errors:
In rules content: (qa_bad_macro.yaml:0:0)
rule 'QA write to a sensitive file': (qa_bad_macro.yaml:7:2)
condition expression: ("qa_open_writes an...":8:3)
------
qa_open_writes and fd.name in (qa_sensitive_files)
^
------
LOAD_ERR_VALIDATE (Error validating rule/macro/list/exception objects): Undefined macro 'qa_open_writes' used in filter.
exit=1
--- qa_bad_priority.yaml
qa_bad_priority.yaml: Invalid
3 Schema warnings:
------
failed for <root>[2][priority]: Failed to match against any enum values.
------
failed for <root>[2]: Failed to validate against schema associated with property name 'priority'.
------
failed for <root>: Failed to validate item #2 in array.
------
1 Errors:
In rules content: (qa_bad_priority.yaml:0:0)
rule 'QA write to a sensitive file': (qa_bad_priority.yaml:7:2)
rule priority: (qa_bad_priority.yaml:11:12)
------
priority: LOUD
^
------
LOAD_ERR_YAML_VALIDATE (Error validating internal structure of YAML file): Invalid priority
exit=1qa_bad_field.yamlhasfd.namin place offd.name. Falco printedInvalid, thenLOAD_ERR_COMPILE_CONDITION (Error compiling condition): filter_check called with nonexistent field fd.nam. It printed the condition with a^under the place of the error, and the exit code was 1. The docs say that--listlists all defined fields, so you can look up the right field name Source 25সোর্স 25. The tutorial did not run it.qa_bad_macro.yamlhasqa_open_writesin place ofqa_open_write. Falco printedLOAD_ERR_VALIDATE (Error validating rule/macro/list/exception objects): Undefined macro 'qa_open_writes' used in filter., and the exit code was 1. The docs say that macros are rule condition snippets that can be re-used inside rules and even other macros Source 22সোর্স 22.qa_bad_priority.yamlhaspriority: LOUD. Falco printed3 Schema warnings,1 Errors, andLOAD_ERR_YAML_VALIDATE (Error validating internal structure of YAML file): Invalid priority, and the exit code was 1. The docs list the available priorities Source 23সোর্স 23.- Each output starts with the file name and the word
Invalid. The step printed stdout only, and it dropped stderr.
14. Install the audit plugin and its rules with falcoctl. Run:
mkdir plugins rules state assets
# The log lines start with a date and a time. sed removes them. The order of the three artifacts can differ from run to run.
falcoctl artifact install k8saudit:0.18.0 json:0.7.4 k8saudit-rules:0.18.0 \
--config falco-0.45.2-x86_64/etc/falcoctl/falcoctl.yaml \
--plugins-dir plugins --rulesfiles-dir rules --state-dir state --assets-dir assets \
--log-format text 2>&1 | sed -E 's/^[0-9-]+ [0-9:]+ //'
echo "exit=${PIPESTATUS[0]}"
ls plugins rules
# The two rules that step 15 triggers (the line numbers show their order in the file), and the lists that have the user kubernetes-admin.
grep -n -A 2 -E '^- rule: (Disallowed K8s User|Create Privileged Pod)$' rules/k8s_audit_rules.yaml
awk '/^- list: /{name=$3} /"kubernetes-admin",/{print "line " NR ": in the list " name}' rules/k8s_audit_rules.yamlOutput of the tutorial's run:
INFO Resolving dependencies ...
INFO Installing artifacts
└ refs: [ghcr.io/falcosecurity/plugins/ruleset/k8saudit:0.18.0 ghcr.io/falcosecurity/plugins/plugin/k8saudit:0.18.0 ghcr.io/falcosecurity/plugins/plugin/json:0.7.4]
INFO Preparing to pull artifact
└ ref: ghcr.io/falcosecurity/plugins/ruleset/k8saudit:0.18.0
INFO Pulling layer 8324f17dce60
INFO Pulling layer d213d53c736a
INFO Pulling layer ffb6b16fb785
INFO Verifying signature for artifact
└ digest: ghcr.io/falcosecurity/plugins/ruleset/k8saudit@sha256:ffb6b16fb78585f9658b75847c511220b4915cf62805261340bcc173906d7d7c
INFO Signature successfully verified!
INFO Extracting and installing artifact
├ type: rulesfile
└ file: k8saudit-rules-0.18.0.tar.gz
INFO Artifact successfully installed
├ name: ghcr.io/falcosecurity/plugins/ruleset/k8saudit:0.18.0
├ type: rulesfile
├ digest: sha256:ffb6b16fb78585f9658b75847c511220b4915cf62805261340bcc173906d7d7c
└ directory: rules
INFO Preparing to pull artifact
└ ref: ghcr.io/falcosecurity/plugins/plugin/k8saudit:0.18.0
INFO Pulling layer 894b71ec239d
INFO Pulling layer 180046ef8a1c
INFO Pulling layer ecfeb7378165
INFO Verifying signature for artifact
└ digest: ghcr.io/falcosecurity/plugins/plugin/k8saudit@sha256:ca794b24fee51095579b63b4e8a57030de6e3a8489bcd11d1960aa26a021308f
INFO Signature successfully verified!
INFO Extracting and installing artifact
├ type: plugin
└ file: k8saudit-0.18.0-linux-x86_64.tar.gz
INFO Artifact successfully installed
├ name: ghcr.io/falcosecurity/plugins/plugin/k8saudit:0.18.0
├ type: plugin
├ digest: sha256:ecfeb737816523d949660404d7a1a4a1dbcaecf785bfb84a1c48a06e899ebb85
└ directory: plugins
INFO Preparing to pull artifact
└ ref: ghcr.io/falcosecurity/plugins/plugin/json:0.7.4
INFO Pulling layer 47b0c10d399d
INFO Pulling layer d1370d6387f9
INFO Pulling layer 9f898f44312d
INFO Verifying signature for artifact
└ digest: ghcr.io/falcosecurity/plugins/plugin/json@sha256:b867a72796552499e3212f5b7af51cbeb5587348041f72d6f2131c575f6fb312
INFO Signature successfully verified!
INFO Extracting and installing artifact
├ type: plugin
└ file: json-0.7.4-linux-x86_64.tar.gz
INFO Artifact successfully installed
├ name: ghcr.io/falcosecurity/plugins/plugin/json:0.7.4
├ type: plugin
├ digest: sha256:9f898f44312dd433ca507190e759277b34d7558cf4a378f97e9b46d705da5f72
└ directory: plugins
exit=0
plugins:
libjson.so
libk8saudit.so
rules:
k8s_audit_rules.yaml
154:- rule: Disallowed K8s User
155- desc: Detect any k8s operation by users outside of an allowed set of users.
156- condition: kevt and non_system_user and not ka.user.name in (allowed_k8s_users) and not ka.user.name in (eks_allowed_k8s_users)
--
247:- rule: Create Privileged Pod
248- desc: >
249- Detect an attempt to start a pod with a privileged container
line 74: in the list allowed_k8s_users
line 783: in the list full_admin_k8s_usersfalcoctl artifact installtook three names:k8saudit:0.18.0,json:0.7.4, andk8saudit-rules:0.18.0. It used the configuration file of the archive (--config), and it put the files in folders of the run (--plugins-dir,--rulesfiles-dir,--state-dir, and--assets-dir). The versions are the tutorial's own choice. The Falco docs say that the install command of falcoctl downloads rules files to a configurable directory, which is/etc/falcoby default Source 43সোর্স 43.- In the output, falcoctl resolved the three names to
ghcr.io/falcosecurity/plugins/plugin/k8saudit:0.18.0,ghcr.io/falcosecurity/plugins/plugin/json:0.7.4, andghcr.io/falcosecurity/plugins/ruleset/k8saudit:0.18.0. It pulled three layers of each artifact. For each artifact it printedVerifying signature for artifactandSignature successfully verified!. The tutorial did not look at how falcoctl checks a signature or at the key that it uses. lsshowedlibjson.soandlibk8saudit.soinplugins, andk8s_audit_rules.yamlinrules. The README of the plugin says that the official ruleset depends on the json plugin Source 45সোর্স 45. The step installsjsontoo.- The last two commands read the rules file.
Disallowed K8s Useris at line 154, and its condition ends withnot ka.user.name in (allowed_k8s_users) and not ka.user.name in (eks_allowed_k8s_users).Create Privileged Podis at line 247, and its description isDetect an attempt to start a pod with a privileged container. The userkubernetes-adminis in the listallowed_k8s_users(line 74) and in the listfull_admin_k8s_users(line 783). The docs say that lists are collections of items that can be included in rules, macros, or other lists Source 22সোর্স 22. The tutorial did not print the other names of the lists.
15. Read Kubernetes audit events from a file. The block writes three audit events as JSON Lines and a Falco configuration, and it runs Falco twice:
# One Kubernetes audit event, as one line of JSON: the user kubernetes-admin creates a Pod with a privileged container.
cat > event-privileged.json <<'EOF'
{"kind":"Event","apiVersion":"audit.k8s.io/v1","level":"RequestResponse","auditID":"11111111-2222-3333-4444-555555555555","stage":"ResponseComplete","requestURI":"/api/v1/namespaces/default/pods","verb":"create","user":{"username":"kubernetes-admin","groups":["system:authenticated"]},"sourceIPs":["10.0.0.5"],"userAgent":"kubectl/v1.37.2","objectRef":{"resource":"pods","namespace":"default","name":"qa-privileged","apiVersion":"v1"},"responseStatus":{"metadata":{},"code":201},"requestObject":{"kind":"Pod","apiVersion":"v1","metadata":{"name":"qa-privileged","namespace":"default"},"spec":{"containers":[{"name":"c1","image":"busybox:1.36","securityContext":{"privileged":true}}]}},"responseObject":{"kind":"Pod","apiVersion":"v1","metadata":{"name":"qa-privileged","namespace":"default"}},"requestReceivedTimestamp":"2026-11-20T01:40:00.000000Z","stageTimestamp":"2026-11-20T01:40:00.100000Z"}
EOF
# The same event from another user, and the same event without the privileged setting.
sed 's/"username":"kubernetes-admin"/"username":"qa-user"/' event-privileged.json > event-other-user.json
sed 's/"privileged":true/"privileged":false/' event-privileged.json > event-plain.json
cat event-privileged.json event-other-user.json event-plain.json > audit.jsonl
echo "events in audit.jsonl: $(wc -l < audit.jsonl)"
# A small Falco configuration: the two plugins, the rules file, and the audit file as the source of events.
cat > falco-audit.yaml <<EOF
rules_files:
- $PWD/rules/k8s_audit_rules.yaml
load_plugins: [k8saudit, json]
plugins:
- name: k8saudit
library_path: $PWD/plugins/libk8saudit.so
init_config: ""
open_params: "$PWD/audit.jsonl"
- name: json
library_path: $PWD/plugins/libjson.so
stdout_output:
enabled: true
EOF
# stdout only (stderr is dropped). sed removes the time at the start of each alert line.
echo "--- the default setting"
falco -c falco-audit.yaml --disable-source syscall 2> /dev/null | sed -E 's/^[0-9:.]+: //'
echo "exit=${PIPESTATUS[0]}"
echo "--- -o rule_matching=all"
falco -c falco-audit.yaml --disable-source syscall -o rule_matching=all 2> /dev/null | sed -E 's/^[0-9:.]+: //'
echo "exit=${PIPESTATUS[0]}"Output of the tutorial's run:
events in audit.jsonl: 3
--- the default setting
Warning Pod started with privileged container (user=kubernetes-admin pod=qa-privileged resource=pods ns=default images=(busybox:1.36) init_images=<NA> ephemeral_images=<NA>)
Warning K8s Operation performed by user not in allowed list of users (user=qa-user target=qa-privileged/pods verb=create uri=/api/v1/namespaces/default/pods resp=201)
Events detected: 2
Rule counts by severity:
WARNING: 2
Triggered rules by rule name:
Disallowed K8s User: 1
Create Privileged Pod: 1
exit=0
--- -o rule_matching=all
Warning Pod started with privileged container (user=kubernetes-admin pod=qa-privileged resource=pods ns=default images=(busybox:1.36) init_images=<NA> ephemeral_images=<NA>)
Warning K8s Operation performed by user not in allowed list of users (user=qa-user target=qa-privileged/pods verb=create uri=/api/v1/namespaces/default/pods resp=201)
Warning Pod started with privileged container (user=qa-user pod=qa-privileged resource=pods ns=default images=(busybox:1.36) init_images=<NA> ephemeral_images=<NA>)
Events detected: 3
Rule counts by severity:
WARNING: 3
Triggered rules by rule name:
Disallowed K8s User: 1
Create Privileged Pod: 2
exit=0event-privileged.jsonis one audit event. The userkubernetes-admincreates the Podqa-privilegedwith a privileged container (verbcreate, resourcepods, response code 201).event-other-user.jsonis the same event from the userqa-user.event-plain.jsonis the same event withprivilegedset tofalse.audit.jsonlhas the three events, one on each line. The events are the tutorial's own.- The README of the plugin says that it supports Kubernetes audit events from the Webhook backend or from a file Source 45সোর্স 45. For a file, the plugin expects JSONL, where each line is a JSON object with one or more audit events Source 45সোর্স 45. The README says that the expected way to use the plugin with Falco is a Webhook, and that file reading can be used for testing and development Source 45সোর্স 45. The Falco docs say that, to receive Kubernetes audit events, the plugin embeds a webserver that listens on a configurable port and accepts POST requests on a configurable endpoint Source 47সোর্স 47. The tutorial read a file and ran no webserver.
falco-audit.yamlis the tutorial's own configuration. It lists the rules file of step 14,load_plugins: [k8saudit, json], the two plugins with their library paths, and the file inopen_params. The README says that a parameter with no scheme is read as a file path Source 45সোর্স 45. Its sample has the sameload_pluginslist Source 45সোর্স 45.- The
--disable-sourceoption turns off a specific event source Source 25সোর্স 25. The step gave itsyscall. The docs say that for plugin-based deployments, you disable syscall explicitly or enable only the desired plugin-based sources Source 19সোর্স 19. - With the default setting, Falco printed two alerts for the three events, and
Events detected: 2. The first event raisedPod started with privileged containerforkubernetes-admin. The second event raisedK8s Operation performed by user not in allowed list of usersforqa-user. The third event raised no alert. The step removed the time at the start of each alert line. - The second event is a privileged Pod too, and in the default setting it did not raise
Create Privileged Pod. In the rules file of step 14,Disallowed K8s Useris defined at line 154 andCreate Privileged Podat line 247. The docs say that by default Falco applies rules per event type on a "first match wins" basis Source 24সোর্স 24. They say that the way to control the order in which rules are triggered is to change the order in which the rules are defined, and therefore loaded Source 23সোর্স 23. In this run, the alert of the second event came from the rule that is defined first. - With
-o rule_matching=all, Falco printed three alerts andEvents detected: 3. The second event raised both rules, andCreate Privileged Podwas counted twice. The docs say that from Falco 0.36.0 you can change the configuration torule_matching: allSource 24সোর্স 24. They say that this change ensures that rules sharing the same event type cannot override each other Source 24সোর্স 24. They warn that it may lead to increased CPU usage Source 24সোর্স 24. The tutorial did not measure CPU. - Falco exited with 0 in both runs, although it raised alerts. In this run, the exit code did not show the alerts.
সহজ English
The tutorial ran steps 1 to 15 on 2026-11-20 at 02:24 (+06) on Linux 7.0.0-43-generic. The versions were istioctl 1.32.0, OPA 1.22.4, gator v3.23.1, Falco 0.45.2, and falcoctl 0.14.3. The helpers were Python 3.14.4, curl 8.18.0, and bash 5.3.9. The output on this page is from the tutorial's run. Each step ran in a subshell of the runner, in one new folder, with a new, empty HOME. The page shows the folder of the run as /work.
The run needs no cluster, no Docker, and no root rights. istioctl reads local files only (--use-kube=false). OPA and gator work on local files. The OPA server listens on 127.0.0.1:18181 only. Falco reads audit events from a file, and it loads no kernel driver. Step 14 pulls three artifacts from ghcr.io. After the run, the real home folder had no new entry, and the folder of the tools had no new or removed file. The port 18181 was free, and the run left no opa or falco process. The empty home folder of the run held one entry after the steps: .sigstore, with 23 files. The tutorial did not check which command made it.
The choices that no source gives are the tutorial's own. They are the Istio files (the namespace shop, the service reviews, and the subsets v1 and v2), the policy pods.rego and its tests, the Gatekeeper template qanoprivileged, the rule QA write to a sensitive file, the three audit events, and the port 18181. The tutorial did not run Istio in a cluster. The run has no sidecar, no ambient data plane, no traffic, and no mutual TLS handshake. It did not run the admission webhook or the audit of Gatekeeper in a cluster. It did not run OPA with Envoy or with a Terraform plan. It did not run Falco with a driver. No syscall event was read. It did not run the event-generator. It ran on Linux only.
Install the tools. The tutorial's install script put the four tools in the home folder of the user, with no sudo. It took each archive from the release place of its project. istioctl and gator came from GitHub releases, OPA from openpolicyagent.org/downloads, and Falco from download.falco.org. The OPA docs say that checksums for all binaries are available in the download path Source 27সোর্স 27. The script compared the SHA-256 of the OPA binary with that file. For istioctl and gator, it compared the SHA-256 of the archive with the checksum file of the same GitHub release. That choice is the tutorial's own.
The tutorial found no checksum file for the Falco archive. The runner asked for ten file names next to the archive on download.falco.org, and only the archive and its .asc file answered with 200:
200 falco-0.45.2-x86_64.tar.gz
200 falco-0.45.2-x86_64.tar.gz.asc
404 falco-0.45.2-x86_64.tar.gz.sig
404 falco-0.45.2-x86_64.tar.gz.sha256
404 falco-0.45.2-x86_64.tar.gz.sha256sum
404 falco-0.45.2-x86_64.tar.gz.sha512
404 falco-0.45.2-x86_64.tar.gz.md5
404 falco-0.45.2-x86_64.tar.gz.cert
404 falco-0.45.2-x86_64.tar.gz.pem
404 falco-0.45.2-x86_64.tar.gz.bundleThe Falco packages page tells you to trust the falcosecurity GPG key Source 41সোর্স 41. It gives the key file at https://falco.org/repo/falcosecurity-packages.asc Source 41সোর্স 41. The script imported that key into a throw-away GnuPG home and checked the .asc file against the archive. The signature was good, and its primary key was 478B2FBBC75F4237B731DA4365106822B35B1B1F. The script did not compare that fingerprint with a second source. For istioctl, OPA, and gator, the checksum file and the archive come from the same host. For Falco, the key comes from falco.org and the archive from download.falco.org. The tutorial treats these checks as a way to find a damaged or swapped archive, and not as proof of who built it. The record of the install is:
istioctl 1.32.0; sha256 4771175dec92527cd90ddc7edb3b3abcb32ca2f3bc32b31aa31e0b12ad36f897
opa v1.22.4; sha256 b76461cf4db0f77946ef557d727a1da5d7a22ba930844678c9be0bebd2c9d0f6
gator v3.23.1; sha256 c268d7b809c9fe59a110ab0bf7c296ab00b0b6c894c209cd15e94194590291bb
falco 0.45.2; sha256 b2e9961e51601095765c6c644329673e6af2f06c02357d0e77da0f680e4910da; signature good, primary key 478B2FBBC75F4237B731DA4365106822B35B1B1FIn your own terminal, put istioctl, opa, and gator on your PATH. Unpack the Falco archive in the folder of the practice, and put its usr/bin folder on your PATH. The steps call falco and falcoctl by name. The tarball page of the Falco docs unpacks the archive with tar and copies it to / Source 26সোর্স 26. The tutorial did not copy anything to /. The page also says that Falco with its bundled plugins requires GLIBC 2.28 or newer Source 26সোর্স 26. The glibc of the tutorial's machine is 2.43.
1. Check the tools. Run this in the folder of the practice. The first command unpacks the Falco archive:
tar -xzf falco-0.45.2-x86_64.tar.gz
istioctl version --remote=false
opa version | head -n 1
gator --version
falco --version
falcoctl versionOutput of the tutorial's run:
client version: 1.32.0
Version: 1.22.4
gator version v3.23.1 (Feature State: beta), opa/v1.17.1, frameworks/v0.0.0-20260616163050-e1eaa1bf6d62
Falco version: 0.45.2
Libs version: 0.26.1
Plugin API: 3.12.0
Engine: 0.65.0
Driver:
API version: 11.0.0
Schema version: 4.3.0
Default driver: 11.0.1+driver
Client Version: 0.14.3istioctl version --remote=falseprintedclient version: 1.32.0. The reference says to use--remote=falseto suppress the control plane check Source 16সোর্স 16.opa versionprintedVersion: 1.22.4on its first line. The step cut the output there withhead -n 1.gator --versionprintedv3.23.1 (Feature State: beta), and the same line hasopa/v1.17.1. Theopabinary of the run is 1.22.4. The two numbers differ, and the tutorial did not find out what theopa/v1.17.1in the gator line stands for.falco --versionprinted 0.45.2 with the version of the libs, the plugin API, and the engine.falcoctl versionprintedClient Version: 0.14.3.- These commands print versions only. The Falco docs say that falcoctl is bundled together with Falco Source 18সোর্স 18.
2. Render the install manifests of five profiles. Run:
for p in default demo minimal ambient empty; do
istioctl manifest generate --set profile=$p > manifest-$p.yaml
echo "$p: $(grep -c '^kind:' manifest-$p.yaml) objects; workloads: $(awk '/^kind: (Deployment|DaemonSet)$/ {k=$2; w=1; next} w && /^ name:/ {print k "/" $2; w=0}' manifest-$p.yaml | tr '\n' ' ')"
doneOutput of the tutorial's run:
default: 39 objects; workloads: Deployment/istio-ingressgateway Deployment/istiod
demo: 42 objects; workloads: Deployment/istio-egressgateway Deployment/istio-ingressgateway Deployment/istiod
minimal: 33 objects; workloads: Deployment/istiod
ambient: 44 objects; workloads: DaemonSet/istio-cni-node DaemonSet/ztunnel Deployment/istiod
empty: 0 objects; workloads: - The loop wrote the manifest of each profile to a file and counted the lines that start with
kind:. The count of objects and the list of workloads are the tutorial's own way to compare profiles. - The reference says that
istioctl manifest generategenerates an Istio install manifest and outputs to the console by default Source 16সোর্স 16. The step wrote the output to files, and it applied nothing. - The
emptyprofile gave 0 objects. The docs say that the empty profile deploys nothing Source 14সোর্স 14. - The
minimalprofile gave 33 objects, and its only workload isistiod. The docs say that the minimal profile is the same as the default profile, but only the control plane components are installed Source 14সোর্স 14. - The
defaultprofile gave 39 objects, withistio-ingressgatewayandistiod. Thedemoprofile gave 42 objects, withistio-egressgatewayadded. The traffic management page says that both gateways are deployed with the demo installation, and just the ingress gateway with the default profile Source 11সোর্স 11. - The
ambientprofile gave 44 objects. Its workloads are the DaemonSetsistio-cni-nodeandztunnel, andistiod. The ambient overview names the ztunnel secure overlay as the base of ambient mode Source 10সোর্স 10.
3. Check a good Istio file. The command block writes mesh-good.yaml, and then it analyzes the file:
cat > mesh-good.yaml <<'EOF'
apiVersion: v1
kind: Namespace
metadata:
name: shop
labels:
istio-injection: enabled
---
apiVersion: v1
kind: Service
metadata:
name: reviews
namespace: shop
spec:
selector:
app: reviews
ports:
- name: http
port: 9080
---
apiVersion: networking.istio.io/v1
kind: Gateway
metadata:
name: shop-gateway
namespace: shop
spec:
selector:
istio: ingressgateway
servers:
- port:
number: 80
name: http
protocol: HTTP
hosts:
- "shop.example.com"
---
apiVersion: networking.istio.io/v1
kind: VirtualService
metadata:
name: reviews
namespace: shop
spec:
hosts:
- reviews
http:
- route:
- destination:
host: reviews
subset: v1
weight: 80
- destination:
host: reviews
subset: v2
weight: 20
---
apiVersion: networking.istio.io/v1
kind: DestinationRule
metadata:
name: reviews
namespace: shop
spec:
host: reviews
subsets:
- name: v1
labels:
version: v1
- name: v2
labels:
version: v2
EOF
cat > mesh-bad.yaml <<'EOF'
apiVersion: v1
kind: Namespace
metadata:
name: shop
---
apiVersion: v1
kind: Service
metadata:
name: reviews
namespace: shop
spec:
selector:
app: reviews
ports:
- name: http
port: 9080
---
apiVersion: networking.istio.io/v1
kind: VirtualService
metadata:
name: reviews
namespace: shop
spec:
hosts:
- reviews
gateways:
- bogus-gateway
http:
- route:
- destination:
host: reviews
subset: v3
---
apiVersion: networking.istio.io/v1
kind: DestinationRule
metadata:
name: reviews
namespace: shop
spec:
host: reviews
subsets:
- name: v1
labels:
version: v1
EOF
istioctl analyze --use-kube=false -A mesh-good.yaml
echo "exit=$?"Output of the tutorial's run:
✔ No validation issues found when analyzing mesh-good.yaml.
exit=0- The file has a Namespace
shopwith the labelistio-injection: enabled, a Servicereviews, a Gateway, a VirtualService, and a DestinationRule. The VirtualService sends 80 % of the requests to the subsetv1and 20 % tov2. The DestinationRule defines both subsets. - The file also has the Namespace and the Service that the other objects refer to. The docs say that a set of local files is expected to be fully self-contained Source 15সোর্স 15.
istioctl analyze --use-kube=false -A mesh-good.yamlprintedNo validation issues found when analyzing mesh-good.yaml.and exited with 0. The docs show the same kind of message for a namespace Source 15সোর্স 15.- The tutorial's files are its own. They are small, and they are not a model of a real mesh.
4. Check a bad file, with and without a namespace option. Step 3 wrote mesh-bad.yaml as well. Run:
echo "--- no namespace option"
istioctl analyze --use-kube=false mesh-bad.yaml
echo "exit=$?"
echo "--- -A (all namespaces)"
istioctl analyze --use-kube=false -A mesh-bad.yaml
echo "exit=$?"
echo "--- -n shop"
istioctl analyze --use-kube=false -n shop mesh-bad.yaml
echo "exit=$?"Output of the tutorial's run:
--- no namespace option
✔ No validation issues found when analyzing mesh-bad.yaml.
exit=0
--- -A (all namespaces)
Error [IST0101] (VirtualService shop/reviews mesh-bad.yaml:27) Referenced gateway not found: "bogus-gateway"
Error [IST0101] (VirtualService shop/reviews mesh-bad.yaml:31) Referenced host+subset in destinationrule not found: "reviews+v3"
Warning [IST0132] (VirtualService shop/reviews mesh-bad.yaml:27) one or more host [reviews] defined in VirtualService shop/reviews not found in Gateway shop/bogus-gateway.
Error: Analyzers found issues when analyzing all namespaces.
See https://istio.io/v1.32/docs/reference/config/analysis for more information about causes and resolutions.
exit=79
--- -n shop
Error [IST0101] (VirtualService shop/reviews mesh-bad.yaml:27) Referenced gateway not found: "bogus-gateway"
Error [IST0101] (VirtualService shop/reviews mesh-bad.yaml:31) Referenced host+subset in destinationrule not found: "reviews+v3"
Warning [IST0132] (VirtualService shop/reviews mesh-bad.yaml:27) one or more host [reviews] defined in VirtualService shop/reviews not found in Gateway shop/bogus-gateway.
Error: Analyzers found issues when analyzing namespace: shop.
See https://istio.io/v1.32/docs/reference/config/analysis for more information about causes and resolutions.
exit=79mesh-bad.yamlhas a VirtualService that names the gatewaybogus-gatewayand the subsetv3. Its DestinationRule has the subsetv1only.- With no namespace option,
istioctl analyze --use-kube=false mesh-bad.yamlprintedNo validation issues found when analyzing mesh-bad.yaml.and exited with 0. The tutorial did not find out why. The reference lists--namespacewith an empty default Source 16সোর্স 16. - With
-A, it printed three messages andError: Analyzers found issues when analyzing all namespaces.The exit code was 79. The docs show the same sentence for one namespace Source 15সোর্স 15. - With
-n shop, it printed the same three messages andError: Analyzers found issues when analyzing namespace: shop.The exit code was 79. - Each message has a level, a code, the kind and the name of the resource, the file and the line, and a text.
- The two
IST0101errors name a gateway and a host with a subset that do not exist. The docs say that this message occurs when an Istio resource references another resource that does not exist Source 17সোর্স 17. The list of messages names it ReferencedResourceNotFound Source 42সোর্স 42. - The list of messages names
IST0132VirtualServiceHostNotFoundInGateway Source 42সোর্স 42. - The exit code was 79 in the tutorial's run. The tutorial did not look up the meaning of the number.
5. Severity, exit codes, and JSON output. Run:
# A copy of the good file in which the VirtualService names the gateway shop-gateway, which does not list the host "reviews".
sed 's/^ - reviews$/&\n gateways:\n - shop-gateway/' mesh-good.yaml > mesh-warn.yaml
istioctl analyze --use-kube=false -A mesh-warn.yaml
for level in Error Warning Info; do
istioctl analyze --use-kube=false -A --failure-threshold $level mesh-warn.yaml > /dev/null 2>&1
echo "mesh-warn.yaml, --failure-threshold $level: exit=$?"
done
istioctl analyze --use-kube=false -A mesh-bad.yaml > /dev/null 2>&1
echo "mesh-bad.yaml, default output: exit=$?"
istioctl analyze --use-kube=false -A -o json mesh-bad.yaml > bad.json 2> bad.err
echo "mesh-bad.yaml, -o json: exit=$?"
python3 -c 'import json; print([(m["code"], m["level"]) for m in json.load(open("bad.json"))])'
echo "analyzers: $(istioctl analyze -L | grep -c '^\* ')"Output of the tutorial's run:
Warning [IST0132] (VirtualService shop/reviews mesh-warn.yaml:45) one or more host [reviews] defined in VirtualService shop/reviews not found in Gateway shop/shop-gateway.
mesh-warn.yaml, --failure-threshold Error: exit=0
mesh-warn.yaml, --failure-threshold Warning: exit=79
mesh-warn.yaml, --failure-threshold Info: exit=79
mesh-bad.yaml, default output: exit=79
mesh-bad.yaml, -o json: exit=0
[('IST0101', 'Error'), ('IST0101', 'Error'), ('IST0132', 'Warning')]
analyzers: 54mesh-warn.yamlismesh-good.yamlwith two more lines in the VirtualService. They name the gatewayshop-gateway, which does not list the hostreviews. The analysis printed one warning,IST0132, at line 45.- The reference says that
--failure-thresholdsets the severity level of analysis at which to set a non-zero exit code Source 16সোর্স 16. The valid values are Info, Warning, and Error, and the default isErrorSource 16সোর্স 16. - On the file with the warning only, the threshold
Errorgave the exit code 0. The thresholdsWarningandInfogave 79. Onmesh-bad.yaml, the default threshold gave 79. - With
-o json, the exit code formesh-bad.yamlwas 0 in the tutorial's run. The filebad.jsonhad the same three messages:IST0101with the levelErrortwice, andIST0132with the levelWarning. The tutorial did not find out why the exit code was 0. In this run, the exit code of the JSON output did not show the errors, and the level of each message did. istioctl analyze -Llisted 54 analyzers in this version. The reference says that-Llists the analyzers available to run Source 16সোর্স 16. The step counted the lines that start with*, which is the tutorial's own way to count.
6. Security files: mutual TLS and authorization policies. The block writes mesh-security.yaml and a copy with a typo, and it analyzes both:
cat > mesh-security.yaml <<'EOF'
apiVersion: v1
kind: Namespace
metadata:
name: shop
labels:
istio-injection: enabled
---
apiVersion: security.istio.io/v1
kind: PeerAuthentication
metadata:
name: default
namespace: shop
spec:
mtls:
mode: STRICT
---
apiVersion: security.istio.io/v1
kind: AuthorizationPolicy
metadata:
name: allow-frontend-get
namespace: shop
spec:
selector:
matchLabels:
app: reviews
action: ALLOW
rules:
- from:
- source:
namespaces: ["frontend"]
to:
- operation:
methods: ["GET"]
---
apiVersion: security.istio.io/v1
kind: AuthorizationPolicy
metadata:
name: deny-admin
namespace: shop
spec:
selector:
matchLabels:
app: reviews
action: DENY
rules:
- to:
- operation:
paths: ["/admin"]
EOF
istioctl analyze --use-kube=false -A mesh-security.yaml
echo "exit=$?"
# A copy in which the action of the last policy is misspelled. sed removes the date and time of the log line, so that the output is the same in each run.
sed 's/action: DENY/action: DENYY/' mesh-security.yaml > mesh-security-typo.yaml
istioctl analyze --use-kube=false -A mesh-security-typo.yaml 2>&1 | sed -E 's/^[0-9T:.Z-]+\t//'
echo "exit=${PIPESTATUS[0]}"Output of the tutorial's run:
Warning [IST0133] (AuthorizationPolicy shop/deny-admin mesh-security.yaml:35) Schema validation warning: configured AuthorizationPolicy will deny all traffic to TCP ports under its scope due to the use of only HTTP attributes in a DENY rule; it is recommended to explicitly specify the port
exit=0
warn file error processing mesh-security-typo.yaml[3]: failed parsing JSON for built-in type: unknown value "\"DENYY\"" for enum istio.security.v1beta1.AuthorizationPolicy.Action - skipping
Error(s) adding files: 1 error occurred:
* errors parsing content "mesh-security-typo.yaml": 1 error occurred:
* error processing mesh-security-typo.yaml[3]: failed parsing JSON for built-in type: unknown value "\"DENYY\"" for enum istio.security.v1beta1.AuthorizationPolicy.Action
No validation issues found when analyzing all namespaces (but 1 file could not be parsed).
Error: Some files couldn't be parsed.
exit=65mesh-security.yamlhas the namespaceshopwith injection enabled, a PeerAuthentication nameddefaultwith the modeSTRICT, an ALLOW policy namedallow-frontend-get, and a DENY policy nameddeny-admin. Both policies select the workload with the labelapp: reviews. The ALLOW policy lets in the GET requests from the namespacefrontend. The DENY policy has the path/admin.- The analysis printed one warning,
IST0133, for the DENY policy at line 35, and it exited with 0. The list of messages namesIST0133SchemaWarning Source 42সোর্স 42. The text of the message says that the policy will deny all traffic to TCP ports under its scope due to the use of only HTTP attributes in a DENY rule. It recommends to specify the port explicitly. - The security page says that certain fields and conditions are only applicable to HTTP workloads Source 12সোর্স 12. The
pathsfield in theoperationsection is one of them Source 12সোর্স 12. The page also says that Istio will ignore the HTTP-only fields if you use any of them for a TCP workload Source 12সোর্স 12. The tutorial sent no traffic. It did not check what the policy does with TCP traffic. - The ALLOW policy uses the field
namespacesundersource. The page says that mutual TLS must be enabled before using any of the following fields in the authorization policy Source 12সোর্স 12. They are theprincipalsandnotPrincipalsfields and thenamespacesandnotNamespacesfields, all under thesourcesection Source 12সোর্স 12. The file has the PeerAuthentication in the modeSTRICTin the same namespace. The analysis printed no message about the ALLOW policy. - In the copy
mesh-security-typo.yaml, the action of the DENY policy isDENYY.istioctlprinted awarnline. It says that it failed parsing JSON formesh-security-typo.yaml[3], with an unknown value for the enum of the action, and that it was skipping it. Then it printedNo validation issues found when analyzing all namespaces (but 1 file could not be parsed).andError: Some files couldn't be parsed.The exit code was 65. - The line
No validation issues foundwas printed although the policy with the typo was not analyzed. Only the last line and the exit code showed the problem. - The reference has the option
--ignore-unknown, which does not complain about un-parseable input documents, for cases where analyze should run only on k8s compliant inputs Source 16সোর্স 16. The tutorial did not use it.
7. Write a policy and ask OPA. The block writes the policy pods.rego and two Pods as JSON, and it runs opa eval:
cat > pods.rego <<'EOF'
package qa.pods
# A pod is denied when one of its containers runs privileged.
deny contains msg if {
some c in input.spec.containers
c.securityContext.privileged == true
msg := sprintf("container %v must not run privileged", [c.name])
}
default allow := false
allow if count(deny) == 0
EOF
cat > bad-pod.json <<'EOF'
{"apiVersion": "v1", "kind": "Pod", "metadata": {"name": "qa-privileged", "namespace": "default"}, "spec": {"containers": [{"name": "c1", "image": "busybox:1.36", "securityContext": {"privileged": true}}]}}
EOF
sed 's/qa-privileged/qa-plain/; s/"privileged": true/"privileged": false/' bad-pod.json > good-pod.json
opa eval --format pretty -d pods.rego -i bad-pod.json 'data.qa.pods.deny'
opa eval --format pretty -d pods.rego -i bad-pod.json 'data.qa.pods.allow'
opa eval --format pretty -d pods.rego -i good-pod.json 'data.qa.pods.allow'
opa eval --fail-defined -d pods.rego -i bad-pod.json 'data.qa.pods.deny[_]' > /dev/null
echo "--fail-defined, bad pod: exit=$?"
opa eval --fail-defined -d pods.rego -i good-pod.json 'data.qa.pods.deny[_]' > /dev/null
echo "--fail-defined, good pod: exit=$?"Output of the tutorial's run:
[
"container c1 must not run privileged"
]
false
true
--fail-defined, bad pod: exit=1
--fail-defined, good pod: exit=0pods.regois the tutorial's own policy. Its ruledenyis a set with one message for each container that hasprivileged == true. Its ruleallowisfalseby default, and it istruewhendenyis empty. The docs say that thedefaultkeyword lets a policy define a default value for documents produced by rules with complete definitions Source 29সোর্স 29.- The input of the query is the Pod that
-igives. The docs say that all modules contain implicit statements which import the data and input documents Source 29সোর্স 29. - For
bad-pod.json,data.qa.pods.denyprinted a list with one message,container c1 must not run privileged, anddata.qa.pods.allowprintedfalse. Forgood-pod.json,allowprintedtrue. - The reference says that
--fail-definedexits with a non-zero exit code on a defined or non-empty result Source 31সোর্স 31. The querydata.qa.pods.deny[_]has a result for the bad Pod, and the exit code was 1. For the good Pod it has no result, and the exit code was 0.
8. Test the policy. The block writes the tests pods_test.rego, then it runs opa test on the good tests, on a failing copy, and on a copy with misspelled tests:
cat > pods_test.rego <<'EOF'
package qa.pods_test
import data.qa.pods
test_privileged_pod_is_denied if {
not pods.allow with input as {"spec": {"containers": [{"name": "c1", "securityContext": {"privileged": true}}]}}
}
test_plain_pod_is_allowed if {
pods.allow with input as {"spec": {"containers": [{"name": "c1", "securityContext": {"privileged": false}}]}}
}
test_pod_without_security_context_is_allowed if {
pods.allow with input as {"spec": {"containers": [{"name": "c1"}]}}
}
EOF
# The run times are removed with sed and the lines are sorted, so that the output is the same in each run.
opa test -v pods.rego pods_test.rego | grep -E 'PASS|FAIL' | sed -E 's/ \([^)]*\)$//' | sort
echo "opa test: exit=${PIPESTATUS[0]}"
# The same policy with a test that expects the wrong answer.
mkdir failing
cp pods.rego failing/
sed 's/^\tnot pods.allow with input/\tpods.allow with input/' pods_test.rego > failing/pods_test.rego
opa test failing/ | sed -E 's/ \([^)]*\)$//'
echo "opa test failing/: exit=${PIPESTATUS[0]}"
# A copy in which the tests are misspelled: the prefix is tset_ and not test_.
mkdir misspelled
cp pods.rego misspelled/
sed 's/^test_/tset_/' pods_test.rego > misspelled/pods_test.rego
opa test misspelled/
echo "opa test misspelled/: exit=$?"
opa test --fail-on-empty misspelled/
echo "opa test --fail-on-empty misspelled/: exit=$?"
# Coverage of the policy file by the tests
opa test --coverage pods.rego pods_test.rego | python3 -c 'import json, sys; d = json.load(sys.stdin)["files"]["pods.rego"]; print("pods.rego covered lines:", d["covered_lines"], "not covered:", d.get("not_covered_lines", 0), "coverage:", d["coverage"])'Output of the tutorial's run:
PASS: 3/3
data.qa.pods_test.test_plain_pod_is_allowed: PASS
data.qa.pods_test.test_pod_without_security_context_is_allowed: PASS
data.qa.pods_test.test_privileged_pod_is_denied: PASS
opa test: exit=0
failing/pods_test.rego:5:
data.qa.pods_test.test_privileged_pod_is_denied: FAIL
--------------------------------------------------------------------------------
PASS: 2/3
FAIL: 1/3
opa test failing/: exit=2
opa test misspelled/: exit=0
no tests were run
opa test --fail-on-empty misspelled/: exit=1
pods.rego covered lines: 6 not covered: 0 coverage: 100pods_test.regohas three tests. A privileged Pod is not allowed, a plain Pod is allowed, and a Pod with nosecurityContextis allowed. The docs say that tests are standard Rego rules with a name that has the prefixtest_Source 30সোর্স 30. Each test sets the input withwith input as. Thewithkeyword lets queries specify values nested under the input document Source 29সোর্স 29.opa test -v pods.rego pods_test.regoprintedPASS: 3/3and onePASSline for each test, and it exited with 0. The step removed the run times and sorted the lines.- In
failing/, the first test expects the privileged Pod to be allowed.opa testprintedFAILfor that test, withFAIL: 1/3andPASS: 2/3, and it exited with 2. The docs say that the result of a test is FAIL when the test rule is undefined or generates a non-true value Source 30সোর্স 30. - In
misspelled/, the prefix istset_.opa testprinted nothing and exited with 0. The docs say that when you misspell a test name or run no test by accident,opa testwill still succeed, and that--fail-on-emptymakes it fail Source 30সোর্স 30. With--fail-on-empty, it printedno tests were runand exited with 1. opa test --coverageprinted a JSON report. The step read three numbers forpods.regofrom it: 6 covered lines, 0 lines not covered, and a coverage of 100. The docs say that the coverage report includes all of the lines evaluated and not evaluated in the Rego files provided on the command line Source 30সোর্স 30.
9. Check, format, and the old syntax. Run:
cat > unused.rego <<'EOF'
package qa.unused
import data.qa.nothing
allow if {
x := 1
input.ok == true
}
EOF
opa check unused.rego
echo "opa check: exit=$?"
opa check --strict unused.rego
echo "opa check --strict: exit=$?"
printf 'package qa.fmt\n\nallow if {\ninput.ok == true\n}\n' > unformatted.rego
opa fmt --fail --list unformatted.rego
echo "opa fmt --fail --list, unformatted file: exit=$?"
opa fmt --fail --list pods.rego
echo "opa fmt --fail --list, formatted file: exit=$?"
# A policy in the old (v0) syntax: no "if" before the body, no "contains" in the set rule.
cat > v0.rego <<'EOF'
package qa.v0
deny[msg] {
c := input.spec.containers[_]
c.securityContext.privileged == true
msg := sprintf("container %v must not run privileged", [c.name])
}
EOF
opa eval --format pretty -d v0.rego -i bad-pod.json 'data.qa.v0.deny'
echo "opa eval, v0 file: exit=$?"
opa eval --v0-compatible --format pretty -d v0.rego -i bad-pod.json 'data.qa.v0.deny'
echo "opa eval --v0-compatible, v0 file: exit=$?"Output of the tutorial's run:
opa check: exit=0
2 errors occurred:
unused.rego:3: rego_compile_error: import data.qa.nothing unused
unused.rego:6: rego_compile_error: assigned var x unused
opa check --strict: exit=1
unformatted.rego
unexpected diff
opa fmt --fail --list, unformatted file: exit=2
opa fmt --fail --list, formatted file: exit=0
2 errors occurred:
v0.rego:3: rego_parse_error: `if` keyword is required before rule body
v0.rego:3: rego_parse_error: `contains` keyword is required for partial set rules
opa eval, v0 file: exit=2
[
"container c1 must not run privileged"
]
opa eval --v0-compatible, v0 file: exit=0unused.regoimportsdata.qa.nothing, and it assignsx := 1, and it uses neither.opa check unused.regoprinted nothing and exited with 0. The reference says that ifchecksucceeds in parsing and compiling the files, no output is produced Source 31সোর্স 31.opa check --strictprinted two errors,import data.qa.nothing unusedandassigned var x unused, and it exited with 1. The reference lists--strictas the option that enables the compiler strict mode Source 31সোর্স 31.opa fmt --fail --liston an unformatted file printed the file name andunexpected diff, and it exited with 2. Onpods.regoit printed nothing and exited with 0. The reference says that with--fail, the commandfmtreturns a non-zero exit code if a file would be reformatted Source 31সোর্স 31. It says that-loutputs the names of files that would change Source 31সোর্স 31.v0.regouses the old syntax. It has noifbefore the rule body and nocontainsin the rule of a set. OPA 1.22.4 printed two parse errors and exited with 2. With--v0-compatible, the same file worked, and it printed the message. The reference lists--v0-compatibleas the option that opts in to the OPA features and behaviors prior to the OPA v1.0 release Source 31সোর্স 31.- The Gatekeeper docs say that using Rego v1 syntax in a ConstraintTemplate is opt-in, and that by default only Rego v0 is allowed Source 37সোর্স 37. The template of step 11 uses the old syntax.
10. Run the OPA server and read its decision log. The step starts the server in the background, sends four requests with curl, stops the server, and reads the log:
opa run --server --addr 127.0.0.1:18181 --set decision_logs.console=true --log-level error pods.rego > opa-server.log 2>&1 &
OPA_PID=$!
for i in $(seq 1 50); do curl -s -o /dev/null http://127.0.0.1:18181/health && break; sleep 0.1; done
echo "health: $(curl -s http://127.0.0.1:18181/health)"
echo "--- bad pod, wrapped in the input key"
curl -s -X POST http://127.0.0.1:18181/v1/data/qa/pods -H 'Content-Type: application/json' -d "{\"input\": $(cat bad-pod.json)}" | sed -E 's/"decision_id":"[^"]*"/"decision_id":"..."/'
echo
echo "--- good pod, wrapped in the input key"
curl -s -X POST http://127.0.0.1:18181/v1/data/qa/pods/allow -H 'Content-Type: application/json' -d "{\"input\": $(cat good-pod.json)}" | sed -E 's/"decision_id":"[^"]*"/"decision_id":"..."/'
echo
echo "--- bad pod, NOT wrapped in the input key"
curl -s -X POST http://127.0.0.1:18181/v1/data/qa/pods/allow -H 'Content-Type: application/json' -d "$(cat bad-pod.json)" | sed -E 's/"decision_id":"[^"]*"/"decision_id":"..."/'
echo
echo "--- a path that no policy defines"
curl -s -X POST http://127.0.0.1:18181/v1/data/qa/nothing -H 'Content-Type: application/json' -d '{"input": {}}' | sed -E 's/"decision_id":"[^"]*"/"decision_id":"..."/'
echo
kill $OPA_PID
wait $OPA_PID 2> /dev/null
echo "--- decision log (the console lines of the server)"
python3 -c '
import json
for line in open("opa-server.log"):
d = json.loads(line)
print(d["msg"], "| path:", d["path"], "| result:", json.dumps(d.get("result", "undefined")), "| input logged:", "input" in d, "| custom.request_metadata logged:", "request_metadata" in d.get("custom", {}))
'Output of the tutorial's run:
health: {}
--- bad pod, wrapped in the input key
{"decision_id":"...","result":{"allow":false,"deny":["container c1 must not run privileged"]}}
--- good pod, wrapped in the input key
{"decision_id":"...","result":true}
--- bad pod, NOT wrapped in the input key
{"decision_id":"...","result":true,"warning":{"code":"api_usage_warning","message":"'input' key missing from the request"}}
--- a path that no policy defines
{"decision_id":"..."}
--- decision log (the console lines of the server)
Decision Log | path: qa/pods | result: {"allow": false, "deny": ["container c1 must not run privileged"]} | input logged: True | custom.request_metadata logged: False
Decision Log | path: qa/pods/allow | result: true | input logged: True | custom.request_metadata logged: False
Decision Log | path: qa/pods/allow | result: true | input logged: False | custom.request_metadata logged: True
Decision Log | path: qa/nothing | result: "undefined" | input logged: True | custom.request_metadata logged: False- The server listens on
127.0.0.1:18181. The docs say that local console logging of decisions can be enabled via theconsoleconfig option Source 33সোর্স 33. They showdecision_logs: console: truefor it Source 33সোর্স 33. The tutorial gave the same setting with--set decision_logs.console=true. It set--log-level errortoo, and the log file held decision log lines only. The step waited for/health, which printed{}. - The Data API takes
POST /v1/data/{path}with a JSON body of the form{"input": ...}Source 32সোর্স 32. The first request sent the bad Pod ininputto/v1/data/qa/pods. The result had both rules:allowwasfalse, anddenyhad the message. The step replaced eachdecision_idwith.... - The second request sent the good Pod to
/v1/data/qa/pods/allow, and the result wastrue. - The third request sent the bad Pod as the whole body, with no
inputkey. The result wastrue, with the warning'input' key missing from the request. The policy allowed a privileged Pod in this request. The REST page says that any additional top-level keys in the request body beyondinputare treated as request metadata Source 32সোর্স 32. The tutorial did not trace the query, and it does not say why the policy answeredtrue. - The fourth request asked for a path that no policy defines, and the response had no
resultkey. The docs say that the server returns 200 if the path refers to an undefined document Source 32সোর্স 32. They say that the response will not contain a result property in this case Source 32সোর্স 32. The step did not print the status code. - The decision log had four lines, one for each request. The
pathfield holds the hierarchical policy decision path Source 33সোর্স 33. Theinputfield holds the input data provided in the policy query Source 33সোর্স 33. Theresultfield holds the policy decision returned to the client Source 33সোর্স 33. - The third line had no
inputand hadcustom.request_metadata. The REST page says that request metadata is included in decision log events under the custom.request_metadata field Source 32সোর্স 32. The fourth line had noresultkey, and the step printedundefinedfor it. - The step stopped the server with
killandwait. After the run, the port 18181 was free, and noopaprocess was left.
11. Test a Gatekeeper template with gator. The block writes a ConstraintTemplate, a Constraint, two Pods, and three more files, and it runs gator test and gator verify:
cat > template.yaml <<'EOF'
apiVersion: templates.gatekeeper.sh/v1
kind: ConstraintTemplate
metadata:
name: qanoprivileged
spec:
crd:
spec:
names:
kind: QANoPrivileged
targets:
- target: admission.k8s.gatekeeper.sh
rego: |
package qanoprivileged
violation[{"msg": msg}] {
c := input.review.object.spec.containers[_]
c.securityContext.privileged == true
msg := sprintf("container <%v> must not run privileged", [c.name])
}
EOF
cat > constraint.yaml <<'EOF'
apiVersion: constraints.gatekeeper.sh/v1beta1
kind: QANoPrivileged
metadata:
name: no-privileged-pods
spec:
match:
kinds:
- apiGroups: [""]
kinds: ["Pod"]
EOF
cat > bad-pod.yaml <<'EOF'
apiVersion: v1
kind: Pod
metadata:
name: qa-privileged
namespace: default
spec:
containers:
- name: c1
image: busybox:1.36
securityContext:
privileged: true
EOF
sed 's/qa-privileged/qa-plain/; s/privileged: true/privileged: false/' bad-pod.yaml > good-pod.yaml
gator test -f template.yaml -f constraint.yaml -f bad-pod.yaml
echo "gator test, bad pod: exit=$?"
gator test -f template.yaml -f constraint.yaml -f good-pod.yaml
echo "gator test, good pod: exit=$?"
cat > suite.yaml <<'EOF'
kind: Suite
apiVersion: test.gatekeeper.sh/v1alpha1
tests:
- name: no-privileged
template: template.yaml
constraint: constraint.yaml
cases:
- name: privileged-pod
object: bad-pod.yaml
assertions:
- violations: 1
message: must not run privileged
- name: plain-pod
object: good-pod.yaml
assertions:
- violations: no
EOF
# A copy in which the second case expects a violation that does not happen.
sed 's/violations: no/violations: yes/' suite.yaml > suite-wrong.yaml
# A file that is not a Suite.
printf 'tests: []\n' > not-a-suite.yaml
# The run times are removed with sed, so that the output is the same in each run.
for f in suite.yaml suite-wrong.yaml not-a-suite.yaml; do
echo "--- gator verify $f"
gator verify $f 2>&1 | sed -E 's/\t\([0-9.]+s\)$//; s/\t[0-9.]+s$//'
echo "exit=${PIPESTATUS[0]}"
doneOutput of the tutorial's run:
v1/Pod default/qa-privileged: ["no-privileged-pods"] Message: "container <c1> must not run privileged"
gator test, bad pod: exit=1
gator test, good pod: exit=0
--- gator verify suite.yaml
ok suite.yaml
PASS
exit=0
--- gator verify suite-wrong.yaml
--- FAIL: plain-pod
unexpected number of violations: got 0 violations but want at least 1: got messages []
--- FAIL: no-privileged
FAIL suite-wrong.yaml
FAIL
Error: FAIL
exit=1
--- gator verify not-a-suite.yaml
PASS
exit=0template.yamlis a ConstraintTemplate namedqanoprivilegedwith the kindQANoPrivileged. It has one target,admission.k8s.gatekeeper.sh, and a Rego ruleviolationin the old syntax.constraint.yamlis a Constraint namedno-privileged-podsthat matches Pods. The docs say that ConstraintTemplates are made of two main elements Source 37সোর্স 37. One is the policy code, and the other is the schema of the Constraint Source 37সোর্স 37. In the Rego, the object under review isinput.review.object. The docs listinput.reviewas the variable that contains the input request object under review Source 37সোর্স 37.gator testtests a set of Kubernetes objects against a set of Templates and Constraints Source 38সোর্স 38. For the bad Pod, it printed one violation line with the messagecontainer <c1> must not run privileged, and the exit code was 1. For the good Pod, it printed nothing, and the exit code was 0. The docs say that the command returns violations when found and communicates success or failure via its exit status Source 38সোর্স 38.suite.yamlhas one test with two cases. The caseprivileged-podexpectsviolations: 1and the messagemust not run privileged. The caseplain-podexpectsviolations: no. The docs say thatviolationsis either "yes", "no", or a non-negative integer Source 38সোর্স 38. They say thatmessageis a regular expression used to match the violation message Source 38সোর্স 38.gator verify suite.yamlprintedok suite.yamlandPASS, and the exit code was 0.- In
suite-wrong.yaml, the second case expectsviolations: yes.gator verifyprintedFAILfor the caseplain-podwith the textunexpected number of violations: got 0 violations but want at least 1. It printedError: FAIL, and the exit code was 1. not-a-suite.yamlis the texttests: [].gator verifyprintedPASSand exited with 0. The docs say that a valid Suite file must declarekind: Suiteand anapiVersion, and thatgator verifysilently ignores files which do not declare these Source 38সোর্স 38. The tutorial did not check whatgator verifydid with this file.
12. Validate Falco rules. The block prints a few lines of the shipped rules file, validates it with and without the container plugin, writes the tutorial's own rules file, validates it, and lists its rules:
FALCO_ETC=falco-0.45.2-x86_64/etc/falco
FALCO_PLUGINS=$PWD/falco-0.45.2-x86_64/usr/share/falco/plugins
# The Falco log lines start with a time stamp. sed removes it, so that the output is the same in each run.
# The "System info" line is left out as well.
NOSTAMP='s/^[A-Z][a-z]{2} [A-Z][a-z]{2} +[0-9]+ [0-9:]+ [0-9]{4}: //'
echo "--- what the rules file of the archive asks for (lines 28 to 32)"
sed -n '28,32p' $FALCO_ETC/falco_rules.yaml
echo "--- the load_plugins line of the configuration file of the archive"
grep -n '^load_plugins:' $FALCO_ETC/falco.yaml
echo "--- the rules file of the archive, with the default configuration"
falco -c $FALCO_ETC/falco.yaml -V $FALCO_ETC/falco_rules.yaml 2>&1 | grep -v 'System info' | sed -E "$NOSTAMP"
echo "exit=${PIPESTATUS[0]}"
echo "--- the rules file of the archive, with the container plugin loaded"
falco -c $FALCO_ETC/falco.yaml -o load_plugins[0]=container -o plugins[0].library_path=$FALCO_PLUGINS/libcontainer.so -V $FALCO_ETC/falco_rules.yaml > shipped.log 2>&1
echo "exit=$?"
echo "log lines from the container plugin, left out below: $(grep -c '\[libs\]' shipped.log)"
grep -v -e '\[libs\]' -e 'System info' shipped.log | sed -E "$NOSTAMP"
cat > qa_rules.yaml <<'EOF'
- list: qa_sensitive_files
items: [/etc/shadow, /etc/sudoers]
- macro: qa_open_write
condition: >
evt.type in (open, openat, openat2) and evt.is_open_write=true and fd.typechar='f'
- rule: QA write to a sensitive file
desc: A process opened a sensitive file for writing. The rule is the tutorial's own.
condition: qa_open_write and fd.name in (qa_sensitive_files)
output: Sensitive file opened for writing (file=%fd.name process=%proc.name command=%proc.cmdline user=%user.name)
priority: WARNING
tags: [qa, filesystem]
EOF
echo "--- the tutorial's own rules file"
falco -c $FALCO_ETC/falco.yaml -V qa_rules.yaml 2>&1 | grep -v 'System info' | sed -E "$NOSTAMP"
echo "exit=${PIPESTATUS[0]}"
echo "--- the rule list"
falco -c $FALCO_ETC/falco.yaml -r qa_rules.yaml -L 2>/dev/null
echo "exit=$?"Output of the tutorial's run:
--- what the rules file of the archive asks for (lines 28 to 32)
- required_engine_version: 0.57.0
- required_plugin_versions:
- name: container
version: 0.4.0
--- the load_plugins line of the configuration file of the archive
588:load_plugins: []
--- the rules file of the archive, with the default configuration
Falco version: 0.45.2 (x86_64)
Falco initialized with configuration files:
falco-0.45.2-x86_64/etc/falco/falco.yaml | schema validation: ok
Validating rules file(s):
falco-0.45.2-x86_64/etc/falco/falco_rules.yaml
Error: Plugin requirement not satisfied, must load one of: container (>= 0.4.0)
exit=1
--- the rules file of the archive, with the container plugin loaded
exit=0
log lines from the container plugin, left out below: 14
Falco version: 0.45.2 (x86_64)
Falco initialized with configuration files:
falco-0.45.2-x86_64/etc/falco/falco.yaml | schema validation: ok
Loaded plugin 'container@0.7.6' from file /work/falco-0.45.2-x86_64/usr/share/falco/plugins/libcontainer.so
Validating rules file(s):
falco-0.45.2-x86_64/etc/falco/falco_rules.yaml
falco-0.45.2-x86_64/etc/falco/falco_rules.yaml: Ok
--- the tutorial's own rules file
Falco version: 0.45.2 (x86_64)
Falco initialized with configuration files:
falco-0.45.2-x86_64/etc/falco/falco.yaml | schema validation: ok
Validating rules file(s):
qa_rules.yaml
qa_rules.yaml: Ok
exit=0
--- the rule list
Rule Description
---- -----------
QA write to a sensitive file A process opened a sensitive file for writing. The rule is
the tutorial's own.
exit=0- Lines 28 to 32 of the shipped
falco_rules.yamlholdrequired_engine_version: 0.57.0and arequired_plugin_versionsentry for the plugincontainerin version0.4.0. The docs say thatrequired_engine_versionis used to track compatibility between rules content and the falco engine version Source 22সোর্স 22. The Falco of the run has the engine version 0.65.0 (step 1). - The docs say that rules files can have a top-level field
required_plugin_versions, to document the plugin versions that they are compatible with Source 46সোর্স 46. They say that if a plugin is loaded and an entry has a matching name, the loaded version must be semver compatible with the version of the entry Source 46সোর্স 46. falco -Vwith the default configuration printedError: Plugin requirement not satisfied, must load one of: container (>= 0.4.0)and exited with 1. Thefalco.yamlof the archive hasload_plugins: []at line 588.- The second command loaded the plugin with two
-ooptions. The docs say that any configuration option can be overridden on the command line with-o/--option key=valueSource 44সোর্স 44. They say that you can override a specific entry of a list by index, as in--option key.subkey[0]=valueSource 44সোর্স 44. The docs say that thepluginsproperty defines the set of plugins that Falco can load, and that theload_pluginsproperty controls which plugins are loaded when Falco starts Source 46সোর্স 46. - With the plugin, Falco printed
Loaded plugin 'container@0.7.6'andfalco_rules.yaml: Ok, and it exited with 0. The step left out 14 log lines of the plugin. - The packages page says that on RHEL 8 / UBI 8 systems with glibc older than 2.34, the container plugin bundled with Falco 0.42 to 0.44.x may fail to load with an undefined symbol, and that Falco 0.45.0 bundles a fixed version Source 41সোর্স 41. The glibc of the tutorial's machine is 2.43.
qa_rules.yamlis the tutorial's own file. It has a list, a macro, and a rule with the priorityWARNING. The docs say that a rules file is a YAML file with mainly three types of elements Source 22সোর্স 22. Falco validated it withqa_rules.yaml: Okand exit code 0. A rule has at least the fieldsrule,desc,condition,output, andprioritySource 23সোর্স 23.falco -r qa_rules.yaml -Lprinted the name and the description of the rule. The reference says that-Lshows the name and description of all rules and exits Source 25সোর্স 25.
13. Break the rule on purpose. The block makes three copies of qa_rules.yaml, each with one mistake, and it validates each copy with -V:
FALCO_ETC=falco-0.45.2-x86_64/etc/falco
# Three copies of the rules file, each with one mistake.
sed 's/fd.name in (qa_sensitive_files)/fd.nam in (qa_sensitive_files)/' qa_rules.yaml > qa_bad_field.yaml
sed 's/qa_open_write and/qa_open_writes and/' qa_rules.yaml > qa_bad_macro.yaml
sed 's/priority: WARNING/priority: LOUD/' qa_rules.yaml > qa_bad_priority.yaml
# stdout only (stderr is dropped).
for f in qa_bad_field.yaml qa_bad_macro.yaml qa_bad_priority.yaml; do
echo "--- $f"
falco -c $FALCO_ETC/falco.yaml -V $f 2> /dev/null
echo "exit=$?"
doneOutput of the tutorial's run:
--- qa_bad_field.yaml
qa_bad_field.yaml: Invalid
1 Errors:
In rules content: (qa_bad_field.yaml:0:0)
rule 'QA write to a sensitive file': (qa_bad_field.yaml:7:2)
rule condition: (qa_bad_field.yaml:9:13)
condition expression: ("qa_open_write and...":10:32)
------
qa_open_write and fd.nam in (qa_sensitive_files)
^
------
LOAD_ERR_COMPILE_CONDITION (Error compiling condition): filter_check called with nonexistent field fd.nam
exit=1
--- qa_bad_macro.yaml
qa_bad_macro.yaml: Invalid
1 Errors:
In rules content: (qa_bad_macro.yaml:0:0)
rule 'QA write to a sensitive file': (qa_bad_macro.yaml:7:2)
condition expression: ("qa_open_writes an...":8:3)
------
qa_open_writes and fd.name in (qa_sensitive_files)
^
------
LOAD_ERR_VALIDATE (Error validating rule/macro/list/exception objects): Undefined macro 'qa_open_writes' used in filter.
exit=1
--- qa_bad_priority.yaml
qa_bad_priority.yaml: Invalid
3 Schema warnings:
------
failed for <root>[2][priority]: Failed to match against any enum values.
------
failed for <root>[2]: Failed to validate against schema associated with property name 'priority'.
------
failed for <root>: Failed to validate item #2 in array.
------
1 Errors:
In rules content: (qa_bad_priority.yaml:0:0)
rule 'QA write to a sensitive file': (qa_bad_priority.yaml:7:2)
rule priority: (qa_bad_priority.yaml:11:12)
------
priority: LOUD
^
------
LOAD_ERR_YAML_VALIDATE (Error validating internal structure of YAML file): Invalid priority
exit=1qa_bad_field.yamlhasfd.namin place offd.name. Falco printedInvalid, thenLOAD_ERR_COMPILE_CONDITION (Error compiling condition): filter_check called with nonexistent field fd.nam. It printed the condition with a^under the place of the error, and the exit code was 1. The docs say that--listlists all defined fields, so you can look up the right field name Source 25সোর্স 25. The tutorial did not run it.qa_bad_macro.yamlhasqa_open_writesin place ofqa_open_write. Falco printedLOAD_ERR_VALIDATE (Error validating rule/macro/list/exception objects): Undefined macro 'qa_open_writes' used in filter., and the exit code was 1. The docs say that macros are rule condition snippets that can be re-used inside rules and even other macros Source 22সোর্স 22.qa_bad_priority.yamlhaspriority: LOUD. Falco printed3 Schema warnings,1 Errors, andLOAD_ERR_YAML_VALIDATE (Error validating internal structure of YAML file): Invalid priority, and the exit code was 1. The docs list the available priorities Source 23সোর্স 23.- Each output starts with the file name and the word
Invalid. The step printed stdout only, and it dropped stderr.
14. Install the audit plugin and its rules with falcoctl. Run:
mkdir plugins rules state assets
# The log lines start with a date and a time. sed removes them. The order of the three artifacts can differ from run to run.
falcoctl artifact install k8saudit:0.18.0 json:0.7.4 k8saudit-rules:0.18.0 \
--config falco-0.45.2-x86_64/etc/falcoctl/falcoctl.yaml \
--plugins-dir plugins --rulesfiles-dir rules --state-dir state --assets-dir assets \
--log-format text 2>&1 | sed -E 's/^[0-9-]+ [0-9:]+ //'
echo "exit=${PIPESTATUS[0]}"
ls plugins rules
# The two rules that step 15 triggers (the line numbers show their order in the file), and the lists that have the user kubernetes-admin.
grep -n -A 2 -E '^- rule: (Disallowed K8s User|Create Privileged Pod)$' rules/k8s_audit_rules.yaml
awk '/^- list: /{name=$3} /"kubernetes-admin",/{print "line " NR ": in the list " name}' rules/k8s_audit_rules.yamlOutput of the tutorial's run:
INFO Resolving dependencies ...
INFO Installing artifacts
└ refs: [ghcr.io/falcosecurity/plugins/ruleset/k8saudit:0.18.0 ghcr.io/falcosecurity/plugins/plugin/k8saudit:0.18.0 ghcr.io/falcosecurity/plugins/plugin/json:0.7.4]
INFO Preparing to pull artifact
└ ref: ghcr.io/falcosecurity/plugins/ruleset/k8saudit:0.18.0
INFO Pulling layer 8324f17dce60
INFO Pulling layer d213d53c736a
INFO Pulling layer ffb6b16fb785
INFO Verifying signature for artifact
└ digest: ghcr.io/falcosecurity/plugins/ruleset/k8saudit@sha256:ffb6b16fb78585f9658b75847c511220b4915cf62805261340bcc173906d7d7c
INFO Signature successfully verified!
INFO Extracting and installing artifact
├ type: rulesfile
└ file: k8saudit-rules-0.18.0.tar.gz
INFO Artifact successfully installed
├ name: ghcr.io/falcosecurity/plugins/ruleset/k8saudit:0.18.0
├ type: rulesfile
├ digest: sha256:ffb6b16fb78585f9658b75847c511220b4915cf62805261340bcc173906d7d7c
└ directory: rules
INFO Preparing to pull artifact
└ ref: ghcr.io/falcosecurity/plugins/plugin/k8saudit:0.18.0
INFO Pulling layer 894b71ec239d
INFO Pulling layer 180046ef8a1c
INFO Pulling layer ecfeb7378165
INFO Verifying signature for artifact
└ digest: ghcr.io/falcosecurity/plugins/plugin/k8saudit@sha256:ca794b24fee51095579b63b4e8a57030de6e3a8489bcd11d1960aa26a021308f
INFO Signature successfully verified!
INFO Extracting and installing artifact
├ type: plugin
└ file: k8saudit-0.18.0-linux-x86_64.tar.gz
INFO Artifact successfully installed
├ name: ghcr.io/falcosecurity/plugins/plugin/k8saudit:0.18.0
├ type: plugin
├ digest: sha256:ecfeb737816523d949660404d7a1a4a1dbcaecf785bfb84a1c48a06e899ebb85
└ directory: plugins
INFO Preparing to pull artifact
└ ref: ghcr.io/falcosecurity/plugins/plugin/json:0.7.4
INFO Pulling layer 47b0c10d399d
INFO Pulling layer d1370d6387f9
INFO Pulling layer 9f898f44312d
INFO Verifying signature for artifact
└ digest: ghcr.io/falcosecurity/plugins/plugin/json@sha256:b867a72796552499e3212f5b7af51cbeb5587348041f72d6f2131c575f6fb312
INFO Signature successfully verified!
INFO Extracting and installing artifact
├ type: plugin
└ file: json-0.7.4-linux-x86_64.tar.gz
INFO Artifact successfully installed
├ name: ghcr.io/falcosecurity/plugins/plugin/json:0.7.4
├ type: plugin
├ digest: sha256:9f898f44312dd433ca507190e759277b34d7558cf4a378f97e9b46d705da5f72
└ directory: plugins
exit=0
plugins:
libjson.so
libk8saudit.so
rules:
k8s_audit_rules.yaml
154:- rule: Disallowed K8s User
155- desc: Detect any k8s operation by users outside of an allowed set of users.
156- condition: kevt and non_system_user and not ka.user.name in (allowed_k8s_users) and not ka.user.name in (eks_allowed_k8s_users)
--
247:- rule: Create Privileged Pod
248- desc: >
249- Detect an attempt to start a pod with a privileged container
line 74: in the list allowed_k8s_users
line 783: in the list full_admin_k8s_usersfalcoctl artifact installtook three names:k8saudit:0.18.0,json:0.7.4, andk8saudit-rules:0.18.0. It used the configuration file of the archive (--config), and it put the files in folders of the run (--plugins-dir,--rulesfiles-dir,--state-dir, and--assets-dir). The versions are the tutorial's own choice. The Falco docs say that the install command of falcoctl downloads rules files to a configurable directory, which is/etc/falcoby default Source 43সোর্স 43.- In the output, falcoctl resolved the three names to
ghcr.io/falcosecurity/plugins/plugin/k8saudit:0.18.0,ghcr.io/falcosecurity/plugins/plugin/json:0.7.4, andghcr.io/falcosecurity/plugins/ruleset/k8saudit:0.18.0. It pulled three layers of each artifact. For each artifact it printedVerifying signature for artifactandSignature successfully verified!. The tutorial did not look at how falcoctl checks a signature or at the key that it uses. lsshowedlibjson.soandlibk8saudit.soinplugins, andk8s_audit_rules.yamlinrules. The README of the plugin says that the official ruleset depends on the json plugin Source 45সোর্স 45. The step installsjsontoo.- The last two commands read the rules file.
Disallowed K8s Useris at line 154, and its condition ends withnot ka.user.name in (allowed_k8s_users) and not ka.user.name in (eks_allowed_k8s_users).Create Privileged Podis at line 247, and its description isDetect an attempt to start a pod with a privileged container. The userkubernetes-adminis in the listallowed_k8s_users(line 74) and in the listfull_admin_k8s_users(line 783). The docs say that lists are collections of items that can be included in rules, macros, or other lists Source 22সোর্স 22. The tutorial did not print the other names of the lists.
15. Read Kubernetes audit events from a file. The block writes three audit events as JSON Lines and a Falco configuration, and it runs Falco twice:
# One Kubernetes audit event, as one line of JSON: the user kubernetes-admin creates a Pod with a privileged container.
cat > event-privileged.json <<'EOF'
{"kind":"Event","apiVersion":"audit.k8s.io/v1","level":"RequestResponse","auditID":"11111111-2222-3333-4444-555555555555","stage":"ResponseComplete","requestURI":"/api/v1/namespaces/default/pods","verb":"create","user":{"username":"kubernetes-admin","groups":["system:authenticated"]},"sourceIPs":["10.0.0.5"],"userAgent":"kubectl/v1.37.2","objectRef":{"resource":"pods","namespace":"default","name":"qa-privileged","apiVersion":"v1"},"responseStatus":{"metadata":{},"code":201},"requestObject":{"kind":"Pod","apiVersion":"v1","metadata":{"name":"qa-privileged","namespace":"default"},"spec":{"containers":[{"name":"c1","image":"busybox:1.36","securityContext":{"privileged":true}}]}},"responseObject":{"kind":"Pod","apiVersion":"v1","metadata":{"name":"qa-privileged","namespace":"default"}},"requestReceivedTimestamp":"2026-11-20T01:40:00.000000Z","stageTimestamp":"2026-11-20T01:40:00.100000Z"}
EOF
# The same event from another user, and the same event without the privileged setting.
sed 's/"username":"kubernetes-admin"/"username":"qa-user"/' event-privileged.json > event-other-user.json
sed 's/"privileged":true/"privileged":false/' event-privileged.json > event-plain.json
cat event-privileged.json event-other-user.json event-plain.json > audit.jsonl
echo "events in audit.jsonl: $(wc -l < audit.jsonl)"
# A small Falco configuration: the two plugins, the rules file, and the audit file as the source of events.
cat > falco-audit.yaml <<EOF
rules_files:
- $PWD/rules/k8s_audit_rules.yaml
load_plugins: [k8saudit, json]
plugins:
- name: k8saudit
library_path: $PWD/plugins/libk8saudit.so
init_config: ""
open_params: "$PWD/audit.jsonl"
- name: json
library_path: $PWD/plugins/libjson.so
stdout_output:
enabled: true
EOF
# stdout only (stderr is dropped). sed removes the time at the start of each alert line.
echo "--- the default setting"
falco -c falco-audit.yaml --disable-source syscall 2> /dev/null | sed -E 's/^[0-9:.]+: //'
echo "exit=${PIPESTATUS[0]}"
echo "--- -o rule_matching=all"
falco -c falco-audit.yaml --disable-source syscall -o rule_matching=all 2> /dev/null | sed -E 's/^[0-9:.]+: //'
echo "exit=${PIPESTATUS[0]}"Output of the tutorial's run:
events in audit.jsonl: 3
--- the default setting
Warning Pod started with privileged container (user=kubernetes-admin pod=qa-privileged resource=pods ns=default images=(busybox:1.36) init_images=<NA> ephemeral_images=<NA>)
Warning K8s Operation performed by user not in allowed list of users (user=qa-user target=qa-privileged/pods verb=create uri=/api/v1/namespaces/default/pods resp=201)
Events detected: 2
Rule counts by severity:
WARNING: 2
Triggered rules by rule name:
Disallowed K8s User: 1
Create Privileged Pod: 1
exit=0
--- -o rule_matching=all
Warning Pod started with privileged container (user=kubernetes-admin pod=qa-privileged resource=pods ns=default images=(busybox:1.36) init_images=<NA> ephemeral_images=<NA>)
Warning K8s Operation performed by user not in allowed list of users (user=qa-user target=qa-privileged/pods verb=create uri=/api/v1/namespaces/default/pods resp=201)
Warning Pod started with privileged container (user=qa-user pod=qa-privileged resource=pods ns=default images=(busybox:1.36) init_images=<NA> ephemeral_images=<NA>)
Events detected: 3
Rule counts by severity:
WARNING: 3
Triggered rules by rule name:
Disallowed K8s User: 1
Create Privileged Pod: 2
exit=0event-privileged.jsonis one audit event. The userkubernetes-admincreates the Podqa-privilegedwith a privileged container (verbcreate, resourcepods, response code 201).event-other-user.jsonis the same event from the userqa-user.event-plain.jsonis the same event withprivilegedset tofalse.audit.jsonlhas the three events, one on each line. The events are the tutorial's own.- The README of the plugin says that it supports Kubernetes audit events from the Webhook backend or from a file Source 45সোর্স 45. For a file, the plugin expects JSONL, where each line is a JSON object with one or more audit events Source 45সোর্স 45. The README says that the expected way to use the plugin with Falco is a Webhook, and that file reading can be used for testing and development Source 45সোর্স 45. The Falco docs say that, to receive Kubernetes audit events, the plugin embeds a webserver that listens on a configurable port and accepts POST requests on a configurable endpoint Source 47সোর্স 47. The tutorial read a file and ran no webserver.
falco-audit.yamlis the tutorial's own configuration. It lists the rules file of step 14,load_plugins: [k8saudit, json], the two plugins with their library paths, and the file inopen_params. The README says that a parameter with no scheme is read as a file path Source 45সোর্স 45. Its sample has the sameload_pluginslist Source 45সোর্স 45.- The
--disable-sourceoption turns off a specific event source Source 25সোর্স 25. The step gave itsyscall. The docs say that for plugin-based deployments, you disable syscall explicitly or enable only the desired plugin-based sources Source 19সোর্স 19. - With the default setting, Falco printed two alerts for the three events, and
Events detected: 2. The first event raisedPod started with privileged containerforkubernetes-admin. The second event raisedK8s Operation performed by user not in allowed list of usersforqa-user. The third event raised no alert. The step removed the time at the start of each alert line. - The second event is a privileged Pod too, and in the default setting it did not raise
Create Privileged Pod. In the rules file of step 14,Disallowed K8s Useris defined at line 154 andCreate Privileged Podat line 247. The docs say that by default Falco applies rules per event type on a "first match wins" basis Source 24সোর্স 24. They say that the way to control the order in which rules are triggered is to change the order in which the rules are defined, and therefore loaded Source 23সোর্স 23. In this run, the alert of the second event came from the rule that is defined first. - With
-o rule_matching=all, Falco printed three alerts andEvents detected: 3. The second event raised both rules, andCreate Privileged Podwas counted twice. The docs say that from Falco 0.36.0 you can change the configuration torule_matching: allSource 24সোর্স 24. They say that this change ensures that rules sharing the same event type cannot override each other Source 24সোর্স 24. They warn that it may lead to increased CPU usage Source 24সোর্স 24. The tutorial did not measure CPU. - Falco exited with 0 in both runs, although it raised alerts. In this run, the exit code did not show the alerts.
বাংলা ব্যাখ্যা
টিউটোরিয়াল ১ থেকে ১৫ নম্বর ধাপ চালিয়েছে 2026-11-20 তারিখে 02:24-এ (+06), Linux 7.0.0-43-generic-এ। সংস্করণগুলো ছিল istioctl 1.32.0, OPA 1.22.4, gator v3.23.1, Falco 0.45.2 আর falcoctl 0.14.3। সহায়ক tool ছিল Python 3.14.4, curl 8.18.0 আর bash 5.3.9। এই page-এর output টিউটোরিয়ালের run থেকে নেওয়া। প্রতিটা ধাপ চলেছে runner-এর একটা subshell-এ, একটা নতুন folder-এ, একটা নতুন, খালি HOME দিয়ে। page-এ run-এর folder দেখানো হয়েছে /work নামে।
run-এর কোনো cluster, Docker বা root অধিকার লাগে না। istioctl শুধু স্থানীয় file পড়ে (--use-kube=false)। OPA আর gator স্থানীয় file-এ কাজ করে। OPA server কেবল 127.0.0.1:18181-এ শোনে। Falco একটা file থেকে audit event পড়ে, আর কোনো kernel driver load করে না। ১৪ নম্বর ধাপ ghcr.io থেকে তিনটা artifact নামায়। run-এর পরে আসল home folder-এ কোনো নতুন entry ছিল না, আর tool-এর folder-এ কোনো file যোগ বা বাদ পড়েনি। port 18181 খালি ছিল, আর run কোনো opa বা falco process ফেলে যায়নি। ধাপগুলোর পরে run-এর খালি home folder-এ একটা entry ছিল: .sigstore, ২৩টা file-সহ। কোন command সেটা বানিয়েছে, টিউটোরিয়াল তা যাচাই করেনি।
যে সিদ্ধান্ত কোনো source দেয় না, সেগুলো টিউটোরিয়ালের নিজের। সেগুলো হলো Istio-র file-গুলো (shop namespace, reviews service, আর v1 ও v2 subset), pods.rego policy আর তার test, Gatekeeper-এর qanoprivileged template, QA write to a sensitive file rule, তিনটা audit event, আর port 18181। টিউটোরিয়াল Istio কোনো cluster-এ চালায়নি। run-এ কোনো sidecar, ambient data plane, traffic বা mutual TLS handshake নেই। সে Gatekeeper-এর admission webhook বা audit কোনো cluster-এ চালায়নি। সে OPA-কে Envoy-র সঙ্গে বা Terraform plan-এর সঙ্গে চালায়নি। সে Falco-কে driver-সহ চালায়নি। কোনো syscall event পড়া হয়নি। সে event-generator চালায়নি। সে শুধু Linux-এ চলেছে।
tool-গুলো install করুন। টিউটোরিয়ালের install script চারটা tool ব্যবহারকারীর home folder-এ রেখেছে, sudo ছাড়া। সে প্রতিটা archive নিয়েছে তার project-এর release-এর জায়গা থেকে। istioctl আর gator এসেছে GitHub release থেকে, OPA openpolicyagent.org/downloads থেকে, আর Falco download.falco.org থেকে। OPA docs বলে, সব binary-র checksum download path-এ পাওয়া যায় Source 27সোর্স 27। script OPA binary-র SHA-256 সেই file-এর সঙ্গে মিলিয়েছে। istioctl আর gator-এর জন্য সে archive-এর SHA-256 মিলিয়েছে একই GitHub release-এর checksum file-এর সঙ্গে। এই বাছাই টিউটোরিয়ালের নিজের।
Falco archive-এর কোনো checksum file টিউটোরিয়াল খুঁজে পায়নি। runner download.falco.org-এ archive-এর পাশে দশটা file-এর নাম চেয়েছে, আর কেবল archive আর তার .asc file 200 দিয়ে সাড়া দিয়েছে:
200 falco-0.45.2-x86_64.tar.gz
200 falco-0.45.2-x86_64.tar.gz.asc
404 falco-0.45.2-x86_64.tar.gz.sig
404 falco-0.45.2-x86_64.tar.gz.sha256
404 falco-0.45.2-x86_64.tar.gz.sha256sum
404 falco-0.45.2-x86_64.tar.gz.sha512
404 falco-0.45.2-x86_64.tar.gz.md5
404 falco-0.45.2-x86_64.tar.gz.cert
404 falco-0.45.2-x86_64.tar.gz.pem
404 falco-0.45.2-x86_64.tar.gz.bundleFalco packages page বলে falcosecurity GPG key বিশ্বাস করতে Source 41সোর্স 41। সে key file দিয়েছে https://falco.org/repo/falcosecurity-packages.asc-এ Source 41সোর্স 41। script সেই key একটা অস্থায়ী GnuPG home-এ import করেছে আর .asc file archive-এর সঙ্গে মিলিয়েছে। signature ভালো ছিল, আর তার primary key ছিল 478B2FBBC75F4237B731DA4365106822B35B1B1F। script সেই fingerprint দ্বিতীয় কোনো source-এর সঙ্গে মেলায়নি। istioctl, OPA আর gator-এর checksum file আর archive একই host থেকে আসে। Falco-র key আসে falco.org থেকে আর archive download.falco.org থেকে। টিউটোরিয়াল এই যাচাইগুলোকে নষ্ট বা বদলে দেওয়া archive ধরার উপায় হিসেবে দেখে, কে বানিয়েছে তার প্রমাণ হিসেবে নয়। install-এর রেকর্ড:
istioctl 1.32.0; sha256 4771175dec92527cd90ddc7edb3b3abcb32ca2f3bc32b31aa31e0b12ad36f897
opa v1.22.4; sha256 b76461cf4db0f77946ef557d727a1da5d7a22ba930844678c9be0bebd2c9d0f6
gator v3.23.1; sha256 c268d7b809c9fe59a110ab0bf7c296ab00b0b6c894c209cd15e94194590291bb
falco 0.45.2; sha256 b2e9961e51601095765c6c644329673e6af2f06c02357d0e77da0f680e4910da; signature good, primary key 478B2FBBC75F4237B731DA4365106822B35B1B1Fআপনার নিজের terminal-এ istioctl, opa আর gator-কে PATH-এ রাখুন। practice-এর folder-এ Falco archive খুলুন, আর তার usr/bin folder PATH-এ রাখুন। ধাপগুলো falco আর falcoctl নাম ধরে ডাকে। Falco docs-এর tarball page archive tar দিয়ে খোলে আর /-এ কপি করে Source 26সোর্স 26। টিউটোরিয়াল /-এ কিছুই কপি করেনি। page আরও বলে, bundled plugin-সহ Falco-র GLIBC 2.28 বা নতুন সংস্করণ লাগে Source 26সোর্স 26। টিউটোরিয়ালের machine-এর glibc 2.43।
১. tool-গুলো দেখে নিন। practice-এর folder-এ এটা চালান। প্রথম command Falco archive খোলে:
tar -xzf falco-0.45.2-x86_64.tar.gz
istioctl version --remote=false
opa version | head -n 1
gator --version
falco --version
falcoctl versionটিউটোরিয়ালের run-এর output:
client version: 1.32.0
Version: 1.22.4
gator version v3.23.1 (Feature State: beta), opa/v1.17.1, frameworks/v0.0.0-20260616163050-e1eaa1bf6d62
Falco version: 0.45.2
Libs version: 0.26.1
Plugin API: 3.12.0
Engine: 0.65.0
Driver:
API version: 11.0.0
Schema version: 4.3.0
Default driver: 11.0.1+driver
Client Version: 0.14.3istioctl version --remote=falseছাপিয়েছেclient version: 1.32.0। reference বলে, control plane check বন্ধ করতে--remote=falseব্যবহার করুন Source 16সোর্স 16।opa versionতার প্রথম লাইনে ছাপিয়েছেVersion: 1.22.4। ধাপটাhead -n 1দিয়ে সেখানেই output কেটেছে।gator --versionছাপিয়েছেv3.23.1 (Feature State: beta), আর একই লাইনেopa/v1.17.1আছে। run-এরopabinary 1.22.4। দুটো সংখ্যা আলাদা, আর gator-এর লাইনেরopa/v1.17.1কিসের কথা বলে, টিউটোরিয়াল তা খুঁজে বের করেনি।falco --versionছাপিয়েছে 0.45.2, সঙ্গে libs, plugin API আর engine-এর সংস্করণ।falcoctl versionছাপিয়েছেClient Version: 0.14.3।- এই command-গুলো শুধু সংস্করণ ছাপে। Falco docs বলে, falcoctl Falco-র সঙ্গেই বান্ডল করা Source 18সোর্স 18।
২. পাঁচটা profile-এর install manifest বানান। চালান:
for p in default demo minimal ambient empty; do
istioctl manifest generate --set profile=$p > manifest-$p.yaml
echo "$p: $(grep -c '^kind:' manifest-$p.yaml) objects; workloads: $(awk '/^kind: (Deployment|DaemonSet)$/ {k=$2; w=1; next} w && /^ name:/ {print k "/" $2; w=0}' manifest-$p.yaml | tr '\n' ' ')"
doneটিউটোরিয়ালের run-এর output:
default: 39 objects; workloads: Deployment/istio-ingressgateway Deployment/istiod
demo: 42 objects; workloads: Deployment/istio-egressgateway Deployment/istio-ingressgateway Deployment/istiod
minimal: 33 objects; workloads: Deployment/istiod
ambient: 44 objects; workloads: DaemonSet/istio-cni-node DaemonSet/ztunnel Deployment/istiod
empty: 0 objects; workloads: - loop প্রতিটা profile-এর manifest একটা file-এ লিখেছে আর
kind:দিয়ে শুরু হওয়া লাইন গুনেছে। object-এর সংখ্যা আর workload-এর তালিকা profile তুলনা করার টিউটোরিয়ালের নিজের উপায়। - reference বলে,
istioctl manifest generateএকটা Istio install manifest তৈরি করে আর ডিফল্টভাবে console-এ ছাপে Source 16সোর্স 16। ধাপটা output file-এ লিখেছে, আর কিছুই প্রয়োগ করেনি। emptyprofile দিয়েছে ০টা object। docs বলে, empty profile কিছুই deploy করে না Source 14সোর্স 14।minimalprofile দিয়েছে ৩৩টা object, আর তার একমাত্র workloadistiod। docs বলে, minimal profile default profile-এর মতোই, কিন্তু শুধু control plane component install হয় Source 14সোর্স 14।defaultprofile দিয়েছে ৩৯টা object,istio-ingressgatewayআরistiod-সহ।demoprofile দিয়েছে ৪২টা object,istio-egressgatewayযোগ হয়ে। traffic management page বলে, demo installation-এ দুটো gateway-ই deploy হয়, আর default profile-এ শুধু ingress gateway Source 11সোর্স 11।ambientprofile দিয়েছে ৪৪টা object। তার workload হলোistio-cni-nodeআরztunnelDaemonSet, আরistiod। ambient overview ztunnel secure overlay-কে ambient mode-এর ভিত্তি বলে Source 10সোর্স 10।
৩. একটা ভালো Istio file পরীক্ষা করুন। command block mesh-good.yaml লেখে, তারপর file-টা analyze করে:
cat > mesh-good.yaml <<'EOF'
apiVersion: v1
kind: Namespace
metadata:
name: shop
labels:
istio-injection: enabled
---
apiVersion: v1
kind: Service
metadata:
name: reviews
namespace: shop
spec:
selector:
app: reviews
ports:
- name: http
port: 9080
---
apiVersion: networking.istio.io/v1
kind: Gateway
metadata:
name: shop-gateway
namespace: shop
spec:
selector:
istio: ingressgateway
servers:
- port:
number: 80
name: http
protocol: HTTP
hosts:
- "shop.example.com"
---
apiVersion: networking.istio.io/v1
kind: VirtualService
metadata:
name: reviews
namespace: shop
spec:
hosts:
- reviews
http:
- route:
- destination:
host: reviews
subset: v1
weight: 80
- destination:
host: reviews
subset: v2
weight: 20
---
apiVersion: networking.istio.io/v1
kind: DestinationRule
metadata:
name: reviews
namespace: shop
spec:
host: reviews
subsets:
- name: v1
labels:
version: v1
- name: v2
labels:
version: v2
EOF
cat > mesh-bad.yaml <<'EOF'
apiVersion: v1
kind: Namespace
metadata:
name: shop
---
apiVersion: v1
kind: Service
metadata:
name: reviews
namespace: shop
spec:
selector:
app: reviews
ports:
- name: http
port: 9080
---
apiVersion: networking.istio.io/v1
kind: VirtualService
metadata:
name: reviews
namespace: shop
spec:
hosts:
- reviews
gateways:
- bogus-gateway
http:
- route:
- destination:
host: reviews
subset: v3
---
apiVersion: networking.istio.io/v1
kind: DestinationRule
metadata:
name: reviews
namespace: shop
spec:
host: reviews
subsets:
- name: v1
labels:
version: v1
EOF
istioctl analyze --use-kube=false -A mesh-good.yaml
echo "exit=$?"টিউটোরিয়ালের run-এর output:
✔ No validation issues found when analyzing mesh-good.yaml.
exit=0- file-এ আছে
istio-injection: enabledlabel-যুক্ত একটা Namespaceshop, একটা Servicereviews, একটা Gateway, একটা VirtualService আর একটা DestinationRule। VirtualService ৮০ % request পাঠায়v1subset-এ আর ২০ %v2-তে। DestinationRule দুটো subset-ই সংজ্ঞায়িত করে। - file-এ সেই Namespace আর Service-ও আছে, যেগুলোর কথা অন্য object বলে। docs বলে, স্থানীয় file-এর একটা সেট সম্পূর্ণ স্বয়ংসম্পূর্ণ হওয়ার কথা Source 15সোর্স 15।
istioctl analyze --use-kube=false -A mesh-good.yamlছাপিয়েছেNo validation issues found when analyzing mesh-good.yaml.আর 0 দিয়ে বেরিয়েছে। docs একটা namespace-এর জন্য একই ধরনের message দেখায় Source 15সোর্স 15।- টিউটোরিয়ালের file-গুলো তার নিজের। সেগুলো ছোট, আর কোনো আসল mesh-এর নমুনা নয়।
৪. একটা খারাপ file পরীক্ষা করুন, namespace option দিয়ে আর ছাড়া। ৩ নম্বর ধাপ mesh-bad.yaml-ও লিখেছিল। চালান:
echo "--- no namespace option"
istioctl analyze --use-kube=false mesh-bad.yaml
echo "exit=$?"
echo "--- -A (all namespaces)"
istioctl analyze --use-kube=false -A mesh-bad.yaml
echo "exit=$?"
echo "--- -n shop"
istioctl analyze --use-kube=false -n shop mesh-bad.yaml
echo "exit=$?"টিউটোরিয়ালের run-এর output:
--- no namespace option
✔ No validation issues found when analyzing mesh-bad.yaml.
exit=0
--- -A (all namespaces)
Error [IST0101] (VirtualService shop/reviews mesh-bad.yaml:27) Referenced gateway not found: "bogus-gateway"
Error [IST0101] (VirtualService shop/reviews mesh-bad.yaml:31) Referenced host+subset in destinationrule not found: "reviews+v3"
Warning [IST0132] (VirtualService shop/reviews mesh-bad.yaml:27) one or more host [reviews] defined in VirtualService shop/reviews not found in Gateway shop/bogus-gateway.
Error: Analyzers found issues when analyzing all namespaces.
See https://istio.io/v1.32/docs/reference/config/analysis for more information about causes and resolutions.
exit=79
--- -n shop
Error [IST0101] (VirtualService shop/reviews mesh-bad.yaml:27) Referenced gateway not found: "bogus-gateway"
Error [IST0101] (VirtualService shop/reviews mesh-bad.yaml:31) Referenced host+subset in destinationrule not found: "reviews+v3"
Warning [IST0132] (VirtualService shop/reviews mesh-bad.yaml:27) one or more host [reviews] defined in VirtualService shop/reviews not found in Gateway shop/bogus-gateway.
Error: Analyzers found issues when analyzing namespace: shop.
See https://istio.io/v1.32/docs/reference/config/analysis for more information about causes and resolutions.
exit=79mesh-bad.yaml-এ একটা VirtualService আছে, যাbogus-gatewaygateway আরv3subset-এর নাম নেয়। তার DestinationRule-এ কেবলv1subset আছে।- কোনো namespace option ছাড়া
istioctl analyze --use-kube=false mesh-bad.yamlছাপিয়েছেNo validation issues found when analyzing mesh-bad.yaml.আর 0 দিয়ে বেরিয়েছে। কেন, টিউটোরিয়াল তা খুঁজে বের করেনি। reference--namespace-এর একটা খালি default দেখায় Source 16সোর্স 16। -Aদিয়ে সে তিনটা message ছাপিয়েছে আরError: Analyzers found issues when analyzing all namespaces.exit code ছিল 79। docs একটা namespace-এর জন্য একই বাক্য দেখায় Source 15সোর্স 15।-n shopদিয়ে সে একই তিনটা message আরError: Analyzers found issues when analyzing namespace: shop.ছাপিয়েছে। exit code ছিল 79।- প্রতিটা message-এ থাকে একটা level, একটা code, resource-এর kind আর নাম, file আর লাইন, আর একটা লেখা।
- দুটো
IST0101error এমন একটা gateway আর এমন একটা host-সহ subset-এর নাম নেয়, যা নেই। docs বলে, এই message ঘটে যখন একটা Istio resource এমন আরেকটা resource-এর কথা বলে, যা নেই Source 17সোর্স 17। message-এর তালিকা তার নাম দেয় ReferencedResourceNotFound Source 42সোর্স 42। - message-এর তালিকা
IST0132-এর নাম দেয় VirtualServiceHostNotFoundInGateway Source 42সোর্স 42। - টিউটোরিয়ালের run-এ exit code ছিল 79। সংখ্যাটার অর্থ টিউটোরিয়াল খুঁজে দেখেনি।
৫. severity, exit code আর JSON output। চালান:
# A copy of the good file in which the VirtualService names the gateway shop-gateway, which does not list the host "reviews".
sed 's/^ - reviews$/&\n gateways:\n - shop-gateway/' mesh-good.yaml > mesh-warn.yaml
istioctl analyze --use-kube=false -A mesh-warn.yaml
for level in Error Warning Info; do
istioctl analyze --use-kube=false -A --failure-threshold $level mesh-warn.yaml > /dev/null 2>&1
echo "mesh-warn.yaml, --failure-threshold $level: exit=$?"
done
istioctl analyze --use-kube=false -A mesh-bad.yaml > /dev/null 2>&1
echo "mesh-bad.yaml, default output: exit=$?"
istioctl analyze --use-kube=false -A -o json mesh-bad.yaml > bad.json 2> bad.err
echo "mesh-bad.yaml, -o json: exit=$?"
python3 -c 'import json; print([(m["code"], m["level"]) for m in json.load(open("bad.json"))])'
echo "analyzers: $(istioctl analyze -L | grep -c '^\* ')"টিউটোরিয়ালের run-এর output:
Warning [IST0132] (VirtualService shop/reviews mesh-warn.yaml:45) one or more host [reviews] defined in VirtualService shop/reviews not found in Gateway shop/shop-gateway.
mesh-warn.yaml, --failure-threshold Error: exit=0
mesh-warn.yaml, --failure-threshold Warning: exit=79
mesh-warn.yaml, --failure-threshold Info: exit=79
mesh-bad.yaml, default output: exit=79
mesh-bad.yaml, -o json: exit=0
[('IST0101', 'Error'), ('IST0101', 'Error'), ('IST0132', 'Warning')]
analyzers: 54mesh-warn.yamlহলোmesh-good.yaml, শুধু VirtualService-এ আরও দুটো লাইন নিয়ে। তারাshop-gatewaygateway-র নাম নেয়, যার তালিকায়reviewshost নেই। বিশ্লেষণ ৪৫ নম্বর লাইনে একটা warning ছাপিয়েছে,IST0132।- reference বলে,
--failure-thresholdঠিক করে বিশ্লেষণের কোন severity স্তরে একটা শূন্য-নয় exit code বসবে Source 16সোর্স 16। বৈধ মান Info, Warning আর Error, আর defaultErrorSource 16সোর্স 16। - যে file-এ কেবল warning আছে, তাতে
Errorthreshold দিয়েছে exit code 0।WarningআরInfothreshold দিয়েছে 79।mesh-bad.yaml-এ default threshold দিয়েছে 79। -o jsonদিয়ে টিউটোরিয়ালের run-এmesh-bad.yaml-এর exit code ছিল 0।bad.json-এ ছিল একই তিনটা message:Errorlevel-সহ দুবারIST0101, আরWarninglevel-সহIST0132। exit code কেন 0 ছিল, টিউটোরিয়াল তা খুঁজে বের করেনি। এই run-এ JSON output-এর exit code error দেখায়নি, আর প্রতিটা message-এর level দেখিয়েছে।istioctl analyze -Lএই সংস্করণে ৫৪টা analyzer তালিকাভুক্ত করেছে। reference বলে,-Lচালানোর জন্য পাওয়া analyzer-গুলোর তালিকা দেয় Source 16সোর্স 16। ধাপটা*দিয়ে শুরু হওয়া লাইন গুনেছে, যা গোনার টিউটোরিয়ালের নিজের উপায়।
৬. security file: mutual TLS আর authorization policy। block mesh-security.yaml আর একটা typo-যুক্ত কপি লেখে, আর দুটোই analyze করে:
cat > mesh-security.yaml <<'EOF'
apiVersion: v1
kind: Namespace
metadata:
name: shop
labels:
istio-injection: enabled
---
apiVersion: security.istio.io/v1
kind: PeerAuthentication
metadata:
name: default
namespace: shop
spec:
mtls:
mode: STRICT
---
apiVersion: security.istio.io/v1
kind: AuthorizationPolicy
metadata:
name: allow-frontend-get
namespace: shop
spec:
selector:
matchLabels:
app: reviews
action: ALLOW
rules:
- from:
- source:
namespaces: ["frontend"]
to:
- operation:
methods: ["GET"]
---
apiVersion: security.istio.io/v1
kind: AuthorizationPolicy
metadata:
name: deny-admin
namespace: shop
spec:
selector:
matchLabels:
app: reviews
action: DENY
rules:
- to:
- operation:
paths: ["/admin"]
EOF
istioctl analyze --use-kube=false -A mesh-security.yaml
echo "exit=$?"
# A copy in which the action of the last policy is misspelled. sed removes the date and time of the log line, so that the output is the same in each run.
sed 's/action: DENY/action: DENYY/' mesh-security.yaml > mesh-security-typo.yaml
istioctl analyze --use-kube=false -A mesh-security-typo.yaml 2>&1 | sed -E 's/^[0-9T:.Z-]+\t//'
echo "exit=${PIPESTATUS[0]}"টিউটোরিয়ালের run-এর output:
Warning [IST0133] (AuthorizationPolicy shop/deny-admin mesh-security.yaml:35) Schema validation warning: configured AuthorizationPolicy will deny all traffic to TCP ports under its scope due to the use of only HTTP attributes in a DENY rule; it is recommended to explicitly specify the port
exit=0
warn file error processing mesh-security-typo.yaml[3]: failed parsing JSON for built-in type: unknown value "\"DENYY\"" for enum istio.security.v1beta1.AuthorizationPolicy.Action - skipping
Error(s) adding files: 1 error occurred:
* errors parsing content "mesh-security-typo.yaml": 1 error occurred:
* error processing mesh-security-typo.yaml[3]: failed parsing JSON for built-in type: unknown value "\"DENYY\"" for enum istio.security.v1beta1.AuthorizationPolicy.Action
No validation issues found when analyzing all namespaces (but 1 file could not be parsed).
Error: Some files couldn't be parsed.
exit=65mesh-security.yaml-এ আছে injection চালুshopnamespace,STRICTmode-এরdefaultনামের একটা PeerAuthentication,allow-frontend-getনামের একটা ALLOW policy, আরdeny-adminনামের একটা DENY policy। দুটো policy-ইapp: reviewslabel-যুক্ত workload বাছে। ALLOW policyfrontendnamespace থেকে আসা GET request ঢুকতে দেয়। DENY policy-তে আছে/adminpath।- বিশ্লেষণ DENY policy-র জন্য ৩৫ নম্বর লাইনে একটা warning ছাপিয়েছে,
IST0133, আর 0 দিয়ে বেরিয়েছে। message-এর তালিকাIST0133-কে বলে SchemaWarning Source 42সোর্স 42। message-এর লেখা বলে, DENY rule-এ কেবল HTTP attribute ব্যবহারের কারণে policy তার আওতার TCP port-গুলোর সব traffic deny করবে। সে port স্পষ্ট করে ঠিক করার সুপারিশ করে। - security page বলে, কিছু field আর condition কেবল HTTP workload-এ প্রযোজ্য Source 12সোর্স 12।
operationsection-এরpathsfield তাদের একটা Source 12সোর্স 12। page আরও বলে, কোনো TCP workload-এ HTTP-only field ব্যবহার করলে Istio সেগুলো উপেক্ষা করবে Source 12সোর্স 12। টিউটোরিয়াল কোনো traffic পাঠায়নি। policy TCP traffic-এর সঙ্গে কী করে, সে তা যাচাই করেনি। - ALLOW policy
source-এর অধীনেnamespacesfield ব্যবহার করে। page বলে, authorization policy-তে নিচের যেকোনো field ব্যবহারের আগে mutual TLS চালু থাকতে হবে Source 12সোর্স 12। সেগুলো হলোprincipalsআরnotPrincipalsfield এবংnamespacesআরnotNamespacesfield, সবইsourcesection-এর অধীনে Source 12সোর্স 12। file-এ একই namespace-এSTRICTmode-এর PeerAuthentication আছে। বিশ্লেষণ ALLOW policy নিয়ে কোনো message ছাপেনি। mesh-security-typo.yamlকপিতে DENY policy-র action হলোDENYY।istioctlএকটাwarnলাইন ছাপিয়েছে। তাতে আছে যে সেmesh-security-typo.yaml[3]-এর JSON পার্স করতে ব্যর্থ হয়েছে, action-এর enum-এর একটা অজানা মান সহ, আর সে সেটা বাদ দিচ্ছে। তারপর ছাপিয়েছেNo validation issues found when analyzing all namespaces (but 1 file could not be parsed).আরError: Some files couldn't be parsed.exit code ছিল 65।No validation issues foundলাইন ছাপা হয়েছে, যদিও typo-যুক্ত policy বিশ্লেষণ করা হয়নি। কেবল শেষ লাইন আর exit code সমস্যাটা দেখিয়েছে।- reference-এ
--ignore-unknownoption আছে, যা পার্স করা যায় না এমন input document নিয়ে অভিযোগ করে না, সেই ক্ষেত্রে যেখানে analyze-এর কেবল k8s-সামঞ্জস্যপূর্ণ input-এ চলা উচিত Source 16সোর্স 16। টিউটোরিয়াল সেটা ব্যবহার করেনি।
৭. একটা policy লিখুন আর OPA-কে জিজ্ঞেস করুন। block pods.rego policy আর JSON-এ দুটো Pod লেখে, আর opa eval চালায়:
cat > pods.rego <<'EOF'
package qa.pods
# A pod is denied when one of its containers runs privileged.
deny contains msg if {
some c in input.spec.containers
c.securityContext.privileged == true
msg := sprintf("container %v must not run privileged", [c.name])
}
default allow := false
allow if count(deny) == 0
EOF
cat > bad-pod.json <<'EOF'
{"apiVersion": "v1", "kind": "Pod", "metadata": {"name": "qa-privileged", "namespace": "default"}, "spec": {"containers": [{"name": "c1", "image": "busybox:1.36", "securityContext": {"privileged": true}}]}}
EOF
sed 's/qa-privileged/qa-plain/; s/"privileged": true/"privileged": false/' bad-pod.json > good-pod.json
opa eval --format pretty -d pods.rego -i bad-pod.json 'data.qa.pods.deny'
opa eval --format pretty -d pods.rego -i bad-pod.json 'data.qa.pods.allow'
opa eval --format pretty -d pods.rego -i good-pod.json 'data.qa.pods.allow'
opa eval --fail-defined -d pods.rego -i bad-pod.json 'data.qa.pods.deny[_]' > /dev/null
echo "--fail-defined, bad pod: exit=$?"
opa eval --fail-defined -d pods.rego -i good-pod.json 'data.qa.pods.deny[_]' > /dev/null
echo "--fail-defined, good pod: exit=$?"টিউটোরিয়ালের run-এর output:
[
"container c1 must not run privileged"
]
false
true
--fail-defined, bad pod: exit=1
--fail-defined, good pod: exit=0pods.regoটিউটোরিয়ালের নিজের policy। তারdenyrule হলো একটা set, যাতেprivileged == trueথাকা প্রতিটা container-এর জন্য একটা message থাকে। তারallowrule ডিফল্টভাবেfalse, আরdenyখালি হলেtrue। docs বলে,defaultkeyword পূর্ণ সংজ্ঞার rule থেকে তৈরি document-এর একটা default মান ঠিক করতে দেয় Source 29সোর্স 29।- query-র input হলো সেই Pod, যা
-iদেয়। docs বলে, সব module-এ data আর input document import করার অন্তর্নিহিত statement আছে Source 29সোর্স 29। bad-pod.json-এর জন্যdata.qa.pods.denyএকটা message-সহ তালিকা ছাপিয়েছে,container c1 must not run privileged, আরdata.qa.pods.allowছাপিয়েছেfalse।good-pod.json-এর জন্যallowছাপিয়েছেtrue।- reference বলে,
--fail-defineddefined বা খালি-নয় ফলে শূন্য-নয় exit code দিয়ে বেরোয় Source 31সোর্স 31।data.qa.pods.deny[_]query-র খারাপ Pod-এর জন্য ফল আছে, আর exit code ছিল 1। ভালো Pod-এর জন্য তার কোনো ফল নেই, আর exit code ছিল 0।
৮. policy পরীক্ষা করুন। block pods_test.rego test লেখে, তারপর ভালো test-এর ওপর, একটা ব্যর্থ কপির ওপর, আর ভুল বানানের test-যুক্ত কপির ওপর opa test চালায়:
cat > pods_test.rego <<'EOF'
package qa.pods_test
import data.qa.pods
test_privileged_pod_is_denied if {
not pods.allow with input as {"spec": {"containers": [{"name": "c1", "securityContext": {"privileged": true}}]}}
}
test_plain_pod_is_allowed if {
pods.allow with input as {"spec": {"containers": [{"name": "c1", "securityContext": {"privileged": false}}]}}
}
test_pod_without_security_context_is_allowed if {
pods.allow with input as {"spec": {"containers": [{"name": "c1"}]}}
}
EOF
# The run times are removed with sed and the lines are sorted, so that the output is the same in each run.
opa test -v pods.rego pods_test.rego | grep -E 'PASS|FAIL' | sed -E 's/ \([^)]*\)$//' | sort
echo "opa test: exit=${PIPESTATUS[0]}"
# The same policy with a test that expects the wrong answer.
mkdir failing
cp pods.rego failing/
sed 's/^\tnot pods.allow with input/\tpods.allow with input/' pods_test.rego > failing/pods_test.rego
opa test failing/ | sed -E 's/ \([^)]*\)$//'
echo "opa test failing/: exit=${PIPESTATUS[0]}"
# A copy in which the tests are misspelled: the prefix is tset_ and not test_.
mkdir misspelled
cp pods.rego misspelled/
sed 's/^test_/tset_/' pods_test.rego > misspelled/pods_test.rego
opa test misspelled/
echo "opa test misspelled/: exit=$?"
opa test --fail-on-empty misspelled/
echo "opa test --fail-on-empty misspelled/: exit=$?"
# Coverage of the policy file by the tests
opa test --coverage pods.rego pods_test.rego | python3 -c 'import json, sys; d = json.load(sys.stdin)["files"]["pods.rego"]; print("pods.rego covered lines:", d["covered_lines"], "not covered:", d.get("not_covered_lines", 0), "coverage:", d["coverage"])'টিউটোরিয়ালের run-এর output:
PASS: 3/3
data.qa.pods_test.test_plain_pod_is_allowed: PASS
data.qa.pods_test.test_pod_without_security_context_is_allowed: PASS
data.qa.pods_test.test_privileged_pod_is_denied: PASS
opa test: exit=0
failing/pods_test.rego:5:
data.qa.pods_test.test_privileged_pod_is_denied: FAIL
--------------------------------------------------------------------------------
PASS: 2/3
FAIL: 1/3
opa test failing/: exit=2
opa test misspelled/: exit=0
no tests were run
opa test --fail-on-empty misspelled/: exit=1
pods.rego covered lines: 6 not covered: 0 coverage: 100pods_test.rego-তে তিনটা test আছে। একটা privileged Pod অনুমোদিত নয়, একটা সাধারণ Pod অনুমোদিত, আরsecurityContext-হীন একটা Pod অনুমোদিত। docs বলে, test হলো সাধারণ Rego rule, যার নামের আগেtest_prefix থাকে Source 30সোর্স 30। প্রতিটা testwith input asদিয়ে input ঠিক করে।withkeyword query-কে input document-এর ভেতরের মান ঠিক করতে দেয় Source 29সোর্স 29।opa test -v pods.rego pods_test.regoছাপিয়েছেPASS: 3/3আর প্রতিটা test-এর জন্য একটাPASSলাইন, আর 0 দিয়ে বেরিয়েছে। ধাপটা run-এর সময় সরিয়েছে আর লাইনগুলো সাজিয়েছে।failing/-এ প্রথম test আশা করে privileged Pod অনুমোদিত হবে।opa testসেই test-এর জন্যFAILছাপিয়েছে, সঙ্গেFAIL: 1/3আরPASS: 2/3, আর 2 দিয়ে বেরিয়েছে। docs বলে, test rule undefined হলে বা non-true মান তৈরি করলে test-এর ফল FAIL Source 30সোর্স 30।misspelled/-এ prefix হলোtset_।opa testকিছুই ছাপেনি আর 0 দিয়ে বেরিয়েছে। docs বলে, আপনি কোনো test-এর নাম ভুল লিখলে বা ভুলে কোনো test না চালালেopa testতবু সফল হয়, আর--fail-on-emptyতাকে ব্যর্থ করে Source 30সোর্স 30।--fail-on-emptyদিয়ে সে ছাপিয়েছেno tests were runআর 1 দিয়ে বেরিয়েছে।opa test --coverageএকটা JSON report ছাপিয়েছে। ধাপটা তা থেকেpods.rego-র তিনটা সংখ্যা পড়েছে: ৬টা covered লাইন, ০টা not covered লাইন, আর ১০০ coverage। docs বলে, coverage report-এ command line-এ দেওয়া Rego file-এর সব evaluated আর not evaluated লাইন থাকে Source 30সোর্স 30।
৯. check, format আর পুরোনো syntax। চালান:
cat > unused.rego <<'EOF'
package qa.unused
import data.qa.nothing
allow if {
x := 1
input.ok == true
}
EOF
opa check unused.rego
echo "opa check: exit=$?"
opa check --strict unused.rego
echo "opa check --strict: exit=$?"
printf 'package qa.fmt\n\nallow if {\ninput.ok == true\n}\n' > unformatted.rego
opa fmt --fail --list unformatted.rego
echo "opa fmt --fail --list, unformatted file: exit=$?"
opa fmt --fail --list pods.rego
echo "opa fmt --fail --list, formatted file: exit=$?"
# A policy in the old (v0) syntax: no "if" before the body, no "contains" in the set rule.
cat > v0.rego <<'EOF'
package qa.v0
deny[msg] {
c := input.spec.containers[_]
c.securityContext.privileged == true
msg := sprintf("container %v must not run privileged", [c.name])
}
EOF
opa eval --format pretty -d v0.rego -i bad-pod.json 'data.qa.v0.deny'
echo "opa eval, v0 file: exit=$?"
opa eval --v0-compatible --format pretty -d v0.rego -i bad-pod.json 'data.qa.v0.deny'
echo "opa eval --v0-compatible, v0 file: exit=$?"টিউটোরিয়ালের run-এর output:
opa check: exit=0
2 errors occurred:
unused.rego:3: rego_compile_error: import data.qa.nothing unused
unused.rego:6: rego_compile_error: assigned var x unused
opa check --strict: exit=1
unformatted.rego
unexpected diff
opa fmt --fail --list, unformatted file: exit=2
opa fmt --fail --list, formatted file: exit=0
2 errors occurred:
v0.rego:3: rego_parse_error: `if` keyword is required before rule body
v0.rego:3: rego_parse_error: `contains` keyword is required for partial set rules
opa eval, v0 file: exit=2
[
"container c1 must not run privileged"
]
opa eval --v0-compatible, v0 file: exit=0unused.regodata.qa.nothingimport করে,x := 1assign করে, আর কোনোটাই ব্যবহার করে না।opa check unused.regoকিছুই ছাপেনি আর 0 দিয়ে বেরিয়েছে। reference বলে,checkfile পার্স আর compile করতে সফল হলে কোনো output দেয় না Source 31সোর্স 31।opa check --strictদুটো error ছাপিয়েছে,import data.qa.nothing unusedআরassigned var x unused, আর 1 দিয়ে বেরিয়েছে। reference--strict-কে এমন option হিসেবে দেখায়, যা compiler strict mode চালু করে Source 31সোর্স 31।- অ-formatted file-এ
opa fmt --fail --listfile-এর নাম আরunexpected diffছাপিয়েছে, আর 2 দিয়ে বেরিয়েছে।pods.rego-তে সে কিছুই ছাপেনি আর 0 দিয়ে বেরিয়েছে। reference বলে,--failদিলে কোনো file নতুন করে format করা হতো এমন হলেfmtcommand শূন্য-নয় exit code ফেরত দেয় Source 31সোর্স 31। সে বলে,-lযে file-গুলো বদলে যেত তাদের নাম ছাপে Source 31সোর্স 31। v0.regoপুরোনো syntax ব্যবহার করে। তার rule body-র আগেifনেই, আর set-এর rule-এcontainsনেই। OPA 1.22.4 দুটো parse error ছাপিয়েছে আর 2 দিয়ে বেরিয়েছে।--v0-compatibleদিয়ে একই file কাজ করেছে, আর message ছাপিয়েছে। reference--v0-compatible-কে এমন option হিসেবে দেখায়, যা OPA v1.0 release-এর আগের features আর আচরণে opt-in করে Source 31সোর্স 31।- Gatekeeper docs বলে, ConstraintTemplate-এ Rego v1 syntax ব্যবহার ঐচ্ছিক, আর ডিফল্টভাবে কেবল Rego v0 অনুমোদিত Source 37সোর্স 37। ১১ নম্বর ধাপের template পুরোনো syntax ব্যবহার করে।
১০. OPA server চালান আর তার decision log পড়ুন। ধাপটা server-কে background-এ চালু করে, curl দিয়ে চারটা request পাঠায়, server থামায়, আর log পড়ে:
opa run --server --addr 127.0.0.1:18181 --set decision_logs.console=true --log-level error pods.rego > opa-server.log 2>&1 &
OPA_PID=$!
for i in $(seq 1 50); do curl -s -o /dev/null http://127.0.0.1:18181/health && break; sleep 0.1; done
echo "health: $(curl -s http://127.0.0.1:18181/health)"
echo "--- bad pod, wrapped in the input key"
curl -s -X POST http://127.0.0.1:18181/v1/data/qa/pods -H 'Content-Type: application/json' -d "{\"input\": $(cat bad-pod.json)}" | sed -E 's/"decision_id":"[^"]*"/"decision_id":"..."/'
echo
echo "--- good pod, wrapped in the input key"
curl -s -X POST http://127.0.0.1:18181/v1/data/qa/pods/allow -H 'Content-Type: application/json' -d "{\"input\": $(cat good-pod.json)}" | sed -E 's/"decision_id":"[^"]*"/"decision_id":"..."/'
echo
echo "--- bad pod, NOT wrapped in the input key"
curl -s -X POST http://127.0.0.1:18181/v1/data/qa/pods/allow -H 'Content-Type: application/json' -d "$(cat bad-pod.json)" | sed -E 's/"decision_id":"[^"]*"/"decision_id":"..."/'
echo
echo "--- a path that no policy defines"
curl -s -X POST http://127.0.0.1:18181/v1/data/qa/nothing -H 'Content-Type: application/json' -d '{"input": {}}' | sed -E 's/"decision_id":"[^"]*"/"decision_id":"..."/'
echo
kill $OPA_PID
wait $OPA_PID 2> /dev/null
echo "--- decision log (the console lines of the server)"
python3 -c '
import json
for line in open("opa-server.log"):
d = json.loads(line)
print(d["msg"], "| path:", d["path"], "| result:", json.dumps(d.get("result", "undefined")), "| input logged:", "input" in d, "| custom.request_metadata logged:", "request_metadata" in d.get("custom", {}))
'টিউটোরিয়ালের run-এর output:
health: {}
--- bad pod, wrapped in the input key
{"decision_id":"...","result":{"allow":false,"deny":["container c1 must not run privileged"]}}
--- good pod, wrapped in the input key
{"decision_id":"...","result":true}
--- bad pod, NOT wrapped in the input key
{"decision_id":"...","result":true,"warning":{"code":"api_usage_warning","message":"'input' key missing from the request"}}
--- a path that no policy defines
{"decision_id":"..."}
--- decision log (the console lines of the server)
Decision Log | path: qa/pods | result: {"allow": false, "deny": ["container c1 must not run privileged"]} | input logged: True | custom.request_metadata logged: False
Decision Log | path: qa/pods/allow | result: true | input logged: True | custom.request_metadata logged: False
Decision Log | path: qa/pods/allow | result: true | input logged: False | custom.request_metadata logged: True
Decision Log | path: qa/nothing | result: "undefined" | input logged: True | custom.request_metadata logged: False- server শোনে
127.0.0.1:18181-এ। docs বলে,consoleconfig option দিয়ে decision-এর স্থানীয় console logging চালু করা যায় Source 33সোর্স 33। তারা তার জন্য দেখায়decision_logs: console: trueSource 33সোর্স 33। টিউটোরিয়াল একই setting দিয়েছে--set decision_logs.console=trueদিয়ে। সে--log-level error-ও দিয়েছিল, আর log file-এ কেবল decision log-এর লাইন ছিল। ধাপটা/health-এর জন্য অপেক্ষা করেছে, যা ছাপিয়েছে{}। - Data API নেয়
POST /v1/data/{path}, যার JSON body-র রূপ{"input": ...}Source 32সোর্স 32। প্রথম requestinput-এ খারাপ Pod পাঠিয়েছে/v1/data/qa/pods-এ। ফলে দুটো rule-ই ছিল:allowছিলfalse, আরdeny-তে ছিল message। ধাপটা প্রতিটাdecision_id-কে...দিয়ে বদলেছে। - দ্বিতীয় request ভালো Pod পাঠিয়েছে
/v1/data/qa/pods/allow-এ, আর ফল ছিলtrue। - তৃতীয় request খারাপ Pod-কে পুরো body হিসেবে পাঠিয়েছে, কোনো
inputkey ছাড়া। ফল ছিলtrue, সঙ্গে warning'input' key missing from the request। এই request-এ policy একটা privileged Pod অনুমোদন করেছে। REST page বলে, request body-তেinput-এর বাইরে বাড়তি যেকোনো top-level key request metadata হিসেবে গণ্য হয় Source 32সোর্স 32। টিউটোরিয়াল query trace করেনি, আর policy কেনtrueউত্তর দিয়েছে তা সে বলে না। - চতুর্থ request এমন একটা path চেয়েছে, যা কোনো policy সংজ্ঞায়িত করে না, আর response-এ কোনো
resultkey ছিল না। docs বলে, path কোনো undefined document-কে নির্দেশ করলে server 200 ফেরত দেয় Source 32সোর্স 32। তারা বলে, এক্ষেত্রে response-এresultproperty থাকে না Source 32সোর্স 32। ধাপটা status code ছাপেনি। - decision log-এ চারটা লাইন ছিল, প্রতি request-এ একটা।
pathfield-এ থাকে policy সিদ্ধান্তের স্তরবদ্ধ path Source 33সোর্স 33।inputfield-এ থাকে policy query-তে দেওয়া input data Source 33সোর্স 33।resultfield-এ থাকে client-কে ফেরত দেওয়া policy সিদ্ধান্ত Source 33সোর্স 33। - তৃতীয় লাইনে কোনো
inputছিল না, আর ছিলcustom.request_metadata। REST page বলে, request metadata decision log event-এcustom.request_metadatafield-এর অধীনে থাকে Source 32সোর্স 32। চতুর্থ লাইনে কোনোresultkey ছিল না, আর ধাপটা তার জন্যundefinedছাপিয়েছে। - ধাপটা
killআরwaitদিয়ে server থামিয়েছে। run-এর পরে port 18181 খালি ছিল, আর কোনোopaprocess পড়ে ছিল না।
১১. gator দিয়ে একটা Gatekeeper template পরীক্ষা করুন। block একটা ConstraintTemplate, একটা Constraint, দুটো Pod আর আরও তিনটা file লেখে, আর gator test ও gator verify চালায়:
cat > template.yaml <<'EOF'
apiVersion: templates.gatekeeper.sh/v1
kind: ConstraintTemplate
metadata:
name: qanoprivileged
spec:
crd:
spec:
names:
kind: QANoPrivileged
targets:
- target: admission.k8s.gatekeeper.sh
rego: |
package qanoprivileged
violation[{"msg": msg}] {
c := input.review.object.spec.containers[_]
c.securityContext.privileged == true
msg := sprintf("container <%v> must not run privileged", [c.name])
}
EOF
cat > constraint.yaml <<'EOF'
apiVersion: constraints.gatekeeper.sh/v1beta1
kind: QANoPrivileged
metadata:
name: no-privileged-pods
spec:
match:
kinds:
- apiGroups: [""]
kinds: ["Pod"]
EOF
cat > bad-pod.yaml <<'EOF'
apiVersion: v1
kind: Pod
metadata:
name: qa-privileged
namespace: default
spec:
containers:
- name: c1
image: busybox:1.36
securityContext:
privileged: true
EOF
sed 's/qa-privileged/qa-plain/; s/privileged: true/privileged: false/' bad-pod.yaml > good-pod.yaml
gator test -f template.yaml -f constraint.yaml -f bad-pod.yaml
echo "gator test, bad pod: exit=$?"
gator test -f template.yaml -f constraint.yaml -f good-pod.yaml
echo "gator test, good pod: exit=$?"
cat > suite.yaml <<'EOF'
kind: Suite
apiVersion: test.gatekeeper.sh/v1alpha1
tests:
- name: no-privileged
template: template.yaml
constraint: constraint.yaml
cases:
- name: privileged-pod
object: bad-pod.yaml
assertions:
- violations: 1
message: must not run privileged
- name: plain-pod
object: good-pod.yaml
assertions:
- violations: no
EOF
# A copy in which the second case expects a violation that does not happen.
sed 's/violations: no/violations: yes/' suite.yaml > suite-wrong.yaml
# A file that is not a Suite.
printf 'tests: []\n' > not-a-suite.yaml
# The run times are removed with sed, so that the output is the same in each run.
for f in suite.yaml suite-wrong.yaml not-a-suite.yaml; do
echo "--- gator verify $f"
gator verify $f 2>&1 | sed -E 's/\t\([0-9.]+s\)$//; s/\t[0-9.]+s$//'
echo "exit=${PIPESTATUS[0]}"
doneটিউটোরিয়ালের run-এর output:
v1/Pod default/qa-privileged: ["no-privileged-pods"] Message: "container <c1> must not run privileged"
gator test, bad pod: exit=1
gator test, good pod: exit=0
--- gator verify suite.yaml
ok suite.yaml
PASS
exit=0
--- gator verify suite-wrong.yaml
--- FAIL: plain-pod
unexpected number of violations: got 0 violations but want at least 1: got messages []
--- FAIL: no-privileged
FAIL suite-wrong.yaml
FAIL
Error: FAIL
exit=1
--- gator verify not-a-suite.yaml
PASS
exit=0template.yamlহলোqanoprivilegedনামের একটা ConstraintTemplate, যার kindQANoPrivileged। তার একটা target আছে,admission.k8s.gatekeeper.sh, আর পুরোনো syntax-এ একটা Rego ruleviolation।constraint.yamlহলোno-privileged-podsনামের একটা Constraint, যা Pod মেলায়। docs বলে, ConstraintTemplate দুটো প্রধান উপাদান দিয়ে তৈরি Source 37সোর্স 37। একটা হলো policy code, অন্যটা Constraint-এর schema Source 37সোর্স 37। Rego-তে পরীক্ষাধীন object হলোinput.review.object। docsinput.review-কে এমন variable হিসেবে তালিকাভুক্ত করে, যাতে পরীক্ষাধীন input request object থাকে Source 37সোর্স 37।gator testএকগুচ্ছ Kubernetes object-কে একগুচ্ছ Template আর Constraint-এর বিরুদ্ধে পরীক্ষা করে Source 38সোর্স 38। খারাপ Pod-এর জন্য সেcontainer <c1> must not run privilegedmessage-সহ একটা violation লাইন ছাপিয়েছে, আর exit code ছিল 1। ভালো Pod-এর জন্য সে কিছুই ছাপেনি, আর exit code ছিল 0। docs বলে, command violation পেলে তা ফেরত দেয় আর exit status দিয়ে সাফল্য বা ব্যর্থতা জানায় Source 38সোর্স 38।suite.yaml-এ একটা test আছে, দুটো case-সহ।privileged-podcase আশা করেviolations: 1আরmust not run privilegedmessage।plain-podcase আশা করেviolations: no। docs বলে,violations-এর মান হয় "yes", "no" অথবা একটা অঋণাত্মক পূর্ণসংখ্যা Source 38সোর্স 38। তারা বলে,messageহলো violation message মেলানোর একটা regular expression Source 38সোর্স 38।gator verify suite.yamlছাপিয়েছেok suite.yamlআরPASS, আর exit code ছিল 0।suite-wrong.yaml-এ দ্বিতীয় case আশা করেviolations: yes।gator verifyplain-podcase-এর জন্যFAILছাপিয়েছে,unexpected number of violations: got 0 violations but want at least 1লেখা-সহ। সেError: FAILছাপিয়েছে, আর exit code ছিল 1।not-a-suite.yamlহলোtests: []লেখা।gator verifyছাপিয়েছেPASSআর 0 দিয়ে বেরিয়েছে। docs বলে, বৈধ Suite file-এkind: Suiteআর একটাapiVersionঘোষণা করতে হয়, আর যে file-এ এগুলো ঘোষণা নেই,gator verifyসেগুলো নীরবে উপেক্ষা করে Source 38সোর্স 38।gator verifyএই file নিয়ে কী করেছে, তা টিউটোরিয়াল যাচাই করেনি।
১২. Falco rule যাচাই করুন। block shipped rules file-এর কয়েকটা লাইন ছাপে, container plugin-সহ আর ছাড়া তাকে যাচাই করে, টিউটোরিয়ালের নিজের rules file লেখে, তা যাচাই করে, আর তার rule-গুলোর তালিকা দেয়:
FALCO_ETC=falco-0.45.2-x86_64/etc/falco
FALCO_PLUGINS=$PWD/falco-0.45.2-x86_64/usr/share/falco/plugins
# The Falco log lines start with a time stamp. sed removes it, so that the output is the same in each run.
# The "System info" line is left out as well.
NOSTAMP='s/^[A-Z][a-z]{2} [A-Z][a-z]{2} +[0-9]+ [0-9:]+ [0-9]{4}: //'
echo "--- what the rules file of the archive asks for (lines 28 to 32)"
sed -n '28,32p' $FALCO_ETC/falco_rules.yaml
echo "--- the load_plugins line of the configuration file of the archive"
grep -n '^load_plugins:' $FALCO_ETC/falco.yaml
echo "--- the rules file of the archive, with the default configuration"
falco -c $FALCO_ETC/falco.yaml -V $FALCO_ETC/falco_rules.yaml 2>&1 | grep -v 'System info' | sed -E "$NOSTAMP"
echo "exit=${PIPESTATUS[0]}"
echo "--- the rules file of the archive, with the container plugin loaded"
falco -c $FALCO_ETC/falco.yaml -o load_plugins[0]=container -o plugins[0].library_path=$FALCO_PLUGINS/libcontainer.so -V $FALCO_ETC/falco_rules.yaml > shipped.log 2>&1
echo "exit=$?"
echo "log lines from the container plugin, left out below: $(grep -c '\[libs\]' shipped.log)"
grep -v -e '\[libs\]' -e 'System info' shipped.log | sed -E "$NOSTAMP"
cat > qa_rules.yaml <<'EOF'
- list: qa_sensitive_files
items: [/etc/shadow, /etc/sudoers]
- macro: qa_open_write
condition: >
evt.type in (open, openat, openat2) and evt.is_open_write=true and fd.typechar='f'
- rule: QA write to a sensitive file
desc: A process opened a sensitive file for writing. The rule is the tutorial's own.
condition: qa_open_write and fd.name in (qa_sensitive_files)
output: Sensitive file opened for writing (file=%fd.name process=%proc.name command=%proc.cmdline user=%user.name)
priority: WARNING
tags: [qa, filesystem]
EOF
echo "--- the tutorial's own rules file"
falco -c $FALCO_ETC/falco.yaml -V qa_rules.yaml 2>&1 | grep -v 'System info' | sed -E "$NOSTAMP"
echo "exit=${PIPESTATUS[0]}"
echo "--- the rule list"
falco -c $FALCO_ETC/falco.yaml -r qa_rules.yaml -L 2>/dev/null
echo "exit=$?"টিউটোরিয়ালের run-এর output:
--- what the rules file of the archive asks for (lines 28 to 32)
- required_engine_version: 0.57.0
- required_plugin_versions:
- name: container
version: 0.4.0
--- the load_plugins line of the configuration file of the archive
588:load_plugins: []
--- the rules file of the archive, with the default configuration
Falco version: 0.45.2 (x86_64)
Falco initialized with configuration files:
falco-0.45.2-x86_64/etc/falco/falco.yaml | schema validation: ok
Validating rules file(s):
falco-0.45.2-x86_64/etc/falco/falco_rules.yaml
Error: Plugin requirement not satisfied, must load one of: container (>= 0.4.0)
exit=1
--- the rules file of the archive, with the container plugin loaded
exit=0
log lines from the container plugin, left out below: 14
Falco version: 0.45.2 (x86_64)
Falco initialized with configuration files:
falco-0.45.2-x86_64/etc/falco/falco.yaml | schema validation: ok
Loaded plugin 'container@0.7.6' from file /work/falco-0.45.2-x86_64/usr/share/falco/plugins/libcontainer.so
Validating rules file(s):
falco-0.45.2-x86_64/etc/falco/falco_rules.yaml
falco-0.45.2-x86_64/etc/falco/falco_rules.yaml: Ok
--- the tutorial's own rules file
Falco version: 0.45.2 (x86_64)
Falco initialized with configuration files:
falco-0.45.2-x86_64/etc/falco/falco.yaml | schema validation: ok
Validating rules file(s):
qa_rules.yaml
qa_rules.yaml: Ok
exit=0
--- the rule list
Rule Description
---- -----------
QA write to a sensitive file A process opened a sensitive file for writing. The rule is
the tutorial's own.
exit=0- shipped
falco_rules.yaml-এর ২৮ থেকে ৩২ নম্বর লাইনে আছেrequired_engine_version: 0.57.0আর0.4.0সংস্করণেরcontainerplugin-এর একটাrequired_plugin_versionsentry। docs বলে,required_engine_versionrules content আর falco engine সংস্করণের সামঞ্জস্য ট্র্যাক করতে ব্যবহৃত হয় Source 22সোর্স 22। run-এর Falco-র engine সংস্করণ ০.৬৫.০ (১ নম্বর ধাপ)। - docs বলে, rules file-এ একটা top-level field
required_plugin_versionsথাকতে পারে, যাতে তারা কোন plugin সংস্করণের সঙ্গে সামঞ্জস্যপূর্ণ তা নথিভুক্ত হয় Source 46সোর্স 46। তারা বলে, কোনো plugin load থাকলে আর কোনো entry-র নাম মিলে গেলে, load হওয়া সংস্করণ entry-র সংস্করণের সঙ্গে semver-সামঞ্জস্যপূর্ণ হতে হবে Source 46সোর্স 46। - default configuration দিয়ে
falco -Vছাপিয়েছেError: Plugin requirement not satisfied, must load one of: container (>= 0.4.0)আর 1 দিয়ে বেরিয়েছে। archive-এরfalco.yaml-এ ৫৮৮ নম্বর লাইনে আছেload_plugins: []। - দ্বিতীয় command দুটো
-ooption দিয়ে plugin load করেছে। docs বলে,-o/--option key=valueদিয়ে command line থেকে যেকোনো configuration option override করা যায় Source 44সোর্স 44। তারা বলে, একটা তালিকার নির্দিষ্ট entry index ধরে override করা যায়, যেমন--option key.subkey[0]=valueSource 44সোর্স 44। docs বলে,pluginsproperty ঠিক করে Falco কোন plugin load করতে পারে, আরload_pluginsproperty নিয়ন্ত্রণ করে Falco চালু হওয়ার সময় কোনগুলো load হয় Source 46সোর্স 46। - plugin-সহ Falco ছাপিয়েছে
Loaded plugin 'container@0.7.6'আরfalco_rules.yaml: Ok, আর 0 দিয়ে বেরিয়েছে। ধাপটা plugin-এর ১৪টা log লাইন বাদ দিয়েছে। - packages page বলে, RHEL 8 / UBI 8 system-এ glibc ২.৩৪-এর পুরোনো হলে Falco 0.42 থেকে 0.44.x-এর সাথে bundled container plugin একটা undefined symbol-সহ load হতে ব্যর্থ হতে পারে, আর Falco 0.45.0 একটা ঠিক করা version bundle করে Source 41সোর্স 41। টিউটোরিয়ালের machine-এর glibc 2.43।
qa_rules.yamlটিউটোরিয়ালের নিজের file। তাতে আছে একটা list, একটা macro, আরWARNINGpriority-র একটা rule। docs বলে, একটা rules file হলো একটা YAML file, যাতে প্রধানত তিন ধরনের উপাদান থাকে Source 22সোর্স 22। Falco তাকে যাচাই করেছেqa_rules.yaml: Okআর exit code 0 দিয়ে। একটা rule-এ অন্ততrule,desc,condition,outputআরpriorityfield থাকে Source 23সোর্স 23।falco -r qa_rules.yaml -Lrule-টার নাম আর বর্ণনা ছাপিয়েছে। reference বলে,-Lসব rule-এর নাম আর বর্ণনা দেখায় আর বেরিয়ে যায় Source 25সোর্স 25।
১৩. ইচ্ছে করে rule ভাঙুন। block qa_rules.yaml-এর তিনটা কপি বানায়, প্রতিটায় একটা করে ভুল, আর প্রতিটা কপি -V দিয়ে যাচাই করে:
FALCO_ETC=falco-0.45.2-x86_64/etc/falco
# Three copies of the rules file, each with one mistake.
sed 's/fd.name in (qa_sensitive_files)/fd.nam in (qa_sensitive_files)/' qa_rules.yaml > qa_bad_field.yaml
sed 's/qa_open_write and/qa_open_writes and/' qa_rules.yaml > qa_bad_macro.yaml
sed 's/priority: WARNING/priority: LOUD/' qa_rules.yaml > qa_bad_priority.yaml
# stdout only (stderr is dropped).
for f in qa_bad_field.yaml qa_bad_macro.yaml qa_bad_priority.yaml; do
echo "--- $f"
falco -c $FALCO_ETC/falco.yaml -V $f 2> /dev/null
echo "exit=$?"
doneটিউটোরিয়ালের run-এর output:
--- qa_bad_field.yaml
qa_bad_field.yaml: Invalid
1 Errors:
In rules content: (qa_bad_field.yaml:0:0)
rule 'QA write to a sensitive file': (qa_bad_field.yaml:7:2)
rule condition: (qa_bad_field.yaml:9:13)
condition expression: ("qa_open_write and...":10:32)
------
qa_open_write and fd.nam in (qa_sensitive_files)
^
------
LOAD_ERR_COMPILE_CONDITION (Error compiling condition): filter_check called with nonexistent field fd.nam
exit=1
--- qa_bad_macro.yaml
qa_bad_macro.yaml: Invalid
1 Errors:
In rules content: (qa_bad_macro.yaml:0:0)
rule 'QA write to a sensitive file': (qa_bad_macro.yaml:7:2)
condition expression: ("qa_open_writes an...":8:3)
------
qa_open_writes and fd.name in (qa_sensitive_files)
^
------
LOAD_ERR_VALIDATE (Error validating rule/macro/list/exception objects): Undefined macro 'qa_open_writes' used in filter.
exit=1
--- qa_bad_priority.yaml
qa_bad_priority.yaml: Invalid
3 Schema warnings:
------
failed for <root>[2][priority]: Failed to match against any enum values.
------
failed for <root>[2]: Failed to validate against schema associated with property name 'priority'.
------
failed for <root>: Failed to validate item #2 in array.
------
1 Errors:
In rules content: (qa_bad_priority.yaml:0:0)
rule 'QA write to a sensitive file': (qa_bad_priority.yaml:7:2)
rule priority: (qa_bad_priority.yaml:11:12)
------
priority: LOUD
^
------
LOAD_ERR_YAML_VALIDATE (Error validating internal structure of YAML file): Invalid priority
exit=1qa_bad_field.yaml-এfd.name-এর জায়গায় আছেfd.nam। Falco ছাপিয়েছেInvalid, তারপরLOAD_ERR_COMPILE_CONDITION (Error compiling condition): filter_check called with nonexistent field fd.nam। সে condition-টা ছাপিয়েছে ভুলের জায়গার নিচে একটা^-সহ, আর exit code ছিল 1। docs বলে,--listসংজ্ঞায়িত সব field-এর তালিকা দেয়, তাই সঠিক field-এর নাম খুঁজে নেওয়া যায় Source 25সোর্স 25। টিউটোরিয়াল এটা চালায়নি।qa_bad_macro.yaml-এqa_open_write-এর জায়গায় আছেqa_open_writes। Falco ছাপিয়েছেLOAD_ERR_VALIDATE (Error validating rule/macro/list/exception objects): Undefined macro 'qa_open_writes' used in filter., আর exit code ছিল 1। docs বলে, macro হলো rule-এর condition-এর টুকরো, যা rule-এর ভেতরে আর এমনকি অন্য macro-র ভেতরেও আবার ব্যবহার করা যায় Source 22সোর্স 22।qa_bad_priority.yaml-এ আছেpriority: LOUD। Falco ছাপিয়েছে3 Schema warnings,1 ErrorsআরLOAD_ERR_YAML_VALIDATE (Error validating internal structure of YAML file): Invalid priority, আর exit code ছিল 1। docs পাওয়া priority-গুলোর তালিকা দেয় Source 23সোর্স 23।- প্রতিটা output শুরু হয় file-এর নাম আর
Invalidশব্দ দিয়ে। ধাপটা শুধু stdout ছাপিয়েছে, আর stderr বাদ দিয়েছে।
১৪. falcoctl দিয়ে audit plugin আর তার rule install করুন। চালান:
mkdir plugins rules state assets
# The log lines start with a date and a time. sed removes them. The order of the three artifacts can differ from run to run.
falcoctl artifact install k8saudit:0.18.0 json:0.7.4 k8saudit-rules:0.18.0 \
--config falco-0.45.2-x86_64/etc/falcoctl/falcoctl.yaml \
--plugins-dir plugins --rulesfiles-dir rules --state-dir state --assets-dir assets \
--log-format text 2>&1 | sed -E 's/^[0-9-]+ [0-9:]+ //'
echo "exit=${PIPESTATUS[0]}"
ls plugins rules
# The two rules that step 15 triggers (the line numbers show their order in the file), and the lists that have the user kubernetes-admin.
grep -n -A 2 -E '^- rule: (Disallowed K8s User|Create Privileged Pod)$' rules/k8s_audit_rules.yaml
awk '/^- list: /{name=$3} /"kubernetes-admin",/{print "line " NR ": in the list " name}' rules/k8s_audit_rules.yamlটিউটোরিয়ালের run-এর output:
INFO Resolving dependencies ...
INFO Installing artifacts
└ refs: [ghcr.io/falcosecurity/plugins/ruleset/k8saudit:0.18.0 ghcr.io/falcosecurity/plugins/plugin/k8saudit:0.18.0 ghcr.io/falcosecurity/plugins/plugin/json:0.7.4]
INFO Preparing to pull artifact
└ ref: ghcr.io/falcosecurity/plugins/ruleset/k8saudit:0.18.0
INFO Pulling layer 8324f17dce60
INFO Pulling layer d213d53c736a
INFO Pulling layer ffb6b16fb785
INFO Verifying signature for artifact
└ digest: ghcr.io/falcosecurity/plugins/ruleset/k8saudit@sha256:ffb6b16fb78585f9658b75847c511220b4915cf62805261340bcc173906d7d7c
INFO Signature successfully verified!
INFO Extracting and installing artifact
├ type: rulesfile
└ file: k8saudit-rules-0.18.0.tar.gz
INFO Artifact successfully installed
├ name: ghcr.io/falcosecurity/plugins/ruleset/k8saudit:0.18.0
├ type: rulesfile
├ digest: sha256:ffb6b16fb78585f9658b75847c511220b4915cf62805261340bcc173906d7d7c
└ directory: rules
INFO Preparing to pull artifact
└ ref: ghcr.io/falcosecurity/plugins/plugin/k8saudit:0.18.0
INFO Pulling layer 894b71ec239d
INFO Pulling layer 180046ef8a1c
INFO Pulling layer ecfeb7378165
INFO Verifying signature for artifact
└ digest: ghcr.io/falcosecurity/plugins/plugin/k8saudit@sha256:ca794b24fee51095579b63b4e8a57030de6e3a8489bcd11d1960aa26a021308f
INFO Signature successfully verified!
INFO Extracting and installing artifact
├ type: plugin
└ file: k8saudit-0.18.0-linux-x86_64.tar.gz
INFO Artifact successfully installed
├ name: ghcr.io/falcosecurity/plugins/plugin/k8saudit:0.18.0
├ type: plugin
├ digest: sha256:ecfeb737816523d949660404d7a1a4a1dbcaecf785bfb84a1c48a06e899ebb85
└ directory: plugins
INFO Preparing to pull artifact
└ ref: ghcr.io/falcosecurity/plugins/plugin/json:0.7.4
INFO Pulling layer 47b0c10d399d
INFO Pulling layer d1370d6387f9
INFO Pulling layer 9f898f44312d
INFO Verifying signature for artifact
└ digest: ghcr.io/falcosecurity/plugins/plugin/json@sha256:b867a72796552499e3212f5b7af51cbeb5587348041f72d6f2131c575f6fb312
INFO Signature successfully verified!
INFO Extracting and installing artifact
├ type: plugin
└ file: json-0.7.4-linux-x86_64.tar.gz
INFO Artifact successfully installed
├ name: ghcr.io/falcosecurity/plugins/plugin/json:0.7.4
├ type: plugin
├ digest: sha256:9f898f44312dd433ca507190e759277b34d7558cf4a378f97e9b46d705da5f72
└ directory: plugins
exit=0
plugins:
libjson.so
libk8saudit.so
rules:
k8s_audit_rules.yaml
154:- rule: Disallowed K8s User
155- desc: Detect any k8s operation by users outside of an allowed set of users.
156- condition: kevt and non_system_user and not ka.user.name in (allowed_k8s_users) and not ka.user.name in (eks_allowed_k8s_users)
--
247:- rule: Create Privileged Pod
248- desc: >
249- Detect an attempt to start a pod with a privileged container
line 74: in the list allowed_k8s_users
line 783: in the list full_admin_k8s_usersfalcoctl artifact installতিনটা নাম নিয়েছে:k8saudit:0.18.0,json:0.7.4আরk8saudit-rules:0.18.0। সে archive-এর configuration file ব্যবহার করেছে (--config), আর file-গুলো রেখেছে run-এর folder-এ (--plugins-dir,--rulesfiles-dir,--state-dirআর--assets-dir)। সংস্করণগুলো টিউটোরিয়ালের নিজের বাছাই। Falco docs বলে, falcoctl-এর install command rules file নামায় একটা সাজানো যায় এমন directory-তে, যা ডিফল্টভাবে/etc/falcoSource 43সোর্স 43।- output-এ falcoctl তিনটা নামকে resolve করেছে
ghcr.io/falcosecurity/plugins/plugin/k8saudit:0.18.0,ghcr.io/falcosecurity/plugins/plugin/json:0.7.4আরghcr.io/falcosecurity/plugins/ruleset/k8saudit:0.18.0-এ। সে প্রতিটা artifact-এর তিনটা layer নামিয়েছে। প্রতিটা artifact-এর জন্য সে ছাপিয়েছেVerifying signature for artifactআরSignature successfully verified!। falcoctl কীভাবে signature যাচাই করে বা কোন key ব্যবহার করে, টিউটোরিয়াল তা দেখেনি। lsদেখিয়েছেplugins-এlibjson.soআরlibk8saudit.so, আরrules-এk8s_audit_rules.yaml। plugin-এর README বলে, অফিসিয়াল ruleset json plugin-এর ওপর নির্ভর করে Source 45সোর্স 45। ধাপটাjson-ও install করে।- শেষ দুটো command rules file পড়ে।
Disallowed K8s Userআছে ১৫৪ নম্বর লাইনে, আর তার condition শেষ হয়not ka.user.name in (allowed_k8s_users) and not ka.user.name in (eks_allowed_k8s_users)দিয়ে।Create Privileged Podআছে ২৪৭ নম্বর লাইনে, আর তার বর্ণনাDetect an attempt to start a pod with a privileged container।kubernetes-adminব্যবহারকারী আছেallowed_k8s_userslist-এ (৭৪ নম্বর লাইন) আরfull_admin_k8s_userslist-এ (৭৮৩ নম্বর লাইন)। docs বলে, list হলো item-এর সংগ্রহ, যা rule, macro বা অন্য list-এ রাখা যায় Source 22সোর্স 22। list-গুলোর অন্য নাম টিউটোরিয়াল ছাপেনি।
১৫. একটা file থেকে Kubernetes audit event পড়ুন। block JSON Lines-এ তিনটা audit event আর একটা Falco configuration লেখে, আর Falco দুবার চালায়:
# One Kubernetes audit event, as one line of JSON: the user kubernetes-admin creates a Pod with a privileged container.
cat > event-privileged.json <<'EOF'
{"kind":"Event","apiVersion":"audit.k8s.io/v1","level":"RequestResponse","auditID":"11111111-2222-3333-4444-555555555555","stage":"ResponseComplete","requestURI":"/api/v1/namespaces/default/pods","verb":"create","user":{"username":"kubernetes-admin","groups":["system:authenticated"]},"sourceIPs":["10.0.0.5"],"userAgent":"kubectl/v1.37.2","objectRef":{"resource":"pods","namespace":"default","name":"qa-privileged","apiVersion":"v1"},"responseStatus":{"metadata":{},"code":201},"requestObject":{"kind":"Pod","apiVersion":"v1","metadata":{"name":"qa-privileged","namespace":"default"},"spec":{"containers":[{"name":"c1","image":"busybox:1.36","securityContext":{"privileged":true}}]}},"responseObject":{"kind":"Pod","apiVersion":"v1","metadata":{"name":"qa-privileged","namespace":"default"}},"requestReceivedTimestamp":"2026-11-20T01:40:00.000000Z","stageTimestamp":"2026-11-20T01:40:00.100000Z"}
EOF
# The same event from another user, and the same event without the privileged setting.
sed 's/"username":"kubernetes-admin"/"username":"qa-user"/' event-privileged.json > event-other-user.json
sed 's/"privileged":true/"privileged":false/' event-privileged.json > event-plain.json
cat event-privileged.json event-other-user.json event-plain.json > audit.jsonl
echo "events in audit.jsonl: $(wc -l < audit.jsonl)"
# A small Falco configuration: the two plugins, the rules file, and the audit file as the source of events.
cat > falco-audit.yaml <<EOF
rules_files:
- $PWD/rules/k8s_audit_rules.yaml
load_plugins: [k8saudit, json]
plugins:
- name: k8saudit
library_path: $PWD/plugins/libk8saudit.so
init_config: ""
open_params: "$PWD/audit.jsonl"
- name: json
library_path: $PWD/plugins/libjson.so
stdout_output:
enabled: true
EOF
# stdout only (stderr is dropped). sed removes the time at the start of each alert line.
echo "--- the default setting"
falco -c falco-audit.yaml --disable-source syscall 2> /dev/null | sed -E 's/^[0-9:.]+: //'
echo "exit=${PIPESTATUS[0]}"
echo "--- -o rule_matching=all"
falco -c falco-audit.yaml --disable-source syscall -o rule_matching=all 2> /dev/null | sed -E 's/^[0-9:.]+: //'
echo "exit=${PIPESTATUS[0]}"টিউটোরিয়ালের run-এর output:
events in audit.jsonl: 3
--- the default setting
Warning Pod started with privileged container (user=kubernetes-admin pod=qa-privileged resource=pods ns=default images=(busybox:1.36) init_images=<NA> ephemeral_images=<NA>)
Warning K8s Operation performed by user not in allowed list of users (user=qa-user target=qa-privileged/pods verb=create uri=/api/v1/namespaces/default/pods resp=201)
Events detected: 2
Rule counts by severity:
WARNING: 2
Triggered rules by rule name:
Disallowed K8s User: 1
Create Privileged Pod: 1
exit=0
--- -o rule_matching=all
Warning Pod started with privileged container (user=kubernetes-admin pod=qa-privileged resource=pods ns=default images=(busybox:1.36) init_images=<NA> ephemeral_images=<NA>)
Warning K8s Operation performed by user not in allowed list of users (user=qa-user target=qa-privileged/pods verb=create uri=/api/v1/namespaces/default/pods resp=201)
Warning Pod started with privileged container (user=qa-user pod=qa-privileged resource=pods ns=default images=(busybox:1.36) init_images=<NA> ephemeral_images=<NA>)
Events detected: 3
Rule counts by severity:
WARNING: 3
Triggered rules by rule name:
Disallowed K8s User: 1
Create Privileged Pod: 2
exit=0event-privileged.jsonএকটা audit event। ব্যবহারকারীkubernetes-adminএকটা privileged container-সহqa-privilegedPod তৈরি করে (verbcreate, resourcepods, response code 201)।event-other-user.jsonএকই event, ব্যবহারকারীqa-user-এর।event-plain.jsonএকই event,privileged-কেfalseকরে।audit.jsonl-এ আছে তিনটা event, প্রতি লাইনে একটা। event-গুলো টিউটোরিয়ালের নিজের।- plugin-এর README বলে, সে Webhook backend থেকে বা একটা file থেকে Kubernetes audit event নেওয়া সমর্থন করে Source 45সোর্স 45। file-এর জন্য plugin আশা করে JSONL, যেখানে প্রতিটা লাইন একটা JSON object, তাতে এক বা একাধিক audit event Source 45সোর্স 45। README বলে, Falco-র সঙ্গে plugin ব্যবহারের প্রত্যাশিত উপায় হলো Webhook, আর file পড়া test আর development-এর জন্য ব্যবহার করা যায় Source 45সোর্স 45। Falco docs বলে, Kubernetes audit event পেতে plugin একটা webserver বসায়, যা একটা সাজানো যায় এমন port-এ শোনে আর একটা সাজানো যায় এমন endpoint-এ POST request নেয় Source 47সোর্স 47। টিউটোরিয়াল একটা file পড়েছে আর কোনো webserver চালায়নি।
falco-audit.yamlটিউটোরিয়ালের নিজের configuration। তাতে আছে ১৪ নম্বর ধাপের rules file,load_plugins: [k8saudit, json], library path-সহ দুটো plugin, আরopen_params-এ file। README বলে, scheme ছাড়া parameter file path হিসেবে পড়া হয় Source 45সোর্স 45। তার sample-এ একইload_pluginsতালিকা আছে Source 45সোর্স 45।--disable-sourceoption একটা নির্দিষ্ট event source বন্ধ করে Source 25সোর্স 25। ধাপে তাকেsyscallদেওয়া হয়েছে। docs বলে, plugin-ভিত্তিক deployment-এ আপনি syscall source স্পষ্ট করে বন্ধ করেন, অথবা শুধু যে plugin-ভিত্তিক source চান সেগুলো চালু করেন Source 19সোর্স 19।- default setting-এ Falco তিনটা event-এর জন্য দুটো alert ছাপিয়েছে, আর
Events detected: 2। প্রথম eventkubernetes-admin-এর জন্যPod started with privileged containerতুলেছে। দ্বিতীয় eventqa-user-এর জন্যK8s Operation performed by user not in allowed list of usersতুলেছে। তৃতীয় event কোনো alert তোলেনি। ধাপটা প্রতিটা alert লাইনের শুরুর সময় সরিয়েছে। - দ্বিতীয় event-ও একটা privileged Pod, আর default setting-এ সে
Create Privileged Podতোলেনি। ১৪ নম্বর ধাপের rules file-এDisallowed K8s Userসংজ্ঞায়িত ১৫৪ নম্বর লাইনে, আরCreate Privileged Pod২৪৭ নম্বর লাইনে। docs বলে, ডিফল্টভাবে Falco প্রতিটা event type-এর জন্য rule প্রয়োগ করে "first match wins" ভিত্তিতে Source 24সোর্স 24। তারা বলে, কোন ক্রমে rule চালু হবে তা নিয়ন্ত্রণের উপায় হলো rule-গুলো যে ক্রমে সংজ্ঞায়িত হয়, আর তাই load হয়, সেই ক্রম বদলানো Source 23সোর্স 23। এই run-এ দ্বিতীয় event-এর alert এসেছে সেই rule থেকে, যা আগে সংজ্ঞায়িত। -o rule_matching=allদিয়ে Falco তিনটা alert ছাপিয়েছে আরEvents detected: 3। দ্বিতীয় event দুটো rule-ই তুলেছে, আরCreate Privileged Podদুবার গোনা হয়েছে। docs বলে, Falco 0.36.0 থেকে আপনি configuration বদলেrule_matching: allকরতে পারেন Source 24সোর্স 24। তারা বলে, এই বদল নিশ্চিত করে যে একই event type-এর rule-গুলো একে অপরকে override করতে পারে না Source 24সোর্স 24। তারা সতর্ক করে, এতে CPU ব্যবহার বাড়তে পারে Source 24সোর্স 24। টিউটোরিয়াল CPU মাপেনি।- Falco দুবারই 0 দিয়ে বেরিয়েছে, যদিও সে alert তুলেছে। এই run-এ exit code alert দেখায়নি।
How a tester uses it
Check Istio files before they reach a cluster. In steps 3 to 6, istioctl analyze --use-kube=false found four problems. A gateway did not exist, and a subset did not exist. A host was not in the gateway. A DENY rule had an HTTP-only attribute. It needed no cluster. The docs say that istioctl analyze can run against a live cluster or a set of local configuration files Source 15সোর্স 15. It can also run against a combination of the two Source 15সোর্স 15. That lets you catch problems before you apply changes to a cluster Source 15সোর্স 15. A tester can run it on the Istio files of a pull request with -A. In step 4, a file with two errors passed when the call had no namespace option. In step 5, the threshold decided the exit code for a warning. In step 6, a file that could not be parsed gave the exit code 65.
Plan a resilience test with fault injection. The tutorial ran no traffic and injected no fault. The docs define fault injection as a testing method Source 11সোর্স 11. It introduces errors into a system to ensure that it can withstand and recover from error conditions Source 11সোর্স 11. Istio lets you inject faults at the application layer, unlike delaying packets or killing pods at the network layer Source 11সোর্স 11. The Envoy timeout for HTTP requests is disabled in Istio by default Source 11সোর্স 11. The default retry behavior for HTTP requests is to retry twice before returning the error Source 11সোর্স 11. A tester can write these two defaults in the test plan. The docs say that the fault injection configuration can not be combined with retry or timeout configuration on the same virtual service Source 11সোর্স 11. If you also set failure recovery policies in your application code, both the application's policies and the ones of Istio work independently Source 11সোর্স 11. Both sets might conflict Source 11সোর্স 11.
Read the mutual TLS mode and the order of the policies. In step 6, the file had a PeerAuthentication in the mode STRICT. The tutorial's check read the file and sent no traffic. Istio mutual TLS has a permissive mode, which allows a service to accept both plaintext traffic and mutual TLS traffic at the same time Source 12সোর্স 12. Once the configuration of the clients is complete, the operator can configure the server to mutual TLS only mode Source 12সোর্স 12. A tester can read the mode of the namespace before a test that expects encrypted traffic. The docs say that Istio checks for matching policies in layers, in this order: CUSTOM, DENY, and then ALLOW Source 12সোর্স 12. The deny by default behavior applies only if the workload has at least one authorization policy with the ALLOW action Source 12সোর্স 12. A tester can write the expected result of a request for each layer.
Put policy tests in the pipeline. In steps 8 and 9, opa test, opa check --strict, and opa fmt --fail --list ran on files. The exit codes were 2 for a failed test, 1 for a strict error, and 2 for a file that would be reformatted. The docs say that --fail-on-empty is also useful in CI/CD pipelines to ensure that tests are actually being executed Source 30সোর্স 30. In step 8, a copy with misspelled tests exited with 0 and ran no test. A tester can add one test for each way that a rule can end: denied, allowed, and a missing field. Step 8 had a Pod with no securityContext for the last one.
Test the OPA server like any other API. In step 10, a request with the Pod in the input key got the answer that the policy gives for it. A request with the Pod as the whole body got true for a privileged Pod. It also got the warning 'input' key missing from the request. The REST page says that the request body contains an object that specifies a value for the input document Source 32সোর্স 32. It says that if decision logging is enabled, the response has a decision_id field that uniquely identifies the decision Source 32সোর্স 32. Callers can use the identifier for correlation purposes Source 32সোর্স 32. Each decision log event includes the policy that was queried and the input to the query Source 33সোর্স 33. It also includes bundle metadata and other information that enables auditing and offline debugging of policy decisions Source 33সোর্স 33. A tester can check the warning key of each response and keep the decision log of a test run.
Test Gatekeeper templates without a cluster. In step 11, gator verify checked a template and a constraint with a Suite of two cases. gator test checked one object. The docs say that gator verify organizes tests into three levels: Suites, Tests, and Cases Source 38সোর্স 38. A Case defines an object to validate and whether the object is expected to pass validation Source 38সোর্স 38. In the run, a file that was not a Suite printed PASS. The docs also note that audit and gator test are different enforcement points Source 38সোর্স 38. They do not have the AdmissionReview request metadata Source 38সোর্স 38. A tester can list which fields of input.review the Rego reads, and check each field against this note. The tutorial did not do this, and it ran no Gatekeeper in a cluster.
Validate Falco rules and replay events. In steps 12 and 13, falco -V exited with 0 for valid files and with 1 for each broken file. The reference says that -V reads the files, validates the loaded rules, and exits Source 25সোর্স 25. It says that --dry-run runs Falco without processing events Source 25সোর্স 25. It can help check that the configuration and rules do not have any errors Source 25সোর্স 25. In step 15, three events gave two alerts in the default setting and three alerts with rule_matching=all. A tester can keep a small file of audit events for each rule, and compare the alerts with a saved list. The event-generator generates a variety of suspect actions that are detected by Falco rulesets Source 39সোর্স 39. Its Kubernetes audit events collection is maintained on a best-effort basis and may not fully work Source 39সোর্স 39. The tutorial did not run it.
Know which Falco rules you test. The Falco rules repository says that the maturity_stable rules in falco_rules.yaml are included in the Falco release package Source 40সোর্স 40. It says that other maturity-level rules are released separately, and that they require explicit installation and possible customization Source 40সোর্স 40. In step 14, the tutorial installed the rules file of the k8saudit plugin with falcoctl. The shipped rules file asked for the engine version 0.57.0 and for the plugin container in version 0.4.0 (step 12). A tester can write the rules files and their versions in the test report.
Read what Istio reports. The tutorial ran no traffic, and the run has no metric of Istio. The docs say that the standard Istio metrics are exported to Prometheus by default Source 13সোর্স 13. They say that by default, Istio enables only a small subset of the Envoy-generated statistics Source 13সোর্স 13. A tester can check that the metric that a test needs is among the standard ones before the test starts. Monitoring and Observability shows Prometheus and PromQL.
সহজ English
Check Istio files before they reach a cluster. In steps 3 to 6, istioctl analyze --use-kube=false found four problems. A gateway did not exist, and a subset did not exist. A host was not in the gateway. A DENY rule had an HTTP-only attribute. It needed no cluster. The docs say that istioctl analyze can run against a live cluster or a set of local configuration files Source 15সোর্স 15. It can also run against a combination of the two Source 15সোর্স 15. That lets you catch problems before you apply changes to a cluster Source 15সোর্স 15. A tester can run it on the Istio files of a pull request with -A. In step 4, a file with two errors passed when the call had no namespace option. In step 5, the threshold decided the exit code for a warning. In step 6, a file that could not be parsed gave the exit code 65.
Plan a resilience test with fault injection. The tutorial ran no traffic and injected no fault. The docs define fault injection as a testing method Source 11সোর্স 11. It introduces errors into a system to ensure that it can withstand and recover from error conditions Source 11সোর্স 11. Istio lets you inject faults at the application layer, unlike delaying packets or killing pods at the network layer Source 11সোর্স 11. The Envoy timeout for HTTP requests is disabled in Istio by default Source 11সোর্স 11. The default retry behavior for HTTP requests is to retry twice before returning the error Source 11সোর্স 11. A tester can write these two defaults in the test plan. The docs say that the fault injection configuration can not be combined with retry or timeout configuration on the same virtual service Source 11সোর্স 11. If you also set failure recovery policies in your application code, both the application's policies and the ones of Istio work independently Source 11সোর্স 11. Both sets might conflict Source 11সোর্স 11.
Read the mutual TLS mode and the order of the policies. In step 6, the file had a PeerAuthentication in the mode STRICT. The tutorial's check read the file and sent no traffic. Istio mutual TLS has a permissive mode, which allows a service to accept both plaintext traffic and mutual TLS traffic at the same time Source 12সোর্স 12. Once the configuration of the clients is complete, the operator can configure the server to mutual TLS only mode Source 12সোর্স 12. A tester can read the mode of the namespace before a test that expects encrypted traffic. The docs say that Istio checks for matching policies in layers, in this order: CUSTOM, DENY, and then ALLOW Source 12সোর্স 12. The deny by default behavior applies only if the workload has at least one authorization policy with the ALLOW action Source 12সোর্স 12. A tester can write the expected result of a request for each layer.
Put policy tests in the pipeline. In steps 8 and 9, opa test, opa check --strict, and opa fmt --fail --list ran on files. The exit codes were 2 for a failed test, 1 for a strict error, and 2 for a file that would be reformatted. The docs say that --fail-on-empty is also useful in CI/CD pipelines to ensure that tests are actually being executed Source 30সোর্স 30. In step 8, a copy with misspelled tests exited with 0 and ran no test. A tester can add one test for each way that a rule can end: denied, allowed, and a missing field. Step 8 had a Pod with no securityContext for the last one.
Test the OPA server like any other API. In step 10, a request with the Pod in the input key got the answer that the policy gives for it. A request with the Pod as the whole body got true for a privileged Pod. It also got the warning 'input' key missing from the request. The REST page says that the request body contains an object that specifies a value for the input document Source 32সোর্স 32. It says that if decision logging is enabled, the response has a decision_id field that uniquely identifies the decision Source 32সোর্স 32. Callers can use the identifier for correlation purposes Source 32সোর্স 32. Each decision log event includes the policy that was queried and the input to the query Source 33সোর্স 33. It also includes bundle metadata and other information that enables auditing and offline debugging of policy decisions Source 33সোর্স 33. A tester can check the warning key of each response and keep the decision log of a test run.
Test Gatekeeper templates without a cluster. In step 11, gator verify checked a template and a constraint with a Suite of two cases. gator test checked one object. The docs say that gator verify organizes tests into three levels: Suites, Tests, and Cases Source 38সোর্স 38. A Case defines an object to validate and whether the object is expected to pass validation Source 38সোর্স 38. In the run, a file that was not a Suite printed PASS. The docs also note that audit and gator test are different enforcement points Source 38সোর্স 38. They do not have the AdmissionReview request metadata Source 38সোর্স 38. A tester can list which fields of input.review the Rego reads, and check each field against this note. The tutorial did not do this, and it ran no Gatekeeper in a cluster.
Validate Falco rules and replay events. In steps 12 and 13, falco -V exited with 0 for valid files and with 1 for each broken file. The reference says that -V reads the files, validates the loaded rules, and exits Source 25সোর্স 25. It says that --dry-run runs Falco without processing events Source 25সোর্স 25. It can help check that the configuration and rules do not have any errors Source 25সোর্স 25. In step 15, three events gave two alerts in the default setting and three alerts with rule_matching=all. A tester can keep a small file of audit events for each rule, and compare the alerts with a saved list. The event-generator generates a variety of suspect actions that are detected by Falco rulesets Source 39সোর্স 39. Its Kubernetes audit events collection is maintained on a best-effort basis and may not fully work Source 39সোর্স 39. The tutorial did not run it.
Know which Falco rules you test. The Falco rules repository says that the maturity_stable rules in falco_rules.yaml are included in the Falco release package Source 40সোর্স 40. It says that other maturity-level rules are released separately, and that they require explicit installation and possible customization Source 40সোর্স 40. In step 14, the tutorial installed the rules file of the k8saudit plugin with falcoctl. The shipped rules file asked for the engine version 0.57.0 and for the plugin container in version 0.4.0 (step 12). A tester can write the rules files and their versions in the test report.
Read what Istio reports. The tutorial ran no traffic, and the run has no metric of Istio. The docs say that the standard Istio metrics are exported to Prometheus by default Source 13সোর্স 13. They say that by default, Istio enables only a small subset of the Envoy-generated statistics Source 13সোর্স 13. A tester can check that the metric that a test needs is among the standard ones before the test starts. Monitoring and Observability shows Prometheus and PromQL.
বাংলা ব্যাখ্যা
cluster-এ পৌঁছানোর আগে Istio file পরীক্ষা করুন। ৩ থেকে ৬ নম্বর ধাপে istioctl analyze --use-kube=false চারটা সমস্যা খুঁজে পেয়েছে। একটা gateway ছিল না, আর একটা subset ছিল না। একটা host gateway-তে ছিল না। একটা DENY rule-এ ছিল কেবল HTTP attribute। তার কোনো cluster লাগেনি। docs বলে, istioctl analyze একটা চালু cluster-এর বিরুদ্ধে বা স্থানীয় configuration file-এর একটা সেটের বিরুদ্ধে চলতে পারে Source 15সোর্স 15। সে দুটোর সমন্বয়ের বিরুদ্ধেও চলতে পারে Source 15সোর্স 15। তাতে cluster-এ পরিবর্তন প্রয়োগের আগেই সমস্যা ধরা যায় Source 15সোর্স 15। একজন tester একটা pull request-এর Istio file-এ -A দিয়ে তাকে চালাতে পারেন। ৪ নম্বর ধাপে দুটো error-যুক্ত একটা file namespace option ছাড়া call-এ পাস করেছে। ৫ নম্বর ধাপে threshold ঠিক করেছে একটা warning-এর exit code। ৬ নম্বর ধাপে পার্স করা যায়নি এমন একটা file exit code 65 দিয়েছে।
fault injection দিয়ে একটা resilience test-এর পরিকল্পনা করুন। টিউটোরিয়াল কোনো traffic চালায়নি আর কোনো fault ঢোকায়নি। docs fault injection-কে সংজ্ঞায়িত করে একটা পরীক্ষার পদ্ধতি হিসেবে Source 11সোর্স 11। সে একটা system-এ ত্রুটি ঢোকায়, যাতে নিশ্চিত হওয়া যায় সে ত্রুটির অবস্থা সইতে আর সেখান থেকে সেরে উঠতে পারে Source 11সোর্স 11। network স্তরে packet দেরি করানো বা pod মেরে ফেলার মতো অন্য উপায়ের উল্টো, Istio আপনাকে application স্তরে fault ঢোকাতে দেয় Source 11সোর্স 11। Istio-তে HTTP request-এর জন্য Envoy timeout ডিফল্টভাবে বন্ধ Source 11সোর্স 11। HTTP request-এর ডিফল্ট retry আচরণ হলো ত্রুটি ফেরত দেওয়ার আগে দুবার retry করা Source 11সোর্স 11। একজন tester এই দুটো default test plan-এ লিখে রাখতে পারেন। docs বলে, fault injection configuration একই virtual service-এ retry বা timeout configuration-এর সঙ্গে একত্র করা যায় না Source 11সোর্স 11। আপনি যদি application code-এও failure recovery policy ঠিক করেন, তবে application-এর policy আর Istio-র policy দুটোই স্বাধীনভাবে কাজ করে Source 11সোর্স 11। দুই সেটের সংঘাত বাধতে পারে Source 11সোর্স 11।
mutual TLS mode আর policy-র ক্রম পড়ুন। ৬ নম্বর ধাপে file-এ STRICT mode-এর একটা PeerAuthentication ছিল। টিউটোরিয়ালের পরীক্ষা file পড়েছে আর কোনো traffic পাঠায়নি। Istio mutual TLS-এর একটা permissive mode আছে, যা একটা service-কে একই সময়ে plaintext traffic আর mutual TLS traffic দুটোই নিতে দেয় Source 12সোর্স 12। client-এর configuration শেষ হলে operator server-কে শুধু mutual TLS mode-এ সাজাতে পারেন Source 12সোর্স 12। এনক্রিপ্টেড traffic আশা করা একটা test-এর আগে একজন tester namespace-এর mode পড়ে নিতে পারেন। docs বলে, Istio মিলে যাওয়া policy খোঁজে স্তরে স্তরে, এই ক্রমে: CUSTOM, DENY, তারপর ALLOW Source 12সোর্স 12। "deny by default" আচরণ কেবল তখনই প্রযোজ্য, যখন workload-এ ALLOW action-সহ অন্তত একটা authorization policy আছে Source 12সোর্স 12। একজন tester প্রতিটা স্তরের জন্য একটা request-এর প্রত্যাশিত ফল লিখে রাখতে পারেন।
pipeline-এ policy test রাখুন। ৮ আর ৯ নম্বর ধাপে opa test, opa check --strict আর opa fmt --fail --list file-এর ওপর চলেছে। exit code ছিল ব্যর্থ test-এর জন্য 2, strict error-এর জন্য 1, আর নতুন করে format করতে হবে এমন file-এর জন্য 2। docs বলে, --fail-on-empty CI/CD pipeline-এও কাজে লাগে, যাতে নিশ্চিত হওয়া যায় test আসলেই চলছে Source 30সোর্স 30। ৮ নম্বর ধাপে ভুল বানানের test-যুক্ত একটা কপি 0 দিয়ে বেরিয়েছে আর কোনো test চালায়নি। একজন tester একটা rule শেষ হওয়ার প্রতিটা উপায়ের জন্য একটা করে test যোগ করতে পারেন: deny, allow, আর একটা অনুপস্থিত field। শেষটার জন্য ৮ নম্বর ধাপে securityContext-হীন একটা Pod ছিল।
OPA server-কে অন্য যেকোনো API-র মতো পরীক্ষা করুন। ১০ নম্বর ধাপে input key-তে Pod-সহ একটা request সেই উত্তর পেয়েছে, যা policy তার জন্য দেয়। Pod-কে পুরো body হিসেবে পাঠানো একটা request একটা privileged Pod-এর জন্য true পেয়েছে। সে warning 'input' key missing from the request-ও পেয়েছে। REST page বলে, request body-তে থাকে একটা object, যা input document-এর মান ঠিক করে Source 32সোর্স 32। সে বলে, decision logging চালু থাকলে response-এ decision_id field থাকে, যা সিদ্ধান্তটাকে অনন্যভাবে শনাক্ত করে Source 32সোর্স 32। caller সম্পর্ক মেলানোর জন্য এই identifier ব্যবহার করতে পারে Source 32সোর্স 32। প্রতিটা decision log event-এ থাকে কোন policy query হয়েছে আর query-র input Source 33সোর্স 33। তাতে bundle metadata আর অন্য তথ্যও থাকে, যা policy সিদ্ধান্তের audit আর offline debugging সম্ভব করে Source 33সোর্স 33। একজন tester প্রতিটা response-এর warning key দেখে নিতে আর একটা test run-এর decision log রেখে দিতে পারেন।
cluster ছাড়া Gatekeeper template পরীক্ষা করুন। ১১ নম্বর ধাপে gator verify দুটো case-এর একটা Suite দিয়ে একটা template আর একটা constraint পরীক্ষা করেছে। gator test একটা object পরীক্ষা করেছে। docs বলে, gator verify test-কে তিন স্তরে সাজায়: Suite, Test আর Case Source 38সোর্স 38। একটা Case ঠিক করে কোন object যাচাই হবে আর object-টা যাচাইয়ে পাস করবে বলে আশা করা হয় কি না Source 38সোর্স 38। run-এ Suite নয় এমন একটা file PASS ছাপিয়েছে। docs আরও উল্লেখ করে, audit আর gator test আলাদা enforcement point Source 38সোর্স 38। তাদের কাছে AdmissionReview request metadata নেই Source 38সোর্স 38। একজন tester Rego input.review-এর কোন field পড়ে তার তালিকা করতে পারেন, আর প্রতিটা field এই উল্লেখের বিরুদ্ধে মিলিয়ে দেখতে পারেন। টিউটোরিয়াল এটা করেনি, আর সে কোনো cluster-এ Gatekeeper চালায়নি।
Falco rule যাচাই করুন আর event আবার চালান। ১২ আর ১৩ নম্বর ধাপে falco -V বৈধ file-এর জন্য 0 দিয়ে আর প্রতিটা ভাঙা file-এর জন্য 1 দিয়ে বেরিয়েছে। reference বলে, -V file পড়ে, load হওয়া rule যাচাই করে আর বেরিয়ে যায় Source 25সোর্স 25। সে বলে, --dry-run event প্রক্রিয়া না করে Falco চালায় Source 25সোর্স 25। সে configuration ও rule-এ কোনো ত্রুটি আছে কি না যাচাই করতে সাহায্য করতে পারে Source 25সোর্স 25। ১৫ নম্বর ধাপে তিনটা event default setting-এ দুটো alert আর rule_matching=all দিয়ে তিনটা alert দিয়েছে। একজন tester প্রতিটা rule-এর জন্য audit event-এর একটা ছোট file রাখতে পারেন, আর alert একটা সংরক্ষিত তালিকার সঙ্গে মিলিয়ে দেখতে পারেন। event-generator এমন নানা সন্দেহজনক কাজ তৈরি করে, যা Falco ruleset ধরে Source 39সোর্স 39। তার Kubernetes audit events collection best-effort ভিত্তিতে রক্ষণাবেক্ষণ হয় আর পুরোপুরি কাজ নাও করতে পারে Source 39সোর্স 39। টিউটোরিয়াল তাকে চালায়নি।
কোন Falco rule পরীক্ষা করছেন তা জানুন। Falco rules repository বলে, falco_rules.yaml-এর maturity_stable rule Falco release package-এ থাকে Source 40সোর্স 40। সে বলে, অন্য maturity-স্তরের rule আলাদাভাবে release হয়, আর তাদের স্পষ্ট install আর সম্ভবত নিজের মতো সাজানো লাগে Source 40সোর্স 40। ১৪ নম্বর ধাপে টিউটোরিয়াল falcoctl দিয়ে k8saudit plugin-এর rules file install করেছে। shipped rules file চেয়েছিল engine সংস্করণ ০.৫৭.০ আর container plugin-এর ০.৪.০ সংস্করণ (১২ নম্বর ধাপ)। একজন tester test report-এ rules file আর তাদের সংস্করণ লিখে রাখতে পারেন।
Istio কী জানায় তা পড়ুন। টিউটোরিয়াল কোনো traffic চালায়নি, আর run-এ Istio-র কোনো metric নেই। docs বলে, Istio-র standard metrics ডিফল্টভাবে Prometheus-এ export হয় Source 13সোর্স 13। তারা বলে, ডিফল্টভাবে Istio Envoy-র তৈরি statistics-এর কেবল একটা ছোট উপসেট চালু রাখে Source 13সোর্স 13। একজন tester test শুরুর আগে দেখে নিতে পারেন, test-এর দরকারি metric standard metric-গুলোর মধ্যে আছে কি না। Monitoring and Observability Prometheus আর PromQL দেখায়।
Common mistakes
- Reading "No validation issues found" as a pass. In step 4, a file with two errors printed it when the call had no namespace option. The reference lists the default of
--namespaceas empty Source 16সোর্স 16. In step 6, a file that could not be parsed printed it too, and the exit code was 65. - Trusting the exit code of
istioctl analyzealone. The reference says that the default value of--failure-thresholdisErrorSource 16সোর্স 16. In step 5, a file with one warning gave 0 with the default threshold and 79 withWarning. With-o json, a file with errors gave 0. - Assuming that mutual TLS is on. The docs say that Istio mutual TLS has a permissive mode, which allows a service to accept both plaintext traffic and mutual TLS traffic at the same time Source 12সোর্স 12. The tutorial's file used the mode
STRICT, and the tutorial sent no traffic. - Using the demo profile for a performance test. The docs say that the demo profile enables high levels of tracing and access logging, so it is not suitable for performance tests Source 14সোর্স 14. In step 2, the
demoprofile gave 42 objects, with both gateways. - Putting a fault and a retry or a timeout on one virtual service. The docs say that the fault injection configuration can not be combined with retry or timeout configuration on the same virtual service Source 11সোর্স 11. The tutorial did not test this.
- Sending an object to OPA without the
inputkey. In step 10, the policy answeredtruefor a privileged Pod that was sent as the whole body, and the response had awarning. The REST page says that any additional top-level keys beyondinputare treated as request metadata Source 32সোর্স 32. - Trusting an
opa testthat ran no test. The docs say that when you misspell a test name or run no test by accident,opa testwill still succeed Source 30সোর্স 30. In step 8, it exited with 0 for the misspelled prefixtset_. - Writing Rego in the wrong syntax for the tool. In step 9, OPA 1.22.4 rejected a file in the old syntax and accepted it with
--v0-compatible. The Gatekeeper docs say that by default only Rego v0 is allowed in a ConstraintTemplate Source 37সোর্স 37. - Counting a file that is not a Suite as a passed test. The docs say that a valid Suite file must declare
kind: Suiteand anapiVersion, and thatgator verifysilently ignores files that do not declare them Source 38সোর্স 38. In step 11,not-a-suite.yamlprintedPASSand the exit code was 0. - Validating the shipped Falco rules without the plugin that they ask for. In step 12,
falco -Vwith the default configuration exited with 1 and printedPlugin requirement not satisfied, must load one of: container (>= 0.4.0). - Expecting every Falco rule that matches to fire. The docs say that by default Falco applies rules per event type on a "first match wins" basis Source 24সোর্স 24. In step 15, the second event matched two rules, and the default setting raised one alert for it. The docs warn that
rule_matching: allmay lead to increased CPU usage Source 24সোর্স 24. - Reading the exit code of Falco as the alert signal. In step 15, Falco exited with 0 in both runs, and it raised alerts.
- Taking the install checks of the tutorial for more than they are. The install compared the SHA-256 of
istioctl, OPA, and gator with a file from the same host as the archive. It checked the Falco archive against a signature fromdownload.falco.organd a key fromfalco.org, and it did not compare the fingerprint of the key with a second source. The tutorial treats these checks as a way to find a damaged or swapped archive.
সহজ English
- Reading "No validation issues found" as a pass. In step 4, a file with two errors printed it when the call had no namespace option. The reference lists the default of
--namespaceas empty Source 16সোর্স 16. In step 6, a file that could not be parsed printed it too, and the exit code was 65. - Trusting the exit code of
istioctl analyzealone. The reference says that the default value of--failure-thresholdisErrorSource 16সোর্স 16. In step 5, a file with one warning gave 0 with the default threshold and 79 withWarning. With-o json, a file with errors gave 0. - Assuming that mutual TLS is on. The docs say that Istio mutual TLS has a permissive mode, which allows a service to accept both plaintext traffic and mutual TLS traffic at the same time Source 12সোর্স 12. The tutorial's file used the mode
STRICT, and the tutorial sent no traffic. - Using the demo profile for a performance test. The docs say that the demo profile enables high levels of tracing and access logging, so it is not suitable for performance tests Source 14সোর্স 14. In step 2, the
demoprofile gave 42 objects, with both gateways. - Putting a fault and a retry or a timeout on one virtual service. The docs say that the fault injection configuration can not be combined with retry or timeout configuration on the same virtual service Source 11সোর্স 11. The tutorial did not test this.
- Sending an object to OPA without the
inputkey. In step 10, the policy answeredtruefor a privileged Pod that was sent as the whole body, and the response had awarning. The REST page says that any additional top-level keys beyondinputare treated as request metadata Source 32সোর্স 32. - Trusting an
opa testthat ran no test. The docs say that when you misspell a test name or run no test by accident,opa testwill still succeed Source 30সোর্স 30. In step 8, it exited with 0 for the misspelled prefixtset_. - Writing Rego in the wrong syntax for the tool. In step 9, OPA 1.22.4 rejected a file in the old syntax and accepted it with
--v0-compatible. The Gatekeeper docs say that by default only Rego v0 is allowed in a ConstraintTemplate Source 37সোর্স 37. - Counting a file that is not a Suite as a passed test. The docs say that a valid Suite file must declare
kind: Suiteand anapiVersion, and thatgator verifysilently ignores files that do not declare them Source 38সোর্স 38. In step 11,not-a-suite.yamlprintedPASSand the exit code was 0. - Validating the shipped Falco rules without the plugin that they ask for. In step 12,
falco -Vwith the default configuration exited with 1 and printedPlugin requirement not satisfied, must load one of: container (>= 0.4.0). - Expecting every Falco rule that matches to fire. The docs say that by default Falco applies rules per event type on a "first match wins" basis Source 24সোর্স 24. In step 15, the second event matched two rules, and the default setting raised one alert for it. The docs warn that
rule_matching: allmay lead to increased CPU usage Source 24সোর্স 24. - Reading the exit code of Falco as the alert signal. In step 15, Falco exited with 0 in both runs, and it raised alerts.
- Taking the install checks of the tutorial for more than they are. The install compared the SHA-256 of
istioctl, OPA, and gator with a file from the same host as the archive. It checked the Falco archive against a signature fromdownload.falco.organd a key fromfalco.org, and it did not compare the fingerprint of the key with a second source. The tutorial treats these checks as a way to find a damaged or swapped archive.
বাংলা ব্যাখ্যা
- "No validation issues found"-কে পাস ভাবা। ৪ নম্বর ধাপে দুটো error-যুক্ত একটা file namespace option ছাড়া call-এ এটা ছাপিয়েছে। reference
--namespace-এর default খালি দেখায় Source 16সোর্স 16। ৬ নম্বর ধাপে পার্স করা যায়নি এমন একটা file-ও এটা ছাপিয়েছে, আর exit code ছিল 65। - শুধু
istioctl analyze-এর exit code-এর ওপর ভরসা করা। reference বলে,--failure-threshold-এর default মানErrorSource 16সোর্স 16। ৫ নম্বর ধাপে একটা warning-যুক্ত file default threshold-এ 0 আরWarningদিয়ে 79 দিয়েছে।-o jsonদিয়ে error-যুক্ত একটা file 0 দিয়েছে। - mutual TLS চালু ধরে নেওয়া। docs বলে, Istio mutual TLS-এর একটা permissive mode আছে, যা একটা service-কে একই সময়ে plaintext traffic আর mutual TLS traffic দুটোই নিতে দেয় Source 12সোর্স 12। টিউটোরিয়ালের file
STRICTmode ব্যবহার করেছে, আর টিউটোরিয়াল কোনো traffic পাঠায়নি। - performance test-এ demo profile ব্যবহার করা। docs বলে, demo profile উচ্চমাত্রার tracing আর access logging চালু করে, তাই performance test-এর উপযোগী নয় Source 14সোর্স 14। ২ নম্বর ধাপে
demoprofile দুটো gateway-সহ ৪২টা object দিয়েছে। - একই virtual service-এ fault আর retry বা timeout রাখা। docs বলে, fault injection configuration একই virtual service-এ retry বা timeout configuration-এর সঙ্গে একত্র করা যায় না Source 11সোর্স 11। টিউটোরিয়াল এটা পরীক্ষা করেনি।
inputkey ছাড়া OPA-তে object পাঠানো। ১০ নম্বর ধাপে পুরো body হিসেবে পাঠানো একটা privileged Pod-এর জন্য policytrueউত্তর দিয়েছে, আর response-এ ছিল একটাwarning। REST page বলে,input-এর বাইরে বাড়তি যেকোনো top-level key request metadata হিসেবে গণ্য হয় Source 32সোর্স 32।- কোনো test না চালানো
opa test-এ ভরসা করা। docs বলে, আপনি কোনো test-এর নাম ভুল লিখলে বা ভুলে কোনো test না চালালেopa testতবু সফল হয় Source 30সোর্স 30। ৮ নম্বর ধাপে ভুল বানানের prefixtset_-এর জন্য সে 0 দিয়ে বেরিয়েছে। - tool-এর জন্য ভুল syntax-এ Rego লেখা। ৯ নম্বর ধাপে OPA 1.22.4 পুরোনো syntax-এর একটা file প্রত্যাখ্যান করেছে, আর
--v0-compatibleদিয়ে গ্রহণ করেছে। Gatekeeper docs বলে, ConstraintTemplate-এ ডিফল্টভাবে কেবল Rego v0 অনুমোদিত Source 37সোর্স 37। - Suite নয় এমন একটা file-কে পাস হওয়া test গোনা। docs বলে, বৈধ Suite file-এ
kind: Suiteআর একটাapiVersionঘোষণা করতে হয়, আর যে file-এ এগুলো ঘোষণা নেই,gator verifyসেগুলো নীরবে উপেক্ষা করে Source 38সোর্স 38। ১১ নম্বর ধাপেnot-a-suite.yamlPASSছাপিয়েছে আর exit code ছিল 0। - shipped Falco rule যাচাই করা, সে যে plugin চায় তা ছাড়া। ১২ নম্বর ধাপে default configuration দিয়ে
falco -V1 দিয়ে বেরিয়েছে আর ছাপিয়েছেPlugin requirement not satisfied, must load one of: container (>= 0.4.0)। - মিলে যাওয়া প্রতিটা Falco rule-ই চালু হবে আশা করা। docs বলে, ডিফল্টভাবে Falco প্রতিটা event type-এর জন্য rule প্রয়োগ করে "first match wins" ভিত্তিতে Source 24সোর্স 24। ১৫ নম্বর ধাপে দ্বিতীয় event দুটো rule মিলিয়েছে, আর default setting তার জন্য একটা alert তুলেছে। docs সতর্ক করে,
rule_matching: allCPU ব্যবহার বাড়াতে পারে Source 24সোর্স 24। - Falco-র exit code-কে alert-এর সংকেত পড়া। ১৫ নম্বর ধাপে Falco দুবারই 0 দিয়ে বেরিয়েছে, আর সে alert তুলেছে।
- টিউটোরিয়ালের install-এর যাচাইকে তার চেয়ে বেশি কিছু ভাবা। install
istioctl, OPA আর gator-এর SHA-256 মিলিয়েছে archive-এর একই host-এর একটা file-এর সঙ্গে। সে Falco archive-কে যাচাই করেছেdownload.falco.org-এর একটা signature আরfalco.org-এর একটা key-র বিরুদ্ধে, আর key-র fingerprint দ্বিতীয় কোনো source-এর সঙ্গে মেলায়নি। টিউটোরিয়াল এই যাচাইগুলোকে নষ্ট বা বদলে দেওয়া archive ধরার উপায় হিসেবে দেখে।
What a tester can check
Tutorial advice
This list is the tutorial's own advice for a tester who works with Istio, Falco, OPA, and Gatekeeper.
- Run
istioctl analyze --use-kube=false -Aon every Istio file of a pull request, and read the messages and the exit code together. - Choose
--failure-thresholdon purpose:Errorblocks the errors only, andWarningblocks the warnings too. - Do not use the exit code of
-o jsonas the pass signal. Read the level of each message. - Search the output for
could not be parsed, and not only forNo validation issues found. - Render the manifest of the profile that you test with
istioctl manifest generate, and keep the list of its workloads in the report. - Write one OPA test for each way that a rule can end: denied, allowed, and a missing field.
- Run
opa test --fail-on-empty,opa check --strict, andopa fmt --fail --listin the pipeline. - Wrap the object in
inputwhen you call the OPA server, and check thewarningkey of the response. - Keep the decision log of a test run: the path, the input, the result, and the
decision_id. - Run
gator verifyon every Suite, and count the Suites, so that a file that is not a Suite is noticed. - Test a Gatekeeper template with a violating object and a good object, and give
violationsa number and amessage, not only yes or no. - Validate every Falco rules file with
falco -Vin the pipeline, with the plugins that the file asks for. - Replay a small file of audit events for each Kubernetes rule, and compare the alerts with a saved list, in the default setting and with
rule_matching=all. - Check the checksum or the signature of each security tool that you install, and write down what the check does not prove.
- Write the versions of istioctl, OPA, gator, Falco, and the plugins in every test report.
সহজ English
Tutorial advice
This list is the tutorial's own advice for a tester who works with Istio, Falco, OPA, and Gatekeeper.
- Run
istioctl analyze --use-kube=false -Aon every Istio file of a pull request, and read the messages and the exit code together. - Choose
--failure-thresholdon purpose:Errorblocks the errors only, andWarningblocks the warnings too. - Do not use the exit code of
-o jsonas the pass signal. Read the level of each message. - Search the output for
could not be parsed, and not only forNo validation issues found. - Render the manifest of the profile that you test with
istioctl manifest generate, and keep the list of its workloads in the report. - Write one OPA test for each way that a rule can end: denied, allowed, and a missing field.
- Run
opa test --fail-on-empty,opa check --strict, andopa fmt --fail --listin the pipeline. - Wrap the object in
inputwhen you call the OPA server, and check thewarningkey of the response. - Keep the decision log of a test run: the path, the input, the result, and the
decision_id. - Run
gator verifyon every Suite, and count the Suites, so that a file that is not a Suite is noticed. - Test a Gatekeeper template with a violating object and a good object, and give
violationsa number and amessage, not only yes or no. - Validate every Falco rules file with
falco -Vin the pipeline, with the plugins that the file asks for. - Replay a small file of audit events for each Kubernetes rule, and compare the alerts with a saved list, in the default setting and with
rule_matching=all. - Check the checksum or the signature of each security tool that you install, and write down what the check does not prove.
- Write the versions of istioctl, OPA, gator, Falco, and the plugins in every test report.
বাংলা ব্যাখ্যা
Tutorial advice
এই তালিকা টিউটোরিয়ালের নিজের পরামর্শ, এমন একজন tester-এর জন্য যিনি Istio, Falco, OPA আর Gatekeeper নিয়ে কাজ করেন।
- একটা pull request-এর প্রতিটা Istio file-এ
istioctl analyze --use-kube=false -Aচালান, আর message ও exit code একসঙ্গে পড়ুন। --failure-thresholdইচ্ছে করে বাছুন:Errorশুধু error আটকায়, আরWarningwarning-ও আটকায়।-o json-এর exit code-কে পাসের সংকেত ধরবেন না। প্রতিটা message-এর level পড়ুন।- output-এ শুধু
No validation issues foundনয়,could not be parsed-ও খুঁজুন। - আপনি যে profile পরীক্ষা করছেন,
istioctl manifest generateদিয়ে তার manifest বানান, আর তার workload-এর তালিকা report-এ রাখুন। - একটা rule শেষ হওয়ার প্রতিটা উপায়ের জন্য একটা করে OPA test লিখুন: deny, allow, আর একটা অনুপস্থিত field।
- pipeline-এ
opa test --fail-on-empty,opa check --strictআরopa fmt --fail --listচালান। - OPA server-কে ডাকার সময় object-কে
input-এ মুড়ে দিন, আর response-এরwarningkey দেখুন। - একটা test run-এর decision log রাখুন: path, input, result আর
decision_id। - প্রতিটা Suite-এ
gator verifyচালান, আর Suite গুনুন, যাতে Suite নয় এমন file চোখে পড়ে। - একটা Gatekeeper template একটা violation-যুক্ত object আর একটা ভালো object দিয়ে পরীক্ষা করুন, আর
violations-এ শুধু yes বা no নয়, একটা সংখ্যা আর একটাmessageদিন। - pipeline-এ প্রতিটা Falco rules file
falco -Vদিয়ে যাচাই করুন, file যে plugin চায় সেগুলো-সহ। - প্রতিটা Kubernetes rule-এর জন্য audit event-এর একটা ছোট file আবার চালান, আর default setting-এ এবং
rule_matching=allদিয়ে alert একটা সংরক্ষিত তালিকার সঙ্গে মেলান। - আপনি যে security tool install করেন, তার checksum বা signature যাচাই করুন, আর যাচাইটা কী প্রমাণ করে না তা লিখে রাখুন।
- প্রতিটা test report-এ istioctl, OPA, gator, Falco আর plugin-গুলোর সংস্করণ লিখুন।
Key words
| Term | Meaning |
|---|---|
| Graduated | highly mature, robust projects whose adopters have demonstrated their production-readiness by their deployment to production environments |
| Incubation | projects gaining adoption, focusing on improving stability and maturity |
| Service mesh | an infrastructure layer that gives applications capabilities like zero-trust security, observability, and advanced traffic management, without code changes |
| Istiod | provides service discovery, configuration, and certificate management |
| Sidecar mode | deploys an Envoy proxy along with each pod that you start in your cluster, or running alongside services running on VMs |
| Ambient mode | uses a per-node Layer 4 proxy, and optionally a per-namespace Envoy proxy for Layer 7 features |
| ztunnel | the secure overlay handles routing and zero trust security for traffic |
| VirtualService | lets you configure how requests are routed to a service within an Istio service mesh |
| DestinationRule | customize Envoy's traffic policies when calling the entire destination service or a particular service subset |
| PeerAuthentication | used for service-to-service authentication to verify the client making the connection |
| Fault injection | a testing method that introduces errors into a system to ensure that it can withstand and recover from error conditions |
| istioctl analyze | a diagnostic tool that can detect potential issues with your Istio configuration |
| Falco | a cloud native security tool that provides runtime security across hosts, containers, Kubernetes, and cloud environments |
| Macro | rule condition snippets that can be re-used inside rules and even other macros |
| Condition | a Boolean predicate expressed using the condition syntax |
| Plugin | shared libraries that conform to a documented API |
| falcoctl | allows you to easily install rules and plugins and perform administrative tasks with Falco |
| OPA | an open source, general-purpose policy engine that unifies policy enforcement across the stack |
| Rego | declarative, so policy authors can focus on what queries should return rather than how queries should be executed |
| Decision log | events that describe policy queries |
| Gatekeeper | a specialized project providing first-class integration between OPA and Kubernetes |
| ConstraintTemplate | define a way to validate some set of Kubernetes objects in Gatekeeper's Kubernetes admission controller |
| gator | a tool for evaluating Gatekeeper ConstraintTemplates and Constraints in a local environment |