· 4 years ago · Jul 28, 2021, 01:38 PM
1apiVersion: v1
2kind: ConfigMap
3metadata:
4 name: basicauth
5 namespace: __NAMESPACE_NAME__
6data:
7 htpasswd: |
8 # generate: $ htpasswd -c {file} username (then input password)
9 admin:$apr1$WNANncoH$APahBqGWgUbHwL6eCisFL0
10
11---
12apiVersion: v1
13kind: ConfigMap
14metadata:
15 name: nginx-configuration
16 namespace: __NAMESPACE_NAME__
17data:
18 nginx-configuration: |
19 server {
20 listen 80;
21 server_name localhost;
22
23 location / {
24 auth_basic "Administrator’s Area";
25 auth_basic_user_file /etc/service-nginx/htpasswd;
26
27 proxy_pass http://localhost:3000;
28 proxy_http_version 1.1;
29 expires off;
30 }
31 location /api/ {
32 auth_basic off;
33 proxy_pass http://localhost:3000;
34 proxy_http_version 1.1;
35 expires off;
36 }
37 }
38
39---
40apiVersion: extensions/v1beta1
41kind: Deployment
42metadata:
43 labels:
44 run: nginx
45 name: __CI_PROJECT_NAME__
46 namespace: __NAMESPACE_NAME__
47spec:
48 replicas: 1
49 selector:
50 matchLabels:
51 run: __CI_PROJECT_NAME__
52 app: __CI_PROJECT_NAME__
53 template:
54 metadata:
55 labels:
56 run: __CI_PROJECT_NAME__
57 app: __CI_PROJECT_NAME__
58 spec:
59 containers:
60 - name: __CI_PROJECT_NAME__
61 image: __REPOSITORY_IMAGE__
62 ports:
63 - containerPort: 3000
64
65 - name: nginx
66 image: nginx
67 ports:
68 - containerPort: 80
69 volumeMounts:
70 - name: config
71 mountPath: /etc/nginx/conf.d/
72 - name: htpasswd
73 mountPath: /etc/service-nginx/
74
75 volumes:
76 - name: config
77 configMap:
78 name: nginx-configuration
79 items:
80 - key: "nginx-configuration"
81 path: "default.conf"
82 - name: htpasswd
83 configMap:
84 name: basicauth
85 items:
86 - key: "htpasswd"
87 path: "htpasswd"
88 imagePullSecrets:
89 - name: gitlab-registry
90---
91
92kind: Service
93apiVersion: v1
94metadata:
95 name: __CI_PROJECT_NAME__-service
96 namespace: __NAMESPACE_NAME__
97spec:
98 selector:
99 app: __CI_PROJECT_NAME__
100 ports:
101 - protocol: TCP
102 port: 80
103 targetPort: 80
104
105---
106
107apiVersion: extensions/v1beta1
108kind: Ingress
109metadata:
110 name: __CI_PROJECT_NAME__-ingress
111 namespace: __NAMESPACE_NAME__
112 annotations:
113 nginx.ingress.kubernetes.io/rewrite-target: /
114 nginx.ingress.kubernetes.io/ssl-redirect: "false"
115 kubernetes.io/ingress.class: "nginx"
116 certmanager.k8s.io/cluster-issuer: letsencrypt-staging
117
118spec:
119 tls:
120 - hosts:
121 - onix-systems-test1.staging.onix.ua
122 secretName: onix-systems-test1.staging.onix.ua-certificate-1
123 rules:
124 - host: onix-systems-test1.staging.onix.ua
125 http:
126 paths:
127 - backend:
128 serviceName: __CI_PROJECT_NAME__-service
129 servicePort: 80
130