VMware/k8s

From DER's LLC
Jump to navigation Jump to search

General Kubernetes Documentation

Setup Artifactory Proxy to GCR

https://jfrog.com/knowledge-base/artifactory-how-to-proxy-a-google-container-registry-gcr/#:~:text=ARTIFACTORY%3A%20How%20to%20proxy%20a%20Google%20Container%20Registry%20(GCR)%3F,-Elina%20Floim&text=Google%20offers%20the%20https%3A%2F%2F,according%20to%20the%20needed%20endpoint.&text=Click%20on%20%E2%80%9CADD%20KEY%E2%80%9D%2C,file%20in%20an%20accessible%20location.

Setup GCR.IO Registry

1. Enable Google Container Registry

2. Setup Service Account via IAM Console. https://console.cloud.google.com/iam-admin/serviceaccounts
3. Create a Key for the Service Account (JSON) and download the JSON file.
4. Transfer the JSON file to the JUMPBOX.
5. Log into GCR via docker.

docker login -u _json_key --password-stdin https://gcr.io < keyfile.json

6. Push image to GCR.IO

docker pull gcr.io/kuar-demo/kuard-amd64:blue
docker tag gcr.io/kuar-demo/kuard-amd64:blue gcr.io/<GCR PROJECT>/kuard:latest
docker push gcr.io/<GCR PROJECT>/kuard:latest

7. Create docker Registry Secret

kubectl create secret docker-registry gcr-json-key \
--docker-server=gcr.io \
--docker-username=_json_key \
--docker-password="$(cat ~/keyfile.json)" \
--docker-email=<valid-email>

8. Set Default K8s Service Account to use the registry secret

kubectl patch serviceaccount default \
-p '{"imagePullSecrets": [{"name": "gcr-json-key"}]}'

9. Create the KUARD deployment YAML

cat <<EOF > kuard-deployment-gcr.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
  name: kuard-deployment
  labels:
    app: kuard
spec:
  replicas: 3
  selector:
    matchLabels:
      app: kuard
  template:
    metadata:
      labels:
        app: kuard
    spec:
      imagePullSecrets:
        - name: regcred
      containers:
        - image: gcr.io/<GCR PROJECT>/kuard:latest
          name: kuard
          ports:
            - containerPort: 8080
              name: http
---
apiVersion: v1
kind: Service
metadata:
  name: kuard-service
spec:
  type: LoadBalancer
  selector:
    app: kuard
  ports:
  - port: 80
    targetPort: 8080
EOF

10. Deploy the KUARD Deployment.

kubectl apply  -f kuard-deployment-gcr.yaml

11. Check that the containers are up and running.

kubectl get pods

12. Get the External Service IP that will be hosting KUARD.

kubectl get service kuard-service

13. Test that you can access the KUARD URL from a Web Browser

http://<EXTERNAL-IP>