项目作者: esakat

项目描述 :
Support using Kubernetes with ECR
高级语言: Go
项目地址: git://github.com/esakat/trimg.git
创建时间: 2019-10-25T12:04:02Z
项目社区:https://github.com/esakat/trimg

开源协议:Apache License 2.0

下载


Trimg

Actions Status

Trimg is CLI to help using Kubernetes with AWS Elastic Container Registry.

Background

If you use kubernetes on AWS with off-line VPC, you should push images into ECR.
Also if you want to use existing manifest, e.g. kubernetes-dashboard, metric-server..,
you should replace manifest about image path.

trimg help you about it!

Installation

homebrew:

  1. brew install esakat/trimg/trimg

Usage

trimg support 2 feature

  1. transfer(pull images, create ecr repository, push into ecr)
  2. replace manifest about image path

transfer

you can get target image from manifest file

  1. $ trimg transfer -f testfiles/input/replicaset.yml --dry-run
  2. following images will be transfer
  3. gcr.io/google_samples/gb-frontend:v3 -> <YourAccountId>.dkr.ecr.<YourDefaultRegion>.amazonaws.com/gcr.io/google_samples/gb-frontend:v3
  4. $ trimg transfer -f testfiles/input/replicaset.yml
  5. [gcr.io/google_samples/gb-frontend:v3] [==============================================================================] 100 %
  6. 1: gcr.io/google_samples/gb-frontend:v3 transfer to <YourAccountId>.dkr.ecr.<YourDefaultRegion>.amazonaws.com/gcr.io/google_samples/gb-frontend:v3
  7. // ecr repository is created
  8. $ aws ecr list-images --repository-name gcr.io/google_samples/gb-frontend
  9. {
  10. "imageIds": [
  11. {
  12. "imageDigest": "sha256:60049e8aa1bb97242ce1a5fc5f9d86478d3f3407c2643edb054c717ac12c14bb",
  13. "imageTag": "v3"
  14. }
  15. ]
  16. }

also, you can specify by manual

  1. $ trimg transfer nginx:latest redis golang:1.13.5 --dry-run
  2. following images will be transfer
  3. nginx:latest -> <YourAccountId>.dkr.ecr.<YourDefaultRegion>.amazonaws.com/nginx:latest
  4. redis -> <YourAccountId>.dkr.ecr.<YourDefaultRegion>.amazonaws.com/redis
  5. golang:1.13.5 -> <YourAccountId>.dkr.ecr.<YourDefaultRegion>.amazonaws.com/golang:1.13.5

replace

  1. $ trimg replace testfiles/input/replicaset.yml > replacedManifest.yml
  2. $ cat testfiles/input/replicaset.yml | grep image:
  3. image: gcr.io/google_samples/gb-frontend:v3
  4. $ cat replacedManifest.yml | grep image:
  5. image: <YourAccountId>.dkr.ecr.<YourDefaultRegion>.amazonaws.com/gcr.io/google_samples/gb-frontend:v3

Use with Kubernetes

  1. $ trimg transfer -f testfiles/input/replicaset.yml
  2. $ trimg replace testfiles/input/replicaset.yml > replacedManifest.yml
  3. // kubernetes on EKS
  4. $ kubectl cluster-info | grep master
  5. Kubernetes master is running at https://......eks.amazonaws.com
  6. // deploy replaced manifes
  7. $ kubectl apply -f replacedManifest.yml
  8. replicaset.apps/frontend created
  9. // check
  10. $ kubectl get replicaset
  11. NAME DESIRED CURRENT READY AGE
  12. frontend 3 3 3 97s
  13. $ kubectl get replicaset frontend -ojson | jq .spec.template.spec.containers[0].image
  14. "<YourAccountId>.dkr.ecr.<YourDefaultRegion>.amazonaws.com/gcr.io/google_samples/gb-frontend:v3"