K8s/Apache/Ingress: Difference between revisions
Jump to navigation
Jump to search
| (3 intermediate revisions by the same user not shown) | |||
| Line 1: | Line 1: | ||
==Namespace » Academia== | ==Namespace » Academia== | ||
{|class='wikitable mw-collapsible' | |||
!scope='col' colspan='2' style='width:1100px'| | |||
Namespace » Academia | |||
|- | |||
|valign='top' colspan='2'| | |||
<syntaxhighlight lang="bash"> | |||
cat << EXE | sudo bash | |||
ufw allow from 192.168.49.2/32 to any port 9000:9010 proto tcp | |||
ufw allow from 192.168.49.2/32 to any port 3000 proto tcp | |||
ufw status numbered | |||
EXE | |||
</syntaxhighlight> | |||
---- | |||
<syntaxhighlight lang="bash"> | |||
cat << EXE | sudo bash | |||
ufw delete allow from 192.168.49.2/32 to any port 9000:9010 proto tcp | |||
ufw delete allow from 192.168.49.2/32 to any port 3000 proto tcp | |||
ufw status numbered | |||
EXE | |||
</syntaxhighlight> | |||
|- | |||
|valign='top' style='width:544px'| | |||
<syntaxhighlight lang="bash"> | |||
export KUBECONFIG=${HOME}/.kube/shahed-ab-kubeconfig.yaml | |||
kubectl config get-contexts | |||
kubectl config view | |||
</syntaxhighlight> | |||
|valign='top'| | |||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
kubectl get ns|grep academia | kubectl get ns|grep academia | ||
| Line 5: | Line 34: | ||
kubectl create namespace academia | kubectl create namespace academia | ||
</syntaxhighlight> | </syntaxhighlight> | ||
|} | |||
==Namespace » Academia » Ingress » Academia== | ==Namespace » Academia » Ingress » Academia== | ||
{|class='wikitable mw-collapsible' | |||
!scope='col' style='width:1100px'| | |||
Namespace » Academia » Ingress » Academia | |||
|- | |||
|valign='top'| | |||
<syntaxhighlight lang="yaml"> | <syntaxhighlight lang="yaml"> | ||
cat <<'YML'| kubectl apply -n academia -f - | cat <<'YML'| kubectl apply -n academia -f - | ||
| Line 37: | Line 72: | ||
YML | YML | ||
</syntaxhighlight> | </syntaxhighlight> | ||
|} | |||
==Namespace » Academia » Service » Academia== | ==Namespace » Academia » Service » Academia== | ||
{|class='wikitable mw-collapsible mw-collapsed' | |||
!scope='col' style='width:1100px'| | |||
Namespace » Academia » Service » Academia | |||
|- | |||
|valign='top'| | |||
<syntaxhighlight lang="yaml"> | <syntaxhighlight lang="yaml"> | ||
cat <<'YML'|kubectl apply -n academia -f - | cat <<'YML'|kubectl apply -n academia -f - | ||
| Line 57: | Line 98: | ||
YML | YML | ||
</syntaxhighlight> | </syntaxhighlight> | ||
|} | |||
==Namespace » Academia » Service » Apache== | ==Namespace » Academia » Service » Apache== | ||
{|class='wikitable mw-collapsible mw-collapsed' | |||
!scope='col' style='width:1100px'| | |||
Namespace » Academia » Service » Apache | |||
|- | |||
|valign='top'| | |||
<syntaxhighlight lang="yaml"> | <syntaxhighlight lang="yaml"> | ||
cat <<'YML'| kubectl apply -n academia -f - | cat <<'YML'| kubectl apply -n academia -f - | ||
| Line 83: | Line 130: | ||
YML | YML | ||
</syntaxhighlight> | </syntaxhighlight> | ||
|} | |||
==Namespace » Academia » ConfigMap » Apache== | ==Namespace » Academia » ConfigMap » Apache== | ||
{|class='wikitable mw-collapsible mw-collapsed' | |||
!scope='col' style='width:1100px'| | |||
Namespace » Academia » ConfigMap » Apache | |||
|- | |||
|valign='top'| | |||
<syntaxhighlight lang="apache" line> | <syntaxhighlight lang="apache" line> | ||
cat <<'CFG'| kubectl -n academia create configmap apache --from-file=default.conf=/dev/stdin | cat <<'CFG'| kubectl -n academia create configmap apache --from-file=default.conf=/dev/stdin | ||
| Line 129: | Line 182: | ||
CFG | CFG | ||
</syntaxhighlight> | </syntaxhighlight> | ||
|} | |||
==Namespace » Academia » Deployment » Apache== | ==Namespace » Academia » Deployment » Apache== | ||
{|class='wikitable mw-collapsible' | |||
!scope='col' style='width:1100px'| | |||
Namespace » Academia » Deployment » Apache | |||
|- | |||
|valign='top'| | |||
<syntaxhighlight lang="yaml"> | <syntaxhighlight lang="yaml"> | ||
cat <<'YML'| kubectl apply -n academia -f - | cat <<'YML'| kubectl apply -n academia -f - | ||
| Line 182: | Line 241: | ||
YML | YML | ||
</syntaxhighlight> | </syntaxhighlight> | ||
|} | |||
==Namespace » Kube-System » ConfigMap » CoreDNS== | ==Namespace » Kube-System » ConfigMap » CoreDNS== | ||
{|class='wikitable mw-collapsible' | |||
!scope='col' style='width:1100px'| | |||
Namespace » Kube-System » ConfigMap » CoreDNS | |||
|- | |||
|valign='top'| | |||
[[K8s/Ingress#CoreDNS|Skipped » Find More » 👈]] | [[K8s/Ingress#CoreDNS|Skipped » Find More » 👈]] | ||
|} | |||
==Namespace » Academia » Clean-up == | ==Namespace » Academia » Clean-up == | ||
{|class='wikitable mw-collapsible mw-collapsed' | |||
!scope='col' style='width:1100px'| | |||
Namespace » Academia » Clean-up | |||
|- | |||
|valign='top'| | |||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
kubectl -n academia delete deploy apache | kubectl -n academia delete deploy apache | ||
| Line 196: | Line 267: | ||
kubectl delete namespace academia | kubectl delete namespace academia | ||
</syntaxhighlight> | </syntaxhighlight> | ||
|} | |||
==Namespace » Academia » Env.js == | ==Namespace » Academia » Env.js == | ||
{|class='wikitable mw-collapsible' | |||
!scope='col' style='width:1100px'| | |||
Namespace » Academia » Env.js | |||
|- | |||
|valign='top'| | |||
<syntaxhighlight lang="js"> | <syntaxhighlight lang="js"> | ||
let token = localStorage.getItem('user') != null ? JSON.parse(localStorage.getItem('user')).token : '' | let token = localStorage.getItem('user') != null ? JSON.parse(localStorage.getItem('user')).token : '' | ||
| Line 220: | Line 297: | ||
}; | }; | ||
</syntaxhighlight> | </syntaxhighlight> | ||
|} | |||
==References== | ==References== | ||
Latest revision as of 00:46, 12 July 2025
Namespace » Academia
|
Namespace » Academia | |
|---|---|
cat << EXE | sudo bash
ufw allow from 192.168.49.2/32 to any port 9000:9010 proto tcp
ufw allow from 192.168.49.2/32 to any port 3000 proto tcp
ufw status numbered
EXE
cat << EXE | sudo bash
ufw delete allow from 192.168.49.2/32 to any port 9000:9010 proto tcp
ufw delete allow from 192.168.49.2/32 to any port 3000 proto tcp
ufw status numbered
EXE
| |
export KUBECONFIG=${HOME}/.kube/shahed-ab-kubeconfig.yaml
kubectl config get-contexts
kubectl config view
|
kubectl get ns|grep academia
kubectl delete namespace academia
kubectl create namespace academia
|
Namespace » Academia » Ingress » Academia
|
Namespace » Academia » Ingress » Academia |
|---|
cat <<'YML'| kubectl apply -n academia -f -
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: academia
namespace: academia
labels:
app.kubernetes.io/version: 1.0.0
app.kubernetes.io/name: academia
app.kubernetes.io/instance: academia
app.kubernetes.io/managed-by: kubectl
annotations:
nginx.ingress.kubernetes.io/proxy-body-size: '0'
spec:
ingressClassName: nginx
rules:
- host: academia.chorke.org.local
http:
paths:
- path: /
pathType: ImplementationSpecific
backend:
service:
name: apache
port:
number: 80
YML
|
Namespace » Academia » Service » Academia
|
Namespace » Academia » Service » Academia |
|---|
cat <<'YML'|kubectl apply -n academia -f -
---
apiVersion: v1
kind: Service
metadata:
name: academia
namespace: academia
labels:
app.kubernetes.io/version: 1.0.0
app.kubernetes.io/name: academia
app.kubernetes.io/instance: academia
app.kubernetes.io/managed-by: kubectl
spec:
type: ExternalName
externalName: host.minikube.internal
YML
|
Namespace » Academia » Service » Apache
|
Namespace » Academia » Service » Apache |
|---|
cat <<'YML'| kubectl apply -n academia -f -
---
apiVersion: v1
kind: Service
metadata:
name: apache
namespace: academia
labels:
app.kubernetes.io/name: apache
app.kubernetes.io/version: 1.0.0
app.kubernetes.io/instance: academia
app.kubernetes.io/managed-by: kubectl
spec:
type: ClusterIP
ports:
- name: http-apache
targetPort: 80
protocol: TCP
port: 80
selector:
app: apache
YML
|
Namespace » Academia » ConfigMap » Apache
|
Namespace » Academia » ConfigMap » Apache |
|---|
cat <<'CFG'| kubectl -n academia create configmap apache --from-file=default.conf=/dev/stdin
<VirtualHost *:80>
ServerName academia.chorke.org.local
ServerAlias academia.chorke.org.local
ProxyVia On
ProxyPreserveHost On
RequestHeader set X-Forwarded-Proto "http"
RequestHeader set X-Forwarded-For expr=%{REMOTE_ADDR}
SetOutputFilter DEFLATE
DeflateCompressionLevel 3
AddOutputFilterByType DEFLATE text/css text/xml application/x-javascript application/atom+xml text/mathml text/plain text/vnd.sun.j2me.app-descriptor text/vnd.wap.wml text/x-component
KeepAliveTimeout 10
LimitRequestBody 26214400 # 25M
ExpiresActive On
ExpiresByType text/css "access plus 1 year"
ExpiresByType image/* "access plus 1 year"
ExpiresByType text/html "access plus 0 seconds"
ExpiresByType application/javascript "access plus 1 year"
ProxyPass /api/policy/rest/ http://academia:9002/
ProxyPassReverse /api/policy/rest/ http://academia:9002/
ProxyPass /api/quote/rest/ http://academia:9001/
ProxyPassReverse /api/quote/rest/ http://academia:9001/
ProxyPass /api/audit/rest/ http://academia:9003/
ProxyPassReverse /api/audit/rest/ http://academia:9003/
ProxyPass /api/rate/rest/ http://academia:9004/
ProxyPassReverse /api/rate/rest/ http://academia:9004/
ProxyPass /api/tds/rest/ http://academia:9000/
ProxyPassReverse /api/tds/rest/ http://academia:9000/
ProxyPass / http://academia:3000/
ProxyPassReverse / http://academia:3000/
</VirtualHost>
CFG
|
Namespace » Academia » Deployment » Apache
|
Namespace » Academia » Deployment » Apache |
|---|
cat <<'YML'| kubectl apply -n academia -f -
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: apache
namespace: academia
labels:
app: apache
app.kubernetes.io/name: apache
app.kubernetes.io/version: 1.0.0
app.kubernetes.io/instance: academia
app.kubernetes.io/managed-by: kubectl
spec:
replicas: 1
selector:
matchLabels:
app: apache
template:
metadata:
labels:
app: apache
spec:
containers:
- name: apache
image: httpd:2.4-alpine
ports:
- name: http-apache
containerPort: 80
protocol: TCP
resources:
requests:
cpu: 50m
memory: 64Mi
limits:
memory: 128Mi
cpu: 100m
volumeMounts:
- mountPath: /etc/apache/conf.d/default.conf
subPath: default.conf
name: default-conf
volumes:
- name: default-conf
configMap:
name: apache
items:
- key: default.conf
path: default.conf
YML
|
Namespace » Kube-System » ConfigMap » CoreDNS
|
Namespace » Kube-System » ConfigMap » CoreDNS |
|---|
Namespace » Academia » Clean-up
|
Namespace » Academia » Clean-up |
|---|
kubectl -n academia delete deploy apache
kubectl -n academia delete service apache
kubectl -n academia delete configmap apache
kubectl -n academia delete service academia
kubectl -n academia delete ingress academia
kubectl delete namespace academia
|
Namespace » Academia » Env.js
|
Namespace » Academia » Env.js |
|---|
let token = localStorage.getItem('user') != null ? JSON.parse(localStorage.getItem('user')).token : ''
const policyUrl = 'http://academia.chorke.org.local/api/policy/rest';
const auditUrl = 'http://academia.chorke.org.local/api/audit/rest';
const quoteUrl = 'http://academia.chorke.org.local/api/quote/rest';
const rateUrl = 'http://academia.chorke.org.local/api/rate/rest';
const url = 'http://academia.chorke.org.local/api/tds/rest';
const siteKey = '6LfAm6MpBBBBBNf1A6fxnsKeH6UQ8lrKw7LarDXa';
const isEnabledReCaptcha = false;
export const env = {
apiURL : url,
apiVersion : `${url}`,
quotationUrl : quoteUrl,
policyUrl : policyUrl,
productsUrl : rateUrl,
auditUrl,
token,
siteKey,
isEnabledReCaptcha
};
|