GitOps Integration with nctl
NOTE: Nirmata Control Hub can open the pull requests or merge requests for approved exceptions automatically, without nctl. See Git Integration (Automatic PRs/MRs).
Policy exceptions can be managed and deployed using GitOps, similar to any other resource. Follow Nirmata Control Hub’s request and approval workflow for creating and approving exceptions. After approval, your team uses nctl to open a pull request that adds the exception to the GitOps repository, and your GitOps tool deploys it after the pull request is merged.
Managing Deployment Settings
An admin user can manage the deployment settings for Policy Exception Requests.
- Go to Settings -> Policy Exceptions and click on the
Deploymenttab. The Settings page for Policy Exceptions deployment opens withAutomatic deploymentset as the default. - Click on the radio button beside
GitOps deployment. - Enter the Git repository URL under
Git repository for policy exceptionsto provide a path for mapping the available clusters to a repository branch. - Optionally, enter a folder under
Folder for policy exception files. The path is relative to the repository root, for examplepolicy-exceptions, and must exist on each mapped branch. The path must not contain spaces or.or..segments. Leave it empty to write exception files to the repository root. - Map the clusters that are onboarded in Nirmata Control Hub to a branch in the Git repository. To do so:
a. Under
Cluster Expression to Branch Mappings, selectcluster.labelorcluster.namefrom the dropdown.
b. Ifcluster.labelis selected, choose the label from the dropdown.
c. Select the operator type from the dropdown. The available options arein,exists, andcontains.
d. Select the operator value from the dropdown or enter it manually, then enter the repository branch name.
e. Ifcluster.nameis selected, choose the operator type from the dropdown. The available options areinandcontains.
f. Select the operator value from the dropdown or enter it manually, then enter the repository branch name.
g. Click the+button to add more cluster mappings.

- Finally, click Save.
The other fields on this page (Create PRs/MRs automatically, Git account, Reviewers, and the repository exception settings) are described in Git Integration (Automatic PRs/MRs). Leave Create PRs/MRs automatically off to open pull requests with nctl.
GitOps Deployment of Policy Exceptions in Action
nctl is required for creating Pull Requests for Policy Exception Requests. Learn more about installing nctl and its commands in the official documentation.
To deploy Policy Exceptions through GitOps:
- Create a Policy Exception Request by following the steps here.
- After the request is approved, a
Create Deploy PRmessage will appear under the Deploy Status section in Nirmata Control Hub. - In your local terminal, verify the created Policy Exception Request by executing:
nctl get policyexceptionrequest
NOTE: Login using the
nctl login nchcommand to fetch policy exception requests from Nirmata Control Hub.
- Now, create a pull request to deploy the Policy Exception by executing the following command. It creates PRs for all Policy Exception Requests that are in
Approvedstate.
nctl create pull-request
To create a PR for a given Policy Exception Request, use the --per-name argument. See nctl create pull-request for all options.
nctl create pull-request --per-name <per-name>
NOTE: NCTL needs a Git Personal Access Token (PAT) to be able to create pull requests on behalf of the user. Use the
nctl login gitcommand to set the Git login credentials, for examplenctl login git --provider gitlab --domain gitlab.example.com.
NOTE: The Git PAT should have write access to the repository. NCTL creates a temporary branch to commit the PolicyException YAML to the folder set in
Folder for policy exception filesand then creates a PR to the relevant branch mapped in Nirmata Control Hub.
NOTE: If Create PRs/MRs automatically is turned on,
nctl create pull-requestprints a message that Nirmata Control Hub opens the pull/merge requests for the tenant and exits without creating a PR.
- Once the PR is created, a team member can review and merge it into the repository. The Policy Exception will be deployed to the cluster according to your GitOps/pipeline workflow settings.
- Verify the deployment by checking the Policy Exceptions in Nirmata Control Hub - you should see a
Merge Deploy PRmessage with a link to the PR under the Deploy Status section while the PR is open. - When revoking a deployed Policy Exception, after revoking it from Nirmata Control Hub, create a PR using the same process to remove the PolicyException from the cluster.
Feedback
Was this page helpful?
Glad to hear it! Please tell us how we can improve.
Sorry to hear that. Please tell us how we can improve.