Skip to content

Instantly share code, notes, and snippets.

@Nurlan199206
Last active October 27, 2023 17:18
Show Gist options
  • Save Nurlan199206/acd4f43fbec7c2b9a915b967adc9fda5 to your computer and use it in GitHub Desktop.
Save Nurlan199206/acd4f43fbec7c2b9a915b967adc9fda5 to your computer and use it in GitHub Desktop.
OpenShift console for Kubernetes Vanilla
Prepartion:
1. 192.168.1.160 - nginx external
2. 192.168.1.164 - worker node, also as nginx ingress
k8s: v1.26.5
imperative method:
kubectl create deploy console --containerPort=9000 --image=quay.io/openshift/origin-console:4.13
kubectl expose deploy console --type=NodePort --port=9000 --target-port=9000 --node-port=30030 --dry-run=client -o yaml > console-svc.yaml
kubectl create ingress console --rule="console.test.kz/=console:9000" --dry-run=client -o yaml > ingress-console.yaml
kubectl create clusterrolebinding cr-admin --clusterrole=cluster-admin --serviceaccount=default:default
#=====================================================NGINX config ========================================================#
upstream console {
server 192.168.1.164:80;
}
server {
listen 80;
server_name console.diploma.kz;
access_log off;
error_log off;
location / {
proxy_pass http://console;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
error_page 403 =404 /url;
}
}
}
=======================================================deployment=========================================================
apiVersion: apps/v1
kind: Deployment
metadata:
creationTimestamp: null
labels:
app: console
name: console
spec:
replicas: 1
selector:
matchLabels:
app: console
strategy: {}
template:
metadata:
creationTimestamp: null
labels:
app: console
spec:
containers:
- image: quay.io/openshift/origin-console:4.13
name: origin-console
resources: {}
ports:
- containerPort: 9000
status: {}
=============================================================service=====================================================
apiVersion: v1
kind: Service
metadata:
creationTimestamp: null
labels:
app: console
name: console
spec:
ports:
- port: 9000
protocol: TCP
targetPort: 9000
nodePort: 30030
selector:
app: console
type: NodePort
status:
loadBalancer: {}
=============================================================ingress=====================================================
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
creationTimestamp: null
name: console
annotations:
kubernetes.io/ingress.class: nginx
spec:
rules:
- host: console.diploma.kz
http:
paths:
- backend:
service:
name: console
port:
number: 9000
path: /
pathType: Prefix
=================================================== HAProxy Kubernetes Ingress Controller =========================================
kind: Ingress
apiVersion: networking.k8s.io/v1
metadata:
name: console-haproxy
namespace: default
spec:
ingressClassName: haproxy
rules:
- host: console.test.kz
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: console
port:
number: 9000
- path: /api/graphql
pathType: Exact
backend:
service:
name: console
port:
number: 9000
status:
loadBalancer:
ingress:
- ip: 192.168.1.164
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment