K8s/Service: Difference between revisions
Jump to navigation
Jump to search
(→GitLab) |
|||
(7 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
==Redis== | |||
{| | |||
|colspan='3'| | |||
<syntaxhighlight lang="bash"> | |||
kubectl config get-contexts | |||
kubectl get ns | grep redis | |||
</syntaxhighlight> | |||
|- | |||
|colspan='3'| | |||
---- | |||
|- | |||
|valign='top'| | |||
<syntaxhighlight lang="yaml" highlight="9" line> | |||
cat << YML | kubectl -n redis apply -f - | |||
--- | |||
apiVersion: v1 | |||
kind: Service | |||
metadata: | |||
name: redis-lb | |||
namespace: redis | |||
labels: | |||
app.kubernetes.io/name: redis | |||
app.kubernetes.io/managed-by: kubectl | |||
annotations: | |||
meta.helm.sh/release-name: redis | |||
meta.helm.sh/release-namespace: redis | |||
spec: | |||
type: LoadBalancer | |||
ports: | |||
- port: 6379 | |||
name: redis | |||
protocol: TCP | |||
targetPort: redis | |||
selector: | |||
app.kubernetes.io/instance: redis | |||
app.kubernetes.io/name: redis | |||
YML | |||
</syntaxhighlight> | |||
|valign='top'| | |||
|valign='top'| | |||
|- | |||
|colspan='3'| | |||
---- | |||
|- | |||
|valign='top'| | |||
|valign='top'| | |||
|valign='top'| | |||
|} | |||
==GitLab== | ==GitLab== | ||
{| | {| | ||
Line 118: | Line 174: | ||
type: ExternalName | type: ExternalName | ||
externalName: host.minikube.internal | externalName: host.minikube.internal | ||
YML | |||
</syntaxhighlight> | |||
|valign='top'| | |||
|valign='top'| | |||
|- | |||
|colspan='3'| | |||
---- | |||
|- | |||
|valign='top'| | |||
|valign='top'| | |||
|valign='top'| | |||
|} | |||
==MariaDB== | |||
{| | |||
|colspan='3'| | |||
<syntaxhighlight lang="bash"> | |||
kubectl config get-contexts | |||
kubectl get ns|grep mariadb | |||
</syntaxhighlight> | |||
|- | |||
|colspan='3'| | |||
---- | |||
|- | |||
|valign='top'| | |||
<syntaxhighlight lang="yaml" highlight="9" line> | |||
cat << YML | kubectl -n mariadb apply -f - | |||
--- | |||
apiVersion: v1 | |||
kind: Service | |||
metadata: | |||
name: mariadb-lb | |||
namespace: mariadb | |||
labels: | |||
app.kubernetes.io/name: mariadb | |||
app.kubernetes.io/managed-by: kubectl | |||
annotations: | |||
meta.helm.sh/release-name: mariadb | |||
meta.helm.sh/release-namespace: mariadb | |||
spec: | |||
type: LoadBalancer | |||
ports: | |||
- port: 3306 | |||
name: mysql | |||
protocol: TCP | |||
targetPort: mysql | |||
selector: | |||
app.kubernetes.io/name: mariadb | |||
app.kubernetes.io/instance: mariadb | |||
YML | YML | ||
</syntaxhighlight> | </syntaxhighlight> | ||
Line 150: | Line 262: | ||
|- | |- | ||
|valign='top'| | |valign='top'| | ||
<syntaxhighlight lang="yaml"> | <syntaxhighlight lang="yaml" highlight="9" line> | ||
cat << YML | kubectl -n postgresql apply -f - | cat << YML | kubectl -n postgresql apply -f - | ||
--- | --- | ||
Line 173: | Line 285: | ||
selector: | selector: | ||
app.kubernetes.io/name: postgresql | app.kubernetes.io/name: postgresql | ||
app.kubernetes.io/instance: postgresql | app.kubernetes.io/instance: postgresql | ||
YML | YML | ||
Line 325: | Line 436: | ||
* [[Helm/GitLab External|Helm » GitLab » External]] | * [[Helm/GitLab External|Helm » GitLab » External]] | ||
* [[Helm/PostgreSQL|Helm » PostgreSQL]] | * [[Helm/PostgreSQL|Helm » PostgreSQL]] | ||
* [[Helm/MariaDB|Helm » MariaDB]] | |||
* [[Helm/GitLab|Helm » GitLab]] | * [[Helm/GitLab|Helm » GitLab]] | ||
* [[Helm/Redis|Helm » Redis]] | * [[Helm/Redis|Helm » Redis]] |
Latest revision as of 07:31, 11 September 2024
Redis
kubectl config get-contexts
kubectl get ns | grep redis
| ||
| ||
cat << YML | kubectl -n redis apply -f -
---
apiVersion: v1
kind: Service
metadata:
name: redis-lb
namespace: redis
labels:
app.kubernetes.io/name: redis
app.kubernetes.io/managed-by: kubectl
annotations:
meta.helm.sh/release-name: redis
meta.helm.sh/release-namespace: redis
spec:
type: LoadBalancer
ports:
- port: 6379
name: redis
protocol: TCP
targetPort: redis
selector:
app.kubernetes.io/instance: redis
app.kubernetes.io/name: redis
YML
|
||
| ||
GitLab
kubectl config get-contexts
kubectl get ns |grep gitlab
| ||
| ||
cat << YML | kubectl -n gitlab apply -f -
---
apiVersion: v1
kind: Service
metadata:
name: gitlab-lb
namespace: gitlab
labels:
app: gitlab
app.kubernetes.io/managed-by: kubectl
annotations:
meta.helm.sh/release-name: gitlab
meta.helm.sh/release-namespace: gitlab
spec:
type: LoadBalancer
ports:
- port: 22
name: ssh
protocol: TCP
targetPort: 22
selector:
app: gitlab
release: gitlab
YML
|
cat << YML | kubectl -n gitlab apply -f -
---
apiVersion: v1
kind: Service
metadata:
name: gitlab-lb
namespace: gitlab
labels:
app: gitlab-shell
app.kubernetes.io/managed-by: kubectl
annotations:
meta.helm.sh/release-name: gitlab
meta.helm.sh/release-namespace: gitlab
spec:
type: LoadBalancer
ports:
- port: 22
name: ssh
protocol: TCP
targetPort: 2222
selector:
app: gitlab-shell
release: gitlab
YML
|
|
| ||
External
kubectl config get-contexts
kubectl get ns|grep external
kubectl create namespace external
Internal
kubectl config get-contexts
kubectl get ns|grep internal
kubectl create namespace internal
| ||
| ||
cat << YML|kubectl apply -n internal -f -
---
apiVersion: v1
kind: Service
metadata:
name: minikube-host
namespace: internal
labels:
app.kubernetes.io/version: 1.0.0
app.kubernetes.io/managed-by: kubectl
app.kubernetes.io/name: minikube-host
app.kubernetes.io/instance: minikube-host
spec:
type: ExternalName
externalName: host.minikube.internal
YML
|
||
| ||
MariaDB
kubectl config get-contexts
kubectl get ns|grep mariadb
| ||
| ||
cat << YML | kubectl -n mariadb apply -f -
---
apiVersion: v1
kind: Service
metadata:
name: mariadb-lb
namespace: mariadb
labels:
app.kubernetes.io/name: mariadb
app.kubernetes.io/managed-by: kubectl
annotations:
meta.helm.sh/release-name: mariadb
meta.helm.sh/release-namespace: mariadb
spec:
type: LoadBalancer
ports:
- port: 3306
name: mysql
protocol: TCP
targetPort: mysql
selector:
app.kubernetes.io/name: mariadb
app.kubernetes.io/instance: mariadb
YML
|
||
| ||
PostgreSQL
kubectl config get-contexts
kubectl get ns|grep postgresql
| ||
| ||
cat << YML | kubectl -n postgresql apply -f -
---
apiVersion: v1
kind: Service
metadata:
name: postgresql-lb
namespace: postgresql
labels:
app.kubernetes.io/name: postgresql
app.kubernetes.io/managed-by: kubectl
annotations:
meta.helm.sh/release-name: postgresql
meta.helm.sh/release-namespace: postgresql
spec:
type: LoadBalancer
ports:
- port: 5432
protocol: TCP
name: tcp-postgresql
targetPort: tcp-postgresql
selector:
app.kubernetes.io/name: postgresql
app.kubernetes.io/instance: postgresql
YML
|
||
| ||
Ingress » Nginx
kubectl config get-contexts
kubectl get ns|grep ingress-nginx
| ||
| ||
cat << YML | kubectl apply -n ingress-nginx -f -
---
apiVersion: v1
kind: Service
metadata:
name: ingress-nginx
namespace: ingress-nginx
labels:
app.kubernetes.io/name: ingress-nginx
app.kubernetes.io/part-of: ingress-nginx
spec:
type: LoadBalancer
ports:
- name: http
port: 80
targetPort: 80
protocol: TCP
- name: https
port: 443
targetPort: 443
protocol: TCP
- name: proxied-tcp-5432
port: 5432
targetPort: 5432
protocol: TCP
- name: proxied-tcp-6379
port: 6379
targetPort: 6379
protocol: TCP
- name: proxied-udp-1194
port: 1194
targetPort: 1194
protocol: UDP
- name: proxied-udp-53
port: 53
targetPort: 53
protocol: UDP
selector:
app.kubernetes.io/name: ingress-nginx
app.kubernetes.io/part-of: ingress-nginx
YML
|
Playground
kubectl -n external get endpoints
kubectl -n external get service
kubectl -n external get ingress
|
kubectl -n internal get endpoints
kubectl -n internal get service
kubectl -n internal get ingress
|
kubectl config get-contexts
sudo -i -u minikube
helm list -A
|
| ||
kubectl get all -A
kubectl get ns
|
||
| ||
References
| ||
| ||