2023년 3월 13일 월요일

[Docker] docker build RUN apk update Error

Step 3/7 : RUN apk update

 ---> Running in 2fdba320b542

fetch http://dl-cdn.alpinelinux.org/alpine/v3.9/main/x86_64/APKINDEX.tar.gz

fetch http://dl-cdn.alpinelinux.org/alpine/v3.9/community/x86_64/APKINDEX.tar.gz

ERROR: http://dl-cdn.alpinelinux.org/alpine/v3.9/main: temporary error (try again later)

WARNING: Ignoring APKINDEX.b89edf6e.tar.gz: No such file or directory

ERROR: http://dl-cdn.alpinelinux.org/alpine/v3.9/community: temporary error (try again later)

WARNING: Ignoring APKINDEX.737f7e01.tar.gz: No such file or directory



$ docker build --tag shlee/springboot-cicd:latest --no-cache --network=host .

 --> Add "--network=host" .. 

2023년 3월 10일 금요일

Nexus Installation on Ubuntu

$ mkdir nexus

$ wget https://download.sonatype.com/nexus/3/nexus-3.39.0-01-unix.tar.gz

$ sudo apt-get update

$ sudo apt install openjdk-8-jdk-headless

$ cd nexus/bin


- install & startup : nexus run

- startup : nexus start

- stop : nexus stop


SonarQube Installation ( on Ubuntu )

 $ sudo apt update




$ sudo apt -y install apt-transport-https ca-certificates curl gnupg-agent software-properties-common


$ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -






$ wget https://binaries.sonarsource.com/Distribution/sonarqube/sonarqube-9.8.0.63668.zip


$ unzip sonarqube-9.8.0.63668.zip


$ sudo groupadd sonar


$ sudo useradd -c "SonarQube - User" -d /home/shlee/sonarqube/ -g sonar sonar


# $ sudo chown -R sonar:sonar /home/shlee/sonarqube/


$ sudo chown -R shlee:shlee /home/shlee/sonarqube/




$ /home/shlee/sonarqube/bin/linux-x86-64/sonar.sh start


$ /home/shlee/sonarqube/bin/linux-x86-64/sonar.sh stop




$ curl localhost:9000 [admin/admin and change password]




[SonarQube Setup in gitlab / SonarQube]


1) create gitlab Impersonation Token in Gitlab


2) create gitlab project and insert gitlab Token in sonarqube 


3) create credential for "admin" account in sonarqube 


   and copy credential, paste to jenkins new credentials






[SonarQube Setup In jenkins]


Install GitLab plugin for Jenkins - version 1.5.13 or later


Install SonarQube Scanner plugin for Jenkins - version 2.11 or later




setting for integrating cicd


setting for sonarqube server 




[Jenkinsfile]


  withSonarQubeEnv('sonarqube_rookie01') {


                sh "mvn clean verify sonar:sonar -Dsonar.projectKey=springboot_springboot-cicd_AYUplgxydso4nsDrpk6X"


              }




sonarqube_rookie01 <- ID for sonarQube Server Setting


springboot_springboot-cicd_AYUplgxydso4nsDrpk6X <-- project key in sonarqube


-----




(1) Docker Push in Jenkinsfile


 docker.withRegistry('<Docker Registry URL>', '<Credential defined in Jenkins Credentials>') {


     dockerImage.push('<Tag>')


 }




ex>


 docker.withRegistry('http://localhost:7890/repository/docker-local-registry/', 'docker_credential') {


      dockerImage.push('latest')


 }




(2) Integrate Sonar with Jenkins


 withSonarQubeEnv('<Name of Jenkins SonarQube Server Settings>') {


      sh "mvn clean verify <Goal for SonarQube (default :  'sonar:sonar' )> -Dsonar.projectKey=<ProjectKey generated by SonarQube Server>"


 }

Prometheus & Grafana Installation (on Ubuntu)

 [Prometheus]


1) download prometheus

$ wget http://dl-cdn.alpinelinux.org/alpine/v3.9/main/x86_64/APKINDEX.tar.gz

압축 해제.. & prometheus.yml 편집

scrape_configs:

  # The job name is added as a label `job=<job_name>` to any timeseries scraped from this config.

  - job_name: "prometheus"


    # metrics_path defaults to '/metrics'

    # scheme defaults to 'http'.

    static_configs:

      - targets: ["localhost:9091"]

      - 

  - job_name: "springboot"

    scrape_interval: 15s

    metrics_path: "/actuator/prometheus"

    static_configs:

      - targets: ["rookie01.local:8080"]

      - 

2) startup

$ ./prometheus --config.file=prometheus.yml  --web.listen-address="0.0.0.0:9091" --web.enable-lifecycle 2>&1 | tee -a ./startup.log &



3) shutdown

$ curl -X POST localhost:9091/-/quit   ( or kill )


4) brower 접속

http://localhost:9091

http://localhost:9091/metrics



[Grafana]

1) download installation file

$ wget wget https://dl.grafana.com/enterprise/release/grafana-enterprise-9.3.6.linux-amd64.tar.gz


2) startup

$ ./bin/grafana-server web


3) browser 접속

http://localhost:3000  ( admin / admin ; pwd 변경 : lsh~)


4) springboot 용 pannel 샘플 다운로드 / Import

 download from : https://grafana.com/grafana/dashboards/12900-springboot-apm-dashboard/

2020년 3월 27일 금요일

Push Docker Image to GCR from WSL

shlee@DESKTOP-FEERFQV:~$ docker images
REPOSITORY                                       TAG                 IMAGE ID            CREATED             SIZE
asia.gcr.io/sunlit-theory-262204/config-server   latest              f9559cb4a95e        25 hours ago        135MB
test/configserver                                latest              f9559cb4a95e        25 hours ago        135MB
openjdk                                          8-jdk-alpine        a3562aa0b991        10 months ago       105MB
hello-world                                      latest              fce289e99eb9        15 months ago       1.84kB

shlee@DESKTOP-FEERFQV:~$ docker push asia.gcr.io/sunlit-theory-262204/config-server
WARNING: Could not open the configuration file: [/home/shlee/.config/gcloud/configurations/config_default].
ERROR: (gcloud.auth.docker-helper) You do not currently have an active account selected.
Please run:

  $ gcloud auth login

to obtain new credentials, or if you have already logged in with a
different account:

  $ gcloud config set account ACCOUNT

to select an already authenticated account to use.
The push refers to repository [asia.gcr.io/sunlit-theory-262204/config-server]
9bb9d4296990: Preparing
ceaf9e1ebef5: Preparing
9b9b7f3d56a0: Preparing
f1b5933fe4b5: Preparing
unauthorized: You don't have the needed permissions to perform this operation, and you may have invalid credentials. To authenticate your request, follow the steps in: https://cloud.google.com/container-registry/docs/advanced-authentication
shlee@DESKTOP-FEERFQV:~$ gcloud auth login
Go to the following link in your browser:

    https://accounts.google.com/o/oauth2/auth?code_challenge=VHaWsnL6HYckYTK5KVqT9h2IW8kjR8sGWUy4x_-IqTw&prompt=select_account&code_challenge_method=S256&access_type=offline&redirect_uri=urn%3Aietf%3Awg%3Aoauth%3A2.0%3Aoob&response_type=code&client_id=32555940559.apps.googleusercontent.com&scope=openid+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fuserinfo.email+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fcloud-platform+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fappengine.admin+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fcompute+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Faccounts.reauth


Enter verification code: <Hidden>

You are now logged in as [lshyuk@gmail.com].
Your current project is [None].  You can change this setting by running:
  $ gcloud config set project PROJECT_ID

shlee@DESKTOP-FEERFQV:~$ gcloud config set project sunlit-theory-262204
Updated property [core/project].


shlee@DESKTOP-FEERFQV:~$ docker push asia.gcr.io/sunlit-theory-262204/config-server
The push refers to repository [asia.gcr.io/sunlit-theory-262204/config-server]
9bb9d4296990: Pushed
ceaf9e1ebef5: Layer already exists
9b9b7f3d56a0: Layer already exists
f1b5933fe4b5: Layer already exists
latest: digest: sha256:5b309a37ba393e74461b10eb52c96b4dc670425b1ba546ffa27f618e607ef6d5 size: 1159




2020년 3월 22일 일요일

Install gcloud on WSL (Ubuntu)

1) Run WSL

2) Add the Cloud SDK distribution URI as a package source
$ echo "deb [signed-by=/usr/share/keyrings/cloud.google.gpg] http://packages.cloud.google.com/apt cloud-sdk main" | sudo tee -a /etc/apt/sources.list.d/google-cloud-sdk.list
3) Install apt-transport-https
$ sudo apt-get install apt-transport-https ca-certificates gnupg

4) Import the Google Cloud Platform public key
$ curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key --keyring /usr/share/keyrings/cloud.google.gpg add -

5) Update the package list and install the Cloud SDK
$ sudo apt-get update && sudo apt-get install google-cloud-sdk

6) Install Additional Component
$ sudo apt-get install google-cloud-sdk-app-engine-java

7) Start gcloud
$ gcloud init

2020년 3월 20일 금요일

docker-compose error (Unable to enable NAT rule)

$ docker-compose up -d
Creating network "chapter04_default" with the default driver
ERROR: Failed to Setup IP tables: Unable to enable NAT rule:  (iptables failed: iptables --wait -t nat -I POSTROUTING -s 172.21.0.0/16 ! -o br-8cbf06e4b2c9 -j MASQUERADE: iptables: No chain/target/match by that name.
 (exit status 1))

[Fix]
$ sudo vi /etc/docker/daemon.json
{
    "iptables":false
}

and then..

restart dockerd

2020년 3월 17일 화요일

Setting or change WSL root password

1. Open PowerShell Console
2. Comand
PS C:\Users\holyx> wsl -u root
root@LAPTOP-EEH80F78:/mnt/c/Users/holyx#
root@LAPTOP-EEH80F78:/mnt/c/Users/holyx# passwd
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully