Uw toepassing koppelen
In dit artikel wordt ervan uitgegaan dat u een Persistent Volume (PV) en een Persistent Volume Claim (PVC) hebt gemaakt. Zie Een permanent volume maken voor meer informatie over het maken van een HW. Zie Een permanente volumeclaim maken voor meer informatie over het maken van een PVC.
Cachevolumes toevoegen aan uw aio-dp-runner-worker-0 pods
Deze pods maken deel uit van een statefulSet. U kunt de statefulSet niet bewerken om koppelpunten toe te voegen. Volg in plaats daarvan deze procedure:
Dump de statefulSet naar yaml:
kubectl get statefulset -o yaml -n azure-iot-operations aio-dp-runner-worker > stateful_worker.yaml
Bewerk de statefulSet om de nieuwe koppelingen voor Cachevolumes op te nemen in volumeMounts en volumes:
volumeMounts: - mountPath: /etc/bluefin/config name: config-volume readOnly: true - mountPath: /var/lib/bluefin/registry name: nfs-volume - mountPath: /var/lib/bluefin/local name: runner-local ### Add the next 2 lines ### - mountPath: /mnt/esa name: esa4 volumes: - configMap: defaultMode: 420 name: file-config name: config-volume - name: nfs-volume persistentVolumeClaim: claimName: nfs-provisioner ### Add the next 3 lines ### - name: esa4 persistentVolumeClaim: claimName: esa4
Verwijder de bestaande statefulSet:
kubectl delete statefulset -n azure-iot-operations aio-dp-runner-worker
Hiermee verwijdert u alle
aio-dp-runner-worker-n
pods. Dit is een gebeurtenis op storingsniveau.Maak een nieuwe statefulSet van aio-dp-runner-worker(s) met de cachevolumes:
kubectl apply -f stateful_worker.yaml -n azure-iot-operations
Wanneer de
aio-dp-runner-worker-n
pods worden gestart, worden deze gekoppeld aan cachevolumes. Het PVC moet dit in de staat overbrengen.Zodra u uw dataprocessormedewerkers opnieuw hebt geconfigureerd om toegang te krijgen tot de cachevolumes, moet u de pijplijnconfiguratie handmatig bijwerken om een lokaal pad te gebruiken dat overeenkomt met de gekoppelde locatie van uw cachevolume op de werkrol-POD's.
Als u de pijplijn wilt wijzigen, gebruikt u
kubectl edit pipeline <name of your pipeline>
. Vervang in die pijplijn de uitvoerfase door de volgende YAML:output: batch: path: .payload time: 60s description: An example file output stage displayName: Sample File output filePath: '{{{instanceId}}}/{{{pipelineId}}}/{{{partitionId}}}/{{{YYYY}}}/{{{MM}}}/{{{DD}}}/{{{HH}}}/{{{mm}}}/{{{fileNumber}}}' format: type: jsonStream rootDirectory: /mnt/esa type: output/file@v1
Een systeemeigen Kubernetes-toepassing configureren
Als u een algemene enkele pod (Kubernetes native toepassing) wilt configureren voor de persistente volumeclaim (PVC), maakt u een bestand met de naam
configPod.yaml
met de volgende inhoud:kind: Deployment apiVersion: apps/v1 metadata: name: example-static labels: app: example-static ### Uncomment the next line and add your namespace only if you are not using the default namespace (if you are using azure-iot-operations) as specified from Line 6 of your pvc.yaml. If you are not using the default namespace, all future kubectl commands require "-n YOUR_NAMESPACE" to be added to the end of your command. # namespace: YOUR_NAMESPACE spec: replicas: 1 selector: matchLabels: app: example-static template: metadata: labels: app: example-static spec: containers: - image: mcr.microsoft.com/cbl-mariner/base/core:2.0 name: mariner command: - sleep - infinity volumeMounts: ### This name must match the 'volumes.name' attribute in the next section. ### - name: blob ### This mountPath is where the PVC is attached to the pod's filesystem. ### mountPath: "/mnt/blob" volumes: ### User-defined 'name' that's used to link the volumeMounts. This name must match 'volumeMounts.name' as specified in the previous section. ### - name: blob persistentVolumeClaim: ### This claimName must refer to the PVC resource 'name' as defined in the PVC config. This name must match what your PVC resource was actually named. ### claimName: YOUR_CLAIM_NAME_FROM_YOUR_PVC
Notitie
Als u uw eigen naamruimte gebruikt, moeten
-n YOUR_NAMESPACE
alle toekomstigekubectl
opdrachten worden toegevoegd aan de opdracht. U moet bijvoorbeeld in plaats van de standaardkubectl get pods
gebruikenkubectl get pods -n YOUR_NAMESPACE
.Voer de volgende opdracht uit om dit YAML-bestand toe te passen:
kubectl apply -f "configPod.yaml"
Gebruik
kubectl get pods
dit om de naam van uw pod te vinden. Kopieer deze naam, omdat u deze nodig hebt voor de volgende stap.Voer de volgende opdracht uit en vervang deze door
POD_NAME_HERE
de gekopieerde waarde uit de vorige stap:kubectl exec -it POD_NAME_HERE -- bash
Wijzig mappen in het
/mnt/blob
koppelpad zoals opgegeven vanuit uwconfigPod.yaml
.Als u bijvoorbeeld een bestand wilt schrijven, voert u het uit
touch file.txt
.Navigeer in Azure Portal naar uw opslagaccount en zoek de container. Dit is dezelfde container die u hebt opgegeven in uw
pv.yaml
bestand. Wanneer u de container selecteert, wordtfile.txt
deze ingevuld in de container.
Volgende stappen
Nadat u deze stappen hebt voltooid, begint u met het bewaken van uw implementatie met behulp van Azure Monitor en Kubernetes Monitoring of bewaking van derden met Prometheus en Grafana: