generated from terraform-ibm-modules/terraform-ibm-module-template
    
        
        - 
                Notifications
    
You must be signed in to change notification settings  - Fork 14
 
feat: add sub-module to enable kube-audit in base-ocp clusters #619
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
  
     Merged
                    Changes from 11 commits
      Commits
    
    
            Show all changes
          
          
            53 commits
          
        
        Select commit
          Hold shift + click to select a range
      
      552b307
              
                feat: add sub-module to enable kube-audit in base-ocp clusters
              
              
                Aashiq-J 9d44de6
              
                test
              
              
                Aashiq-J 3b16802
              
                test
              
              
                Aashiq-J 9292d5d
              
                test
              
              
                Aashiq-J ccef77e
              
                test
              
              
                Aashiq-J 684e97d
              
                update advanced example
              
              
                Aashiq-J e90cad9
              
                documentation
              
              
                Aashiq-J 79ffe77
              
                change image variable
              
              
                Aashiq-J 1bb31a8
              
                add provider
              
              
                Aashiq-J e061d4b
              
                update sleep
              
              
                Aashiq-J 12f383c
              
                update script
              
              
                Aashiq-J ec3a5e6
              
                Merge branch 'main' into audit
              
              
                Aashiq-J ccbed82
              
                review changes
              
              
                Aashiq-J 946278b
              
                Merge branch 'main' into audit
              
              
                Aashiq-J 5f4b46a
              
                Merge branch 'main' of https://github.com/terraform-ibm-modules/terra…
              
              
                Aashiq-J fba88e4
              
                updates
              
              
                Aashiq-J 744e85d
              
                test
              
              
                Aashiq-J 2e73fdc
              
                test
              
              
                Aashiq-J 842d8f1
              
                Merge branch 'main' into audit
              
              
                Aashiq-J 8259907
              
                test
              
              
                Aashiq-J 3ced82b
              
                test
              
              
                Aashiq-J 464c143
              
                test
              
              
                Aashiq-J 67db02d
              
                update
              
              
                Aashiq-J afbc0ad
              
                Merge branch 'main' into audit
              
              
                Aashiq-J d7c852f
              
                update
              
              
                Aashiq-J b91a834
              
                test
              
              
                Aashiq-J 3206a0a
              
                test
              
              
                Aashiq-J 06a5a2a
              
                Merge branch 'main' into audit
              
              
                Aashiq-J 4d7d049
              
                test
              
              
                Aashiq-J 543c676
              
                test
              
              
                Aashiq-J df9c994
              
                test
              
              
                Aashiq-J 3ea0e07
              
                test
              
              
                Aashiq-J 980cfc5
              
                test
              
              
                Aashiq-J e67d2ce
              
                test
              
              
                Aashiq-J 588c1ff
              
                test
              
              
                Aashiq-J f92906f
              
                test
              
              
                Aashiq-J ae8ba0c
              
                test
              
              
                Aashiq-J 27c4aed
              
                test
              
              
                Aashiq-J 94187cc
              
                test
              
              
                Aashiq-J 0823497
              
                test
              
              
                Aashiq-J 7966557
              
                test
              
              
                Aashiq-J 8d041e0
              
                test
              
              
                Aashiq-J f190b17
              
                test
              
              
                Aashiq-J ba450c1
              
                test
              
              
                Aashiq-J 4345fce
              
                test
              
              
                Aashiq-J 5d7180d
              
                Merge branch 'main' into audit
              
              
                Aashiq-J ba93b82
              
                Merge branch 'main' into audit
              
              
                Aashiq-J 7d3cce9
              
                update
              
              
                Aashiq-J c2a6de6
              
                Merge branch 'main' into audit
              
              
                imprateeksh 72bdce3
              
                Merge branch 'main' into audit
              
              
                Aashiq-J bc76879
              
                Merge branch 'main' into audit
              
              
                Aashiq-J 7594159
              
                Merge branch 'main' of https://github.com/terraform-ibm-modules/terra…
              
              
                Aashiq-J 3969896
              
                update
              
              
                Aashiq-J File filter
Filter by extension
Conversations
          Failed to load comments.   
        
        
          
      Loading
        
  Jump to
        
          Jump to file
        
      
      
          Failed to load files.   
        
        
          
      Loading
        
  Diff view
Diff view
There are no files selected for viewing
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,99 @@ | ||
| # Kubernetes API server audit logs | ||
| 
     | 
||
| To monitor user-initiated, Kubernetes administrative activity made within your cluster, you can collect and forward audit events that are passed through your Kubernetes API server to IBM Cloud Logs or an external server. | ||
| 
     | 
||
| This sub-module helps you to create a Kubernetes audit system by using the provided image and deployment in your existing cluster. [Learn more](https://cloud.ibm.com/docs/openshift?topic=openshift-health-audit) | ||
| 
     | 
||
| **Important**: The sub-module uses the `icr.io/ibm/ibmcloud-kube-audit-to-ibm-cloud-logs` image to forward logs to IBM Cloud Logs. This image is for demonstration purposes only. For a production solution, configure and maintain your own log forwarding image. | ||
| 
     | 
||
| ### Usage | ||
| 
     | 
||
| ```hcl | ||
| # ############################################################################ | ||
| # Init cluster config for helm | ||
| # ############################################################################ | ||
| 
     | 
||
| data "ibm_container_cluster_config" "cluster_config" { | ||
| # update this value with the Id of the cluster where these agents will be provisioned | ||
| cluster_name_id = "cluster_id" | ||
| } | ||
| 
     | 
||
| # ############################################################################ | ||
| # Config providers | ||
| # ############################################################################ | ||
| 
     | 
||
| provider "ibm" { | ||
| # update this value with your IBM Cloud API key value | ||
| ibmcloud_api_key = "XXXXXXXXXXXXXXXXX" #pragma: allowlist secret | ||
| } | ||
| 
     | 
||
| provider "helm" { | ||
| kubernetes { | ||
| host = data.ibm_container_cluster_config.cluster_config.host | ||
| token = data.ibm_container_cluster_config.cluster_config.token | ||
| cluster_ca_certificate = data.ibm_container_cluster_config.cluster_config.ca_certificate | ||
| } | ||
| } | ||
| 
     | 
||
| provider "kubernetes" { | ||
| host = data.ibm_container_cluster_config.cluster_config.host | ||
| token = data.ibm_container_cluster_config.cluster_config.token | ||
| cluster_ca_certificate = data.ibm_container_cluster_config.cluster_config.ca_certificate | ||
| } | ||
| 
     | 
||
| module "kube_audit" { | ||
| source = "terraform-ibm-modules/terraform-ibm-base-ocp-vpc/ibm//modules/kube-audit" | ||
| version = "X.X.X" # Replace "X.X.X" with a release version to lock into a specific release | ||
| cluster_id = "cluster_id" | ||
| cluster_resource_group_id = "resource group id" | ||
| region = "us-south" | ||
| } | ||
| ``` | ||
| 
     | 
||
| <!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK --> | ||
| ### Requirements | ||
| 
     | 
||
| | Name | Version | | ||
| |------|---------| | ||
| | <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >=1.9.0 | | ||
| | <a name="requirement_helm"></a> [helm](#requirement\_helm) | >= 2.15.0, <3.0.0 | | ||
| | <a name="requirement_ibm"></a> [ibm](#requirement\_ibm) | >= 1.70.0, <2.0.0 | | ||
| | <a name="requirement_null"></a> [null](#requirement\_null) | >= 3.2.1, < 4.0.0 | | ||
| 
     | 
||
| ### Modules | ||
| 
     | 
||
| No modules. | ||
| 
     | 
||
| ### Resources | ||
| 
     | 
||
| | Name | Type | | ||
| |------|------| | ||
| | [helm_release.kube_audit](https://registry.terraform.io/providers/hashicorp/helm/latest/docs/resources/release) | resource | | ||
| | [null_resource.set_audit_log_policy](https://registry.terraform.io/providers/hashicorp/null/latest/docs/resources/resource) | resource | | ||
| | [null_resource.set_audit_webhook](https://registry.terraform.io/providers/hashicorp/null/latest/docs/resources/resource) | resource | | ||
| | [ibm_container_cluster_config.cluster_config](https://registry.terraform.io/providers/ibm-cloud/ibm/latest/docs/data-sources/container_cluster_config) | data source | | ||
| | [ibm_container_vpc_cluster.cluster](https://registry.terraform.io/providers/ibm-cloud/ibm/latest/docs/data-sources/container_vpc_cluster) | data source | | ||
| | [ibm_iam_account_settings.iam_account_settings](https://registry.terraform.io/providers/ibm-cloud/ibm/latest/docs/data-sources/iam_account_settings) | data source | | ||
| | [ibm_iam_auth_token.reset_api_key_tokendata](https://registry.terraform.io/providers/ibm-cloud/ibm/latest/docs/data-sources/iam_auth_token) | data source | | ||
| 
     | 
||
| ### Inputs | ||
| 
     | 
||
| | Name | Description | Type | Default | Required | | ||
| |------|-------------|------|---------|:--------:| | ||
| | <a name="input_audit_deployment_name"></a> [audit\_deployment\_name](#input\_audit\_deployment\_name) | The name of log collection deployement and service. | `string` | `"ibmcloud-kube-audit"` | no | | ||
| | <a name="input_audit_log_policy"></a> [audit\_log\_policy](#input\_audit\_log\_policy) | Specify the amount of information that is logged to the API server audit logs by choosing the audit log policy profile to use. Supported values are `default` and `WriteRequestBodies`. | `string` | `"default"` | no | | ||
| | <a name="input_audit_namespace"></a> [audit\_namespace](#input\_audit\_namespace) | The name of the namespace where log collection service and a deployment will be created. | `string` | `"ibm-kube-audit"` | no | | ||
| | <a name="input_audit_webhook_listener_image"></a> [audit\_webhook\_listener\_image](#input\_audit\_webhook\_listener\_image) | The audit webhook listener image reference in the format of `[registry-url]/[namespace]/[image]`.The sub-module uses the `icr.io/ibm/ibmcloud-kube-audit-to-ibm-cloud-logs` image to forward logs to IBM Cloud Logs. This image is for demonstration purposes only. For a production solution, configure and maintain your own log forwarding image. | `string` | `"icr.io/ibm/ibmcloud-kube-audit-to-ibm-cloud-logs"` | no | | ||
| | <a name="input_audit_webhook_listener_image_digest"></a> [audit\_webhook\_listener\_image\_digest](#input\_audit\_webhook\_listener\_image\_digest) | An image digest in the format `sha256:xxxxx...` can also be specified. If no value is passed, latest image is used. | `string` | `null` | no | | ||
| | <a name="input_cluster_config_endpoint_type"></a> [cluster\_config\_endpoint\_type](#input\_cluster\_config\_endpoint\_type) | Specify which type of endpoint to use for for cluster config access: 'default', 'private', 'vpe', 'link'. 'default' value will use the default endpoint of the cluster. | `string` | `"default"` | no | | ||
| | <a name="input_cluster_id"></a> [cluster\_id](#input\_cluster\_id) | The ID of the cluster to deploy the log collection service in. | `string` | n/a | yes | | ||
| | <a name="input_cluster_resource_group_id"></a> [cluster\_resource\_group\_id](#input\_cluster\_resource\_group\_id) | The resource group ID of the cluster. | `string` | n/a | yes | | ||
| | <a name="input_region"></a> [region](#input\_region) | The IBM Cloud region where the cluster is provisioned. | `string` | n/a | yes | | ||
| | <a name="input_use_private_endpoint"></a> [use\_private\_endpoint](#input\_use\_private\_endpoint) | Set this to true to force all api calls to use the IBM Cloud private endpoints. | `bool` | `false` | no | | ||
| | <a name="input_wait_till"></a> [wait\_till](#input\_wait\_till) | To avoid long wait times when you run your Terraform code, you can specify the stage when you want Terraform to mark the cluster resource creation as completed. Depending on what stage you choose, the cluster creation might not be fully completed and continues to run in the background. However, your Terraform code can continue to run without waiting for the cluster to be fully created. Supported args are `MasterNodeReady`, `OneWorkerNodeReady`, `IngressReady` and `Normal` | `string` | `"Normal"` | no | | ||
| | <a name="input_wait_till_timeout"></a> [wait\_till\_timeout](#input\_wait\_till\_timeout) | Timeout for wait\_till in minutes. | `number` | `90` | no | | ||
| 
     | 
||
| ### Outputs | ||
| 
     | 
||
| No outputs. | ||
| <!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK --> | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| # Patterns to ignore when building packages. | ||
| # This supports shell glob matching, relative path matching, and | ||
| # negation (prefixed with !). Only one pattern per line. | ||
| .DS_Store | ||
| # Common VCS dirs | ||
| .git/ | ||
| .gitignore | ||
| .bzr/ | ||
| .bzrignore | ||
| .hg/ | ||
| .hgignore | ||
| .svn/ | ||
| # Common backup files | ||
| *.swp | ||
| *.bak | ||
| *.tmp | ||
| *.orig | ||
| *~ | ||
| # Various IDEs | ||
| .project | ||
| .idea/ | ||
| *.tmproj | ||
| .vscode/ | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| apiVersion: v2 | ||
| name: kube-audit | ||
| description: A Helm chart for kube-audit | ||
| 
     | 
||
| # A chart can be either an 'application' or a 'library' chart. | ||
| # | ||
| # Application charts are a collection of templates that can be packaged into versioned archives | ||
| # to be deployed. | ||
| # | ||
| # Library charts provide useful utilities or functions for the chart developer. They're included as | ||
| # a dependency of application charts to inject those utilities and functions into the rendering | ||
| # pipeline. Library charts do not define any templates and therefore cannot be deployed. | ||
| type: application | ||
| 
     | 
||
| # This is the chart version. This version number should be incremented each time you make changes | ||
| # to the chart and its templates, including the app version. | ||
| # Versions are expected to follow Semantic Versioning (https://semver.org/) | ||
| version: 0.1.2 | ||
| 
     | 
||
| # This is the version number of the application being deployed. This version number should be | ||
| # incremented each time you make changes to the application. Versions are not expected to | ||
| # follow Semantic Versioning. They should reflect the version the application is using. | ||
| # It is recommended to use it with quotes. | ||
| appVersion: "1.16.0" | ||
        
          
  
    
      
          
            31 changes: 31 additions & 0 deletions
          
          31 
        
  modules/kube-audit/helm-charts/kube-audit/templates/deployment.yaml
  
  
      
      
   
        
      
      
    
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| apiVersion: apps/v1 | ||
| kind: Deployment | ||
| metadata: | ||
| name: "{{ .Values.metadata.name }}" | ||
| namespace: "{{ .Values.metadata.namespace }}" | ||
| labels: | ||
| app: "{{ .Values.metadata.name }}" | ||
| spec: | ||
| replicas: 1 | ||
| selector: | ||
| matchLabels: | ||
| app: "{{ .Values.metadata.name }}" | ||
| template: | ||
| metadata: | ||
| labels: | ||
| app: "{{ .Values.metadata.name }}" | ||
| spec: | ||
| containers: | ||
| - name: "{{ .Values.metadata.name }}" | ||
| image: "{{ .Values.image }}" | ||
| imagePullPolicy: Always | ||
| ports: | ||
| - containerPort: 3000 | ||
| securityContext: | ||
| allowPrivilegeEscalation: false | ||
| runAsNonRoot: true | ||
| capabilities: | ||
| drop: | ||
| - ALL | ||
| seccompProfile: | ||
| type: RuntimeDefault | 
        
          
  
    
      
          
            12 changes: 12 additions & 0 deletions
          
          12 
        
  modules/kube-audit/helm-charts/kube-audit/templates/namespace.yaml
  
  
      
      
   
        
      
      
    
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| apiVersion: v1 | ||
| kind: Namespace | ||
| metadata: | ||
| name: "{{ .Values.metadata.namespace }}" | ||
| labels: | ||
| pod-security.kubernetes.io/enforce: restricted | ||
| pod-security.kubernetes.io/enforce-version: latest | ||
| pod-security.kubernetes.io/audit: restricted | ||
| pod-security.kubernetes.io/audit-version: latest | ||
| pod-security.kubernetes.io/warn: restricted | ||
| pod-security.kubernetes.io/warn-version: latest | ||
| security.openshift.io/scc.podSecurityLabelSync: "false" | 
        
          
  
    
      
          
            28 changes: 28 additions & 0 deletions
          
          28 
        
  modules/kube-audit/helm-charts/kube-audit/templates/network-policy.yaml
  
  
      
      
   
        
      
      
    
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| kind: NetworkPolicy | ||
| apiVersion: networking.k8s.io/v1 | ||
| metadata: | ||
| name: "{{ .Values.metadata.name }}" | ||
| namespace: "{{ .Values.metadata.namespace }}" | ||
| spec: | ||
| podSelector: | ||
| matchLabels: | ||
| app: "{{ .Values.metadata.name }}" | ||
| policyTypes: | ||
| - Ingress | ||
| ingress: | ||
| - ports: | ||
| - protocol: TCP | ||
| port: 3000 | ||
| from: | ||
| - namespaceSelector: | ||
| matchLabels: | ||
| kubernetes.io/metadata.name: kube-system | ||
| podSelector: | ||
| matchLabels: | ||
| app: konnectivity-agent | ||
| - namespaceSelector: | ||
| matchLabels: | ||
| kubernetes.io/metadata.name: kube-system | ||
| podSelector: | ||
| matchLabels: | ||
| app: vpn | 
        
          
  
    
      
          
            15 changes: 15 additions & 0 deletions
          
          15 
        
  modules/kube-audit/helm-charts/kube-audit/templates/service.yaml
  
  
      
      
   
        
      
      
    
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| apiVersion: v1 | ||
| kind: Service | ||
| metadata: | ||
| name: "{{ .Values.metadata.name }}-service" | ||
| namespace: "{{ .Values.metadata.namespace }}" | ||
| labels: | ||
| app: "{{ .Values.metadata.name }}" | ||
| spec: | ||
| selector: | ||
| app: "{{ .Values.metadata.name }}" | ||
| ports: | ||
| - protocol: TCP | ||
| port: 80 | ||
| targetPort: 3000 | ||
| type: ClusterIP | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| # NOTE: Mock values added here for helm linter to pass. Actual values are set in main.tf | ||
| metadata: | ||
| name: "ibmcloud-kube-audit" | ||
| namespace: "ibm-kube-audit" | ||
| 
     | 
||
| image: "icr.io/ibm/ibmcloud-kube-audit-to-ibm-cloud-logs" | 
      
      Oops, something went wrong.
        
    
  
  Add this suggestion to a batch that can be applied as a single commit.
  This suggestion is invalid because no changes were made to the code.
  Suggestions cannot be applied while the pull request is closed.
  Suggestions cannot be applied while viewing a subset of changes.
  Only one suggestion per line can be applied in a batch.
  Add this suggestion to a batch that can be applied as a single commit.
  Applying suggestions on deleted lines is not supported.
  You must change the existing code in this line in order to create a valid suggestion.
  Outdated suggestions cannot be applied.
  This suggestion has been applied or marked resolved.
  Suggestions cannot be applied from pending reviews.
  Suggestions cannot be applied on multi-line comments.
  Suggestions cannot be applied while the pull request is queued to merge.
  Suggestion cannot be applied right now. Please check back later.
  
    
  
    
Uh oh!
There was an error while loading. Please reload this page.