Skip to content

Fix L7 policies not being saved properly

Alexander Turinske requested to merge 271169-fix-l7-policies into master

What does this MR do?

Fix L7 policies not being saved properly

  • if the UI does not support L7 policies currently
  • if the user is in yaml mode, save the yaml file

Screenshots (strongly suggested)

Before After
Screen_Shot_2021-02-11_at_4.08.43_PM Screen_Shot_2021-02-11_at_4.09.00_PM

After

➜  gitlab git:(271169-fix-l7-policies) kubectl exec -it -n gitlab-managed-apps -c cilium-agent cilium-xvzn2 -- /bin/bash
root@minikube:/home/cilium# cilium policy get
[
  ...,
  {
    "endpointSelector": {
      "matchLabels": {
        "k8s:io.kubernetes.pod.namespace": "network-policy-demo-cluster-management-5000174-production"
      }
    },
    "ingress": [
      {
        "toPorts": [
          {
            "ports": [
              {
                "port": "80",
                "protocol": "TCP"
              },
              {
                "port": "443",
                "protocol": "TCP"
              }
            ],
            "rules": {
              "http": [
                {
                  "headers": [
                    "X-Forwarded-For: 192.168.1.1"
                  ]
                }
              ]
            }
          }
        ],
        "fromEntities": [
          "cluster"
        ]
      }
    ],
    "labels": [
      {
        "key": "io.cilium.k8s.policy.derived-from",
        "value": "CiliumNetworkPolicy",
        "source": "k8s"
      },
      {
        "key": "io.cilium.k8s.policy.name",
        "value": "limit-inbound-ip-02",
        "source": "k8s"
      },
      {
        "key": "io.cilium.k8s.policy.namespace",
        "value": "network-policy-demo-cluster-management-5000174-production",
        "source": "k8s"
      },
      {
        "key": "io.cilium.k8s.policy.uid",
        "value": "a4b46ef8-57cb-43a6-8720-d7adc7342077",
        "source": "k8s"
      }
    ]
  },
  ...
]

How to test

https://gitlab.com/-/snippets/2070592

Does this MR meet the acceptance criteria?

Conformity

Availability and Testing

Security

If this MR contains changes to processing or storing of credentials or tokens, authorization and authentication methods and other items described in the security review guidelines:

  • Label as security and @ mention @gitlab-com/gl-security/appsec
  • The MR includes necessary changes to maintain consistency between UI, API, email, or other methods
  • Security reports checked/validated by a reviewer from the AppSec team

Related to #271169 (closed)

Edited by Alexander Turinske

Merge request reports