Skip to main content

Best practices for using HttpClient in c#

Introduction HttpClient is the library to Get, Post, Put,.. and call WebAPIs and it is very important to use it correctly. This Library has some methods to call web apis which all of them are Async. It is really important to use them in async method but if you are using an Async method in a console application that does not have separate UI thread you can use it like the following code : public void MySyncMethod() { using (HttpClient client = new HttpClient()) { client.BaseAddress = new Uri( "https://google.com" ); var response = client.GetAsync( "SomeAddress" ) .ConfigureAwait( false ).GetAwaiter().GetResult(); if ( response .IsSuccessStatusCode) { //Do Something... } } } Using ConfigureAwait(false) is very important for the applications which does not have separate UI thread Creating HttpClient for each request is not a good Idea and  Reuse  Httpclient as much as possible

Advanced Installation of Openshift Origin 3.6.0 on CentOS7

To install openshift origin 3.6.0

The first and for most is planning your architecture
In this installation I will try to install 1 master and 3 nodes. your master can use as a node so we will install 1 master and 3 node in just 3 machine.
do not forget to register an DNS. in this example I will use sample.com


1- Install and run 3 machine with CentOS 7.x
2- set the hostnames of 3 machine

# hostnamectl set-hostname master.sample.com
# hostnamectl set-hostname node1.sample.com
# hostnamectl set-hostname node1.sample.com

3- forward following domains to the machines

*.sample.com        => master
*.app.sample.com => master
node1.sample.com  => node1
node2.sample.com  => node2
 
4- generate ssh key in master and copy to all servers as you need to ssh to all machine without password by Ansible

# ssh-keygen -t dsa
# cat .ssh/id_dsa.pub
* copy the keys to all machin in .ssh/authorized_keys file 

6- install fallowing packages in all machines

# yum install wget git net-tools bind-utils iptables-services bridge-utils bash-completion kexec-tools sos psacct
# yum update
# yum install atomic

# yum -y install \
    https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
# sed -i -e "s/^enabled=1/enabled=0/" /etc/yum.repos.d/epel.repo
# yum -y --enablerepo=epel install ansible pyOpenSSL

7- Clone the openshift/openshift-ansible repository from GitHub, which provides the required playbooks and configuration files:(On Master)

# cd ~
# git clone https://github.com/openshift/openshift-ansible
# cd openshift-ansible
8- run the following steps


# atomic host upgrade
# yum install docker-1.12.6
# rpm -V docker-1.12.6
9-edit docker-storage and set DOCKER_STORAGE_OPTIONS= -s overlay2

# vi /etc/sysconfig/docker-storage

10- restart the docker like this:

# systemctl stop docker
# rm -rf /var/lib/docker/
# systemctl enable docker
# systemctl start docker

11- install ntp for time

# yum install ntp
# systemctl restart ntpd


12- finally you need to install java in master node

# yum install java-1.8.0-openjdk-headless

13- open a hosts file for ansible configuration

# vi /etc/ansible/origin_hosts

and put the following lines in this file:


#------------------
[OSEv3:children]
nodes
masters
etcd

[OSEv3:vars]
openshift_master_identity_providers=[{'name': 'htpasswd_auth', 'login': 'true', 'challenge': 'true', 'kind': 'HTPasswdPasswordIdentityProvider', 'filename': '/etc/origin/master/htpasswd'}]
openshift_master_cluster_public_hostname=occonsole.sample.com
openshift_master_default_subdomain=apps.sample.com
ansible_ssh_user=root
openshift_master_cluster_hostname=occonsole.sample.com
ansible_become=yes
deployment_type=origin
openshift_release=v3.6.0
openshift_image_tag=v3.6.0
openshift_disable_check=disk_availability,memory_availability,docker_storage
containerized=true
openshift_master_cluster_method=native
openshift_docker_use_system_container=True
openshift_clock_enabled=true
openshift_hosted_metrics_deploy=true
openshift_hosted_logging_deploy=true
openshift_master_overwrite_named_certificates=true

[nodes]
master.sample.com  openshift_schedulable=False
node1.sample.com  openshift_node_labels="{'region': 'infra'}" openshift_schedulable=True
node2.sample.com  openshift_node_labels="{'region': 'infra'}" openshift_schedulable=True

[masters]
master.sample.com  openshift_schedulable=false

[etcd]
master.sample.com  openshift_schedulable=false
#------------------

And Now you have to run install file by ansible:

# ansible-playbook -i /etc/ansible/origin_hosts openshift-ansible/playbooks/byo/config.yml -vvv

after about 20 minutes you will have your openshift :)

you can up your cluster manually

# oc cluster up --public-hostname=occonsole.ibeaconhub.com --routing-suffix=apps.ibeaconhub.com --host-data-dir ~/origin-etcd --metrics ibeaconhub.com --logging ibeaconhub.com --service-catalog


you can create user whith htpasswd

# htpasswd -b /etc/origin/master/htpasswd [user] [pass]

add all project access to your user

oc adm policy add-cluster-role-to-user cluster-admin user

Comments

  1. Thanks For Sharing, Here New Version Available;

    https://licensedinfo.com/advanced-installer-crack/

    ReplyDelete

Post a Comment

Popular posts from this blog

Best practices for using HttpClient in c#

Introduction HttpClient is the library to Get, Post, Put,.. and call WebAPIs and it is very important to use it correctly. This Library has some methods to call web apis which all of them are Async. It is really important to use them in async method but if you are using an Async method in a console application that does not have separate UI thread you can use it like the following code : public void MySyncMethod() { using (HttpClient client = new HttpClient()) { client.BaseAddress = new Uri( "https://google.com" ); var response = client.GetAsync( "SomeAddress" ) .ConfigureAwait( false ).GetAwaiter().GetResult(); if ( response .IsSuccessStatusCode) { //Do Something... } } } Using ConfigureAwait(false) is very important for the applications which does not have separate UI thread Creating HttpClient for each request is not a good Idea and  Reuse  Httpclient as much as possible

Advanced Installation of Openshift Origin 3.7 on CentOS7 with nfs storage

Installing Openshift origin 3.7 with NFS storage The first and for most is planning your architecture In this installation I will try to install 1 master and 3 nodes. your master can use as a node so we will install 1 master and 3 node (use master as a node). do not forget to register an DNS. in this example I will use sample.com 1- Install and run 3 machine with CentOS 7.x 2- set the hostnames of 3 machine # hostnamectl set-hostname master.sample.com # hostnamectl set-hostname node1.sample.com # hostnamectl set-hostname node1.sample.com 3- forward following domains to the machines *.sample.com        => master *.app.sample.com => master node1.sample.com  =>  node1 node2.sample.com  =>  node2 4- generate ssh key in master and copy to all servers as you need to ssh to all machine without password by Ansible # ssh-keygen -t dsa # cat .ssh/id_dsa.pub * copy the keys to all machin in  .ssh/authorized_keys  file  6- install fallowing packages in all