Skip to content

Instantly share code, notes, and snippets.

@jseguillon
Created March 21, 2023 20:49
Show Gist options
  • Save jseguillon/9c6cb153ca7670aec4761cb70d74b6a8 to your computer and use it in GitHub Desktop.
Save jseguillon/9c6cb153ca7670aec4761cb70d74b6a8 to your computer and use it in GitHub Desktop.
Kubernetes bot log: add istio support

user > deploie nginx

expert > Très bien, voici votre yaml:

---
apiVersion: v1
kind: Namespace
metadata:
  name: nginx-namespace

---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: nginx-deployment
  namespace: nginx-namespace
spec:
  replicas: 3
  selector:
    matchLabels:
      app: nginx
  template:
    metadata:
      labels:
        app: nginx
    spec:
      containers:
      - image: nginx:latest
        name: nginx
        ports:
        - containerPort: 80

---
apiVersion: v1
kind: Service
metadata:
  name: nginx-service
  namespace: nginx-namespace
spec:
  ports:
  - name: http
    port: 80
    targetPort: 80
  selector:
    app: nginx

Voulez-vous que j'applique les changements ?

user > non. ajoute le support de istio sur le deploiement

expert > Très bien, voici votre yaml:

---
apiVersion: v1
kind: Namespace
metadata:
  name: nginx-namespace

---
apiVersion: v1
kind: Service
metadata:
  name: nginx-service
  namespace: nginx-namespace
spec:
  ports:
  - name: http
    port: 80
    targetPort: 80
  selector:
    app: nginx

---
apiVersion: apps/v1
kind: Deployment
metadata:
  annotations:
    sidecar.istio.io/inject: 'true'
  name: nginx-deployment
  namespace: nginx-namespace
spec:
  replicas: 3
  selector:
    matchLabels:
      app: nginx
  template:
    metadata:
      labels:
        app: nginx
    spec:
      containers:
      - image: nginx:latest
        name: nginx
        ports:
        - containerPort: 80

Voulez-vous que j'applique les changements ?

# user   > non. ajoute tous les CRDs Istio necessaire pour que le deploiement soit joignable de l'e
expert > Très bien, voici votre yaml:
---
apiVersion: v1
kind: Namespace
metadata:
  name: nginx-namespace

---
apiVersion: v1
kind: Service
metadata:
  name: nginx-service
  namespace: nginx-namespace
spec:
  ports:
  - name: http
    port: 80
    targetPort: 80
  selector:
    app: nginx

---
apiVersion: apps/v1
kind: Deployment
metadata:
  annotations:
    sidecar.istio.io/inject: 'true'
  name: nginx-deployment
  namespace: nginx-namespace
spec:
  replicas: 3
  selector:
    matchLabels:
      app: nginx
  template:
    metadata:
      labels:
        app: nginx
    spec:
      containers:
      - image: nginx:latest
        name: nginx
        ports:
        - containerPort: 80
---
apiVersion: networking.istio.io/v1alpha3
kind: Gateway
metadata:
  name: nginx-gateway
  namespace: nginx-namespace
spec:
  selector:
    istio: ingressgateway
  servers:
  - hosts:
    - '*'
    port:
      name: http
      number: 80
      protocol: HTTP
  type: LoadBalancer

---
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
  name: nginx-virtual-service
  namespace: nginx-namespace
spec:
  gateways:
  - nginx-gateway
  hosts:
  - '*'
  http:
  - match:
    - uri:
        prefix: /
    - uri:
        exact: /favicon.ico
    route:
    - destination:
        host: nginx-service
        port:
          number: 80

---
apiVersion: security.istio.io/v1beta1
kind: AuthorizationPolicy
metadata:
  name: nginx-auth-policy
  namespace: nginx-namespace
spec:
  action: ALLOW
  rules:
  - from:
    - source:
        notNamespaces:
        - nginx-namespace
  selector:
    matchLabels:
      app: nginx
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment