最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

How to access Rancher Desktop Kubernetes files via Visual Studio Code? - Stack Overflow

programmeradmin2浏览0评论

I'm trying to access files from a Kubernetes cluster running on Rancher Desktop using Visual Studio Code. I’ve already set up a WordPress deployment with a PersistentVolumeClaim and need to modify files inside the WordPress container at /var/www/html. What is the best way to configure Visual Studio Code so I can access and work on the files of the local Kubernetes containers in Rancher Desktop?

I’ve tried setting up the Kubernetes extension for Visual Studio Code, but I haven’t been able to find a way to navigate the container files directly in VS Code. Is there a better way to do this, or do I need to use a tool like kubectl to export and manually edit the files?

Kubernetes Deployment Configuration:

apiVersion: v1
kind: Service
metadata:
  name: wordpress
  labels:
    app: wordpress
spec:
  ports:
    - port: 80
  selector:
    app: wordpress
    tier: frontend
  type: NodePort
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: wp-pv-claim
  labels:
    app: wordpress
spec:
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 20Gi
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: wordpress
  labels:
    app: wordpress
spec:
  selector:
    matchLabels:
      app: wordpress
      tier: frontend
  strategy:
    type: Recreate
  template:
    metadata:
      labels:
        app: wordpress
        tier: frontend
    spec:
      containers:
      - image: wordpress:6.2.1-apache
        name: wordpress
        env:
        - name: WORDPRESS_DB_HOST
          value: wordpress-mysql
        - name: WORDPRESS_DB_PASSWORD
          valueFrom:
            secretKeyRef:
              name: mysql-pass
              key: password
        - name: WORDPRESS_DB_USER
          value: wordpress
        ports:
        - containerPort: 80
          name: wordpress
        volumeMounts:
        - name: wordpress-persistent-storage
          mountPath: /var/www/html
      volumes:
      - name: wordpress-persistent-storage
        persistentVolumeClaim:
          claimName: wp-pv-claim

Command I tried:

PS C:\Users\alessio.malamov\desktop\k8s-rancher> kubectl get pods -n wordpress-unipol
NAME                             READY   STATUS    RESTARTS   AGE
wordpress-764497fd54-k2sqt       1/1     Running   0          20m
wordpress-mysql-f7d6744c-vslkz   1/1     Running   0          75m

PS C:\Users\alessio.malamov\desktop\k8s-rancher> kubectl cp wordpress-764497fd54-k2sqt:/var/www/html C:\Users\alessio.malamov\Desktop\k8s-rancher -n wordpress-unipol
error: one of src or dest must be a local file specification

PS C:\Users\alessio.malamov\desktop\k8s-rancher> kubectl cp wordpress-764497fd54-k2sqt:/var/www/html "C:\Users\alessio.malamov\Desktop\k8s-rancher" -n wordpress-unipol
error: one of src or dest must be a local file specification

PS C:\Users\alessio.malamov\desktop\k8s-rancher> kubectl cp wordpress-764497fd54-k2sqt:/var/www/html /c/Users/alessio.malamov/Desktop/k8s-rancher -n wordpress-unipol
tar: Removing leading `/' from member names
发布评论

评论列表(0)

  1. 暂无评论