---
title: Kubernetes
description: Deployment, ClusterIP Service, सेटिंग्स के लिए Secret और Unico के registry के लिए pull secret के साथ Kubernetes पर Human Plugin चलाएँ।
canonical: https://developer.unico.io/hi/human-plugin/self-hosting/kubernetes
locale: hi
generated_by: markdown-export
---

# Kubernetes

ClusterIP Service के पीछे दो या अधिक replicas, जो केवल आपके back-end से पहुँच योग्य हैं।

## पूर्वापेक्षाएँ

- एक Kubernetes cluster और उस तक `kubectl` एक्सेस।
- Human Plugin के लिए समर्पित एक PostgreSQL डेटाबेस, जो cluster से पहुँच योग्य हो। [पूर्वापेक्षाएँ और एक्सेस](/hi/human-plugin/get-started/prerequisites) देखें।
- Unico से मिले registry credentials और access key।

नीचे का सब कुछ अपने अलग namespace में रखें:

```bash
kubectl create namespace human-plugin
```

## 1. Registry pull secret

```bash
kubectl -n human-plugin create secret docker-registry unico-registry \
  --docker-server=pkg.unico.run \
  --docker-username="<username>" \
  --docker-password="<token>"
```

## 2. सेटिंग्स Secret

```bash
kubectl -n human-plugin create secret generic human-plugin \
  --from-literal=HUMAN_API_ACCESS_KEY='<your access key>' \
  --from-literal=POSTGRES_ADDRESS_HOST='<database host>' \
  --from-literal=POSTGRES_USER='human_plugin' \
  --from-literal=POSTGRES_PASSWORD='<database password>'
```

`POSTGRES_ADDRESS_PORT`, `POSTGRES_DATABASE` या `POSTGRES_SSL_MODE` तभी जोड़ें जब आपका डेटाबेस [कॉन्फ़िगरेशन](/hi/human-plugin/self-hosting/configuration) के डिफ़ॉल्ट मानों से अलग हो। यदि आप secrets को किसी अन्य टूल (External Secrets, Sealed Secrets, एक vault) से प्रबंधित करते हैं, तो उसी से यही keys बनाएँ। मानों वाला Secret manifest कभी commit न करें।

## 3. Deployment और Service

```yaml title="human-plugin.yaml"
apiVersion: apps/v1
kind: Deployment
metadata:
  name: human-plugin
  namespace: human-plugin
spec:
  replicas: 2
  selector:
    matchLabels: { app: human-plugin }
  template:
    metadata:
      labels: { app: human-plugin }
    spec:
      terminationGracePeriodSeconds: 60
      imagePullSecrets:
        - name: unico-registry
      containers:
        - name: human-plugin
          image: pkg.unico.run/human-plugin-api:latest
          imagePullPolicy: Always
          ports:
            - { name: http, containerPort: 8080 }
          envFrom:
            - secretRef: { name: human-plugin }
          resources:
            requests: { cpu: "1", memory: 1Gi }
            limits: { cpu: "1", memory: 1Gi }
          readinessProbe:
            httpGet: { path: /health/ready, port: http }
            timeoutSeconds: 5
          livenessProbe:
            httpGet: { path: /health/live, port: http }
            periodSeconds: 30
---
apiVersion: v1
kind: Service
metadata:
  name: human-plugin
  namespace: human-plugin
spec:
  selector: { app: human-plugin }
  ports:
    - { name: http, port: 8080, targetPort: http }
```

```bash
kubectl apply -f human-plugin.yaml
```

```bash
kubectl -n human-plugin rollout status deployment/human-plugin
```

- **`replicas: 2`:** replicas डेटाबेस साझा करते हैं, इसलिए आप जितने चाहें उतने चला सकते हैं। दो replicas एक के रीस्टार्ट होने के दौरान भी Human Plugin को उपलब्ध रखते हैं।
- **`terminationGracePeriodSeconds: 60`:** रुकते समय Human Plugin चल रहे अनुरोधों के लिए 55 सेकंड तक प्रतीक्षा करता है। Kubernetes का डिफ़ॉल्ट, 30 सेकंड, किसी create को बीच में काट सकता है।
- **`imagePullPolicy: Always`:** `latest` tag के साथ, हर नया Pod सबसे हालिया release pull करता है।
- **Probes:** readiness किसी replica को तब तक ट्रैफ़िक से दूर रखता है जब तक उसका डेटाबेस उत्तर न दे, और `timeoutSeconds: 5` डेटाबेस के उत्तर देना बंद करने पर उसे विफल कर देता है। [हेल्थ और मॉनिटरिंग](/hi/human-plugin/self-hosting/health-and-monitoring) देखें।
- **Resources:** ऊपर के मान प्रत्येक replica के लिए न्यूनतम हैं। [हार्डवेयर आवश्यकताएँ](/hi/human-plugin/self-hosting/overview#hardware-requirements) देखें।

## 4. एक्सेस सीमित करें

आपका back-end Human Plugin तक `http://human-plugin.human-plugin.svc:8080` पर पहुँचता है। Human Plugin में अपना कोई authentication नहीं है, इसलिए:

- Service को Ingress, `LoadBalancer` या `NodePort` के ज़रिए expose न करें;
- NetworkPolicy से केवल अपने back-end के namespace को अनुमति दें।

```yaml title="network-policy.yaml"
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
  name: human-plugin-allow-backend
  namespace: human-plugin
spec:
  podSelector:
    matchLabels: { app: human-plugin }
  policyTypes: [Ingress]
  ingress:
    - from:
        - namespaceSelector:
            matchLabels: { kubernetes.io/metadata.name: <your back-end namespace> }
      ports:
        - { port: 8080 }
```

Human Plugin को स्वयं Unico तक outbound HTTPS और आपके डेटाबेस तक एक्सेस चाहिए। [नेटवर्किंग और सुरक्षा](/hi/human-plugin/self-hosting/networking-and-security) देखें।

## 5. सत्यापित करें

```bash
kubectl -n human-plugin port-forward svc/human-plugin 8080:8080
```

दूसरे terminal में, readiness जाँचें और `http://127.0.0.1:8080` के विरुद्ध [क्विकस्टार्ट](/hi/human-plugin/get-started/quickstart#3-create-a-process) का create अनुरोध चलाएँ:

```bash
curl --fail http://127.0.0.1:8080/health/ready
```

## लॉग

```bash
kubectl -n human-plugin logs deploy/human-plugin --since=10m
```

## अपडेट

```bash
kubectl -n human-plugin rollout restart deployment/human-plugin
```

नए Pods नवीनतम image pull करते हैं और तैयार होने पर पुराने Pods को एक-एक करके बदलते हैं। [ऑपरेशंस](/hi/human-plugin/self-hosting/operations) देखें।