Skip to content
This repository has been archived by the owner on Aug 25, 2021. It is now read-only.

Enable Openshift for connect injector #972

Merged
merged 1 commit into from May 25, 2021
Merged

Conversation

ishustava
Copy link
Member

@ishustava ishustava commented May 25, 2021

Companion to hashicorp/consul-k8s#521 and hashicorp/consul-k8s#524
Changes proposed in this PR:

  • Pass -enable-openshift flag to connect injector when openshift is enabled globally

How I've tested this PR:
Deployed manually on openshift with the image built from hashicorp/consul-k8s#524 (ishustava/consul-k8s-dev:05-25-2021-0bc1f55)

First, I need to allow Envoy to run as the specific user and the init contianer to run with elevated privileges:

oc adm policy add-scc-to-user anyuid -z default
oc adm policy add-scc-to-user privileged -z default

This will allow any pod with the default service account to run as any user and have elevated privileges to run iptables.

Deployed static-server and static-client with:

---
apiVersion: v1
kind: Service
metadata:
  name: static-server
spec:
  type: LoadBalancer
  selector:
    app: static-server
  ports:
    - protocol: TCP
      port: 80
      targetPort: 8080
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: static-server
spec:
  replicas: 1
  selector:
    matchLabels:
      app: static-server
  template:
    metadata:
      name: static-server
      labels:
        app: static-server
      annotations:
        "consul.hashicorp.com/connect-inject": "true"
    spec:
      containers:
        - name: static-server
          image: docker.mirror.hashicorp.services/hashicorp/http-echo:latest
          args:
            - -text="hello world"
            - -listen=:8080
          ports:
            - containerPort: 8080
              name: http
      terminationGracePeriodSeconds: 0 # so deletion is quick
apiVersion: v1
kind: Service
metadata:
  name: static-client
spec:
  selector:
    app: static-client
  ports:
    - port: 80
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: static-client
spec:
  replicas: 1
  selector:
    matchLabels:
      app: static-client
  template:
    metadata:
      name: static-client
      labels:
        app: static-client
      annotations:
        "consul.hashicorp.com/connect-inject": "true"
    spec:
      containers:
        - name: static-client
          image: docker.mirror.hashicorp.services/curlimages/curl:latest
          command: [ "/bin/sh", "-c", "--" ]
          args: [ "while true; do sleep 30; done;" ]
$ kubectl exec deploy/static-client -- curl -s static-server
Defaulting container name to static-client.
Use 'kubectl describe pod/static-client-dc7497cb4-5dzkl -n consul' to see all of the containers in this pod.
"hello world"

How I expect reviewers to test this PR:

  • code review

Checklist:

  • Bats tests added
  • CHANGELOG entry added (HashiCorp engineers only, community PRs should not add a changelog entry)

@ishustava ishustava changed the title Enable Openshift for connect injector Enable Openshift for connect injector when tproxy is enabled May 25, 2021
@ishustava ishustava changed the title Enable Openshift for connect injector when tproxy is enabled Enable Openshift for connect injector May 25, 2021
@ishustava ishustava requested review from a team, ndhanushkodi and kschoche and removed request for a team May 25, 2021 19:53
Copy link
Contributor

@kschoche kschoche left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great!

@ishustava ishustava merged commit 44fbdea into master May 25, 2021
@ishustava ishustava deleted the enable-openshift-tproxy branch May 25, 2021 21:43
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants