How to Upload Images Into a Bitbucket Repository

kubernetes blogpost global Wavenet Prasada Jayasinghe - Global Wavenet

     Written by:'

Prasad Jayasinghe,

     Tech Lead,  Global Wavenet

 Prerequisites

· Bitbucket Account

· Container Repository Account (Nexus)

· Kubernetes Cluster

Commands

          #git add #git commit -m "Pocket-sized Clarification" #git push          CICD 2        

Select the Pipelines tab.

CICD 3

CICD 4

Then it volition let us to select some predefined build templates. But don't worry, your technology not there, still we tin write build script to build the image.

CICD 5

Here nosotros can write the custom build scripts.

CICD 6

I'm using Dockerfile to build the docker paradigm from the committed code, then the build image push button to Nexus repository. Then by using yaml file, I'k deploying the build epitome on  the Kubernetes cluster.

Dockerfile

          FROM openjdk:8-jdk-alpine ARG JAR_FILE=/target/*.jar COPY ${JAR_FILE} app.jar ENTRYPOINT ["java","-jar","/app.jar"]        

deployment.yml fiel

          apiVersion: v1 kind: Service metadata:   name: coursework-app spec:   selector:     app: coursework-app   ports:   - port: 8080     targetPort: 8080   type: LoadBalancer   --- apiVersion: apps/v1 kind: Deployment metadata:   proper noun: coursework-app spec:   selector:     matchLabels:       app: coursework-app   template:     metadata:       labels:         app: coursework-app     spec:       imagePullSecrets:         - proper name: <tag proper name>       containers:       - name: coursework-app         image: <image url Eg: username:image_name:tag>         ports:         - containerPort: 8080        

bitbucket-pipeline.yml

          paradigm: maven:3.6.3 pipelines:   default:     - step:         proper noun: Build and Push Wavenet Repository         script:           - mvn clean install           - docker login examination.domain.com --username $NEXUS_USERNAME --password $NEXUX_PASSWORD           - docker build -t <username:image_name:tag> .           - docker push <username:image_name:tag>         services:           - docker     - step:         name: Deploy to Kubernetes         deployment: production         script:           - pipe: atlassian/google-gke-kubectl-run:1.3.1             variables:               KEY_FILE: $KUBE_CONFIG               PROJECT: "wn-crs"               COMPUTE_ZONE: "us-central1-c"               CLUSTER_NAME: "cluster-1"               KUBECTL_COMMAND: "apply"               RESOURCE_PATH: "deployment.yml        

This bitbucket-deployment.yml file mainly consist of 2 principal sections:

1) Build

two) Deploy

Under this section, the lawmaking will get build and create the Docker image. And so prototype button to Nexus repository

          - mvn clean install          - docker login examination.domain.com — username $NEXUS_USERNAME — password $NEXUX_PASSWORD          - docker build -t <username:image_name:tag> .          - docker push <username:image_name:tag>        

Under this section by using the pushed image, the script will deploy on the Kubernetes cluster.

          - step: name: Deploy to Kubernetes deployment: production          script: - piping: atlassian/google-gke-kubectl-run:1.3.1          variables: KEY_FILE: $KUBE_CONFIG PROJECT: "wn-crs" COMPUTE_ZONE: "usa-central1-c" CLUSTER_NAME: "cluster-1" KUBECTL_COMMAND: "apply" RESOURCE_PATH: "deployment.yml        

Also in this build script, nosotros can use some variables to maintain the security eg : provide login details.

Select Repository Settings -> Nether pipelines section we can take the Repository variables.

CICD 7

Image for post

Surround Variable Details

NEXUS_USERNAME  and NEXUS_PASSWORS

These two variables are contained login credentials for nexus repository. This is fully directly forward and we tin user carve up account user proper name and countersign.

KUBE_CONFIG

This variable contains login credentials for Kubernetes Cluster.

Generate KUBE_CONGIG value

First, you need to create the  service account in Google Cloud

Login to google cloud console -> become to IAM and Admin section -> Select Service business relationship

CICD 8

Once you enter required details then it will ask you for Access permission.

There you can select "Kubernetes Engine Admin"

CICD 9

So click on done. Once it is done, we have to generate the key file.

To exercise that click on iii the dots under "Action" section

CICD 10

So select the JSON and click the create link.

CICD 11

And then it will download a fundamental file. To user this key file as KUBE_CONFIG variable we have convert information technology in to base64 format

Linux

          base64 -due west 0 < my_ssh_key        

Mac

          base64 < my_ssh_key        

Generated Key file

CICD 12

Now we tin can user this key in KUBE_CONFIG  variable.

Once every thing is done. And then we can run our build scripts.

Build Script is running

CICD 13

Bitbucket pipeline run without any issue

CICD 14

Build image pushed to Repository

CICD 15

Pod is created on Kubernetes cluster:

CICD 16

End.

  • ButbucketCreatinga nd managing service account keys |Cloud IAM DOcumentaion
  • Variables & sectret | Bitbucket Cloud | Atlassian Support

READ More

Select the tool to maximise Cloud strategy Cloud ahasa webinar

      

bardwellmosperwrongs.blogspot.com

Source: https://www.globalwavenet.com/2021/01/20/codeblog01/

0 Response to "How to Upload Images Into a Bitbucket Repository"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel