分類
發燒車訊

非洲豬瘟疫情防控 南韓今年確診11起

摘錄自2020年01月12日中央通訊社南韓報導

南韓環境部和國立環境科學院今天(12日)表示,自去年10月3日首次確診以來,截至10日共有66起確診感染非洲豬瘟(ASF)病毒,僅今年就有11起確診,疫情防控上仍有很大挑戰。

南韓聯合新聞通訊社報導,去年10月(18起)、11月(15起)、12月(22起)平均每天有0.5~0.7起確診,但今年以來每天發現1起以上感染死豬。江原道華川地區最近首次發現感染非洲豬瘟的野豬屍體。

之前僅在京畿道漣川(26起)、坡州(22起)、江原道鐵原(17起)發現感染非洲豬瘟的野豬屍體,此次擴散到華川。

報導說,政府9日召開會議檢討非洲豬瘟疫情應對情況。雖然確診疫情數在增加,但政府官員認為,這是防疫過程中的自然現象。不過由於家豬傳播非洲豬瘟病毒的可能性沒有完全消失,將繼續加強防疫監管。

本站聲明:網站內容來源環境資訊中心https://e-info.org.tw/,如有侵權,請聯繫我們,我們將及時處理

【其他文章推薦】

※為什麼 USB CONNECTOR 是電子產業重要的元件?

網頁設計一頭霧水該從何著手呢? 台北網頁設計公司幫您輕鬆架站!

※台北網頁設計公司全省服務真心推薦

※想知道最厲害的網頁設計公司"嚨底家"!

新北清潔公司,居家、辦公、裝潢細清專業服務

※推薦評價好的iphone維修中心

分類
發燒車訊

番茄感染病毒 法國出現首批確診案例

摘錄自2020年2月18日中央社報導

法國農業部今天(18日)表示,法國最西邊菲尼斯泰爾省(Finistere)的番茄植物已遭一種毀滅性病毒污染,這種病毒可能導致全部作物付之一炬。

法新社報導,法國農業部表示,已隔離一座農場,並將摧毀充滿番茄的多座溫室,目前沒有已知的治療方法。

這種病毒稱作「番茄褐色皺紋果病毒」(ToBRFV),可造成番茄出現粗糙變色斑塊,以致番茄賣不出去。官員先前警告,這種病毒的散播對農夫將有「重大經濟後果」。

這種病毒對人類無害。2014年於以色列的溫室中傳出首例,之後傳播至歐洲及美洲。

本站聲明:網站內容來源環境資訊中心https://e-info.org.tw/,如有侵權,請聯繫我們,我們將及時處理

【其他文章推薦】

USB CONNECTOR掌控什麼技術要點? 帶您認識其相關發展及效能

台北網頁設計公司這麼多該如何選擇?

※智慧手機時代的來臨,RWD網頁設計為架站首選

※評比南投搬家公司費用收費行情懶人包大公開

※幫你省時又省力,新北清潔一流服務好口碑

※回頭車貨運收費標準

分類
發燒車訊

貝斯女王島走出油污陰霾 褐鵜鶘庇護區揭牌

摘錄自2020年3月3日公視報導

美國路易斯安那州的貝斯女王島,是褐鵜鶘主要的棲地,過去因為遭到漏油事件重創,環境危害嚴重。不過在肇事的英國石油公司賠償下,將擴建庇護區。

路易斯安那州官員為重建的水鳥庇護區揭牌同時表示,過去人類對牠們棲地所造成的傷害長達10年,現在要還給牠們更乾淨、更安全的家。各界也希望今年夏天,貝斯女王島能跟往年一樣有約6500隻褐鵜鶘,以及約3000隻較小的水鳥遷徙到這裡築巢。

2010年墨西哥灣漏油事件,造成11人死亡,87天內超過1億加侖的原油洩漏。當時貝斯女王島72公里海岸線布滿油汙,褐鵜鶘全身浸泡在黑色汙泥的景象極為駭人,島上許多植物被遭毀,造成的生態浩劫引發全球擔憂。肇事的英國石油公司賠償200億美元,其中部分金額用來擴建養護1700公頃的海岸跟小島,今年還將投入8億美元持續重建工程。

本站聲明:網站內容來源環境資訊中心https://e-info.org.tw/,如有侵權,請聯繫我們,我們將及時處理

【其他文章推薦】

網頁設計一頭霧水該從何著手呢? 台北網頁設計公司幫您輕鬆架站!

網頁設計公司推薦不同的風格,搶佔消費者視覺第一線

※想知道購買電動車哪裡補助最多?台中電動車補助資訊懶人包彙整

南投搬家公司費用,距離,噸數怎麼算?達人教你簡易估價知識!

※教你寫出一流的銷售文案?

※超省錢租車方案

分類
發燒車訊

專家針對武漢肺炎警告 都市人長期處於空污下 恐增加感染死亡風險

環境資訊中心綜合外電;姜唯 編譯;林大利 審校

本站聲明:網站內容來源環境資訊中心https://e-info.org.tw/,如有侵權,請聯繫我們,我們將及時處理

【其他文章推薦】

網頁設計一頭霧水該從何著手呢? 台北網頁設計公司幫您輕鬆架站!

網頁設計公司推薦不同的風格,搶佔消費者視覺第一線

※Google地圖已可更新顯示潭子電動車充電站設置地點!!

※廣告預算用在刀口上,台北網頁設計公司幫您達到更多曝光效益

※別再煩惱如何寫文案,掌握八大原則!

網頁設計最專業,超強功能平台可客製化

分類
發燒車訊

Dell 將於 2040 年全面轉用再生能源

摘錄自2019年11月13日unwire HK報導

隨著更多的企業響應環保,作為知名的電腦公司 DELL 在近日亦宣佈了新的可持續發展計劃,指公司所有設施的 75% 電力將會使用可再生能源,直至 2040 年時將預計可獲 100% 的電力,並同時在計劃在過程中提高公司在生產及供應鏈上的能源效益,以達致低排放的目標為環保出一分力。

DELL 在早前宣佈公司將進行「Progress Made Real」的計劃,計劃內容主要包括在消費者購買的每一項設備時會回收同一污染水平的產品,以及在生產電力方面採用可再生能源。DELL 指出到 2030 年時公司一半以上的設備將會由回收材料或可再生物料而生產,在包裝上則會全面使用可重覆利用的物料。

不過 DELL 就並未透露公司是否會增加旗下所有裝置的使用壽命,但就指出對電子製造商而言,應對氣候變化的最佳方法是避免所有電子產品送往堆填區,而是重覆使用及物盡其用。

本站聲明:網站內容來源環境資訊中心https://e-info.org.tw/,如有侵權,請聯繫我們,我們將及時處理

【其他文章推薦】

網頁設計公司推薦不同的風格,搶佔消費者視覺第一線

※廣告預算用在刀口上,台北網頁設計公司幫您達到更多曝光效益

※自行創業缺乏曝光? 網頁設計幫您第一時間規劃公司的形象門面

南投搬家公司費用需注意的眉眉角角,別等搬了再說!

新北清潔公司,居家、辦公、裝潢細清專業服務

※教你寫出一流的銷售文案?

分類
發燒車訊

不敵客訴壓力 澳洲超市延後對塑膠袋收費

摘錄自2018年8月3日蘋果日報澳洲報導

澳洲一間大型連鎖超市原本要實施塑膠袋需收費政策,希望可推動「減塑」為環保出一分力,不料顧客對此大感不滿,政策推出後已經第2次延長收費期限。

連鎖超市科爾斯(Coles)自上月1日起停用一次性塑膠袋,改向顧客提供可重複使用、質料更耐用的塑膠袋作過渡,直至本周三(1日)為止。超市原定顧客此後若索取塑膠袋,每個須收取15澳分(約3.4元台幣)。

然而科爾斯周三發聲明指,自禁用一次性塑膠袋後,有顧客反映需要更多過渡時間,以適應使用可重複使用塑膠袋,集團因此決定在昆士蘭、新南威爾斯、維多利亞及西澳洲等地繼續提供免費塑膠袋至8月29日,而南澳洲、塔斯馬尼亞等地區則仍繼續收費。

本站聲明:網站內容來源環境資訊中心https://e-info.org.tw/,如有侵權,請聯繫我們,我們將及時處理

【其他文章推薦】

※自行創業缺乏曝光? 網頁設計幫您第一時間規劃公司的形象門面

網頁設計一頭霧水該從何著手呢? 台北網頁設計公司幫您輕鬆架站!

※想知道最厲害的網頁設計公司"嚨底家"!

※幫你省時又省力,新北清潔一流服務好口碑

※別再煩惱如何寫文案,掌握八大原則!

※產品缺大量曝光嗎?你需要的是一流包裝設計!

分類
發燒車訊

湄公河跨國水資源爭奪戰 寮國沙耶武里大壩爭議中即將啟用

環境資訊中心外電;姜唯 翻譯;林大利 審校;稿源:ENS

位於寮國北部湄公河的沙耶武里水壩將在數日內正式啟用。沙耶武里水壩是湄公河主流下游的第一座水壩,它的啟用象徵著湄公河命運的重要轉折點。

湄公河長4,350公里,是世界第12長河,排水量世界第八。發源於青藏高原,流經中國、緬甸、寮國和泰國,接著湧入柬埔寨和越南的沖積平原和三角洲。

沙耶武里水壩的主要目的是水力發電,其95%的發電量將由泰國電力局購買。

沙耶武里水壩打從一開始就是一個爭議性的工程,許多人擔心它對河流系統的作用,包括使湄公河的洄游魚類和沈積物難以往下游移動,可能連鄰國都會受影響。

大壩對環境的影響進而威脅流域內居民的糧食來源、生計和社會文化體系。

沙耶武里水壩即將完工。照片來源:

許多專家認為,湄公河上游中國境內已經建了六座水壩,寮國甚至柬埔寨下游還要再蓋,已經讓湄公河深陷危機。

沙耶武里水壩諮詢過程中,有許多利害關係者表示關切,質疑資料和研究是否充分。

越南政府呼籲暫停所有主流上水壩的建設10年,以進一步研究、更深入地了解河流系統和水壩的可能影響。

泰國湄公河沿岸的社區代表於2012年向泰國行政法院提起訴訟,質疑泰國向沙耶武里水壩購買電力的計畫。此訴訟案別具指標性,但經過數次上訴,七年後的今日仍懸而未決。

儘管如此,沙耶武里水壩的開發並沒有停止,開發商重新設計以減輕疑慮。

後續的大壩工程計畫也持續在進行。本月,湄公河委員會宣布開始對湄公河下游的第五座主流水壩瑯勃拉邦進行事前諮商。

在沙耶武里水壩啟用前,美國非營利組織國際河網(International Rivers)發布了關於水壩的新報告。該組織邀請兩位獨立專家針對湄公河委員會今年稍早發布的沙耶武里水壩設計變更審查報告發表評論。

兩位專家分別是澳洲雪梨大學人文地理學教授賀屈(Philip Hirsch)博士和英格蘭諾桑比亞大學社會科學副教授亨森格斯(Oliver Hensengerth)博士。他們檢視沙耶武里水壩如何成為主流水壩決策模式的基準,強調「迫切需要一個真正的區域性標準程序來保護湄公河的未來。」

國際河網的聲明指出,雖然國際河網自身的立場是認為大壩的開發正在「扼殺」湄公河,但該專家評論的目的並非批評或評估湄公河委員會的管理審查報告,而是在試圖「找出關鍵點,討論它們對沙耶武里水壩和其他規劃中或興建中水壩對湄公河下游主流以及該地區內的影響。」

沙耶武里水壩開發前的地景樣貌。照片來源: (CC BY 2.0)

23日,一場針對國際河網報告的座談會在泰國曼谷外國記者俱樂部舉行,與會學者、社區和民間社團熱烈討論沙耶武里水壩工程的歷史、決策過程缺陷、進行中的活動以及對生態系統與居民的影響。

國際河網認為,沙耶武里水壩興建過程「工程先行,研究後補」的做法很不負責任。(詳見)

湄公河沖積平原和三角洲是全世界農業產量極高、生物多樣性極豐富的水域之一,但是海平面上升、土地沉降、上游超過126個規劃中水壩以及各式各樣三角洲水利基礎設施讓人們不得不對水力發電的潛在問題感到憂心。

國際河網不是唯一一個對湄公河流域感到擔憂的環境組織。

丹麥DHI顧問集團針對湄公河三角洲進行的研究得出的結論是,「即使是現有最佳的魚道技術,也可能無法因應大量的魚類遷徙。在高峰時期,遷徙魚群最多可達每小時300萬條。此外,可能也難以滿足該流域數百種魚類有百百種遷移方式。」

根據22日在寮國首都永珍發布的最新報告《》,負責管理流域水壩開發的湄公河委員會也對此表示關注。

湄公河委員會成立於1995年,是一個政府間組織,直接與柬埔寨、寮國、泰國和越南政府合作,共同管理共享水資源和湄公河的永續發展。

該組織是水務外交的區域平台,也是維持該區域永續發展的水資源管理知識中心。

湄公河委員會報告警告:「主流水流體系明顯永久性改變,沉積物被阻攔造成泥沙流量大量減少,濕地持續喪失,河流生態環境惡化,捕撈漁業的壓力不斷增加以及目前水開發設施和用水資訊共享有限」,是湄公河流域國家面臨的主要挑戰。

「我們現在必須解決這些問題,盡可能減少對環境的損害,並在僅剩的濕地和河邊生態環境消失之前加以保護,同時利用更穩定且有所增加的旱季流量,實現湄公河地區最佳永續發展。」湄公河委員會執行長An Pich Hatda博士在啟用儀式上對來自四個湄公河國家、近100位官員說。

最新的流域狀況報告建議:「必須緊急採取更積極的區域性流域規劃和管理方法,並加強系統性地共享資訊,並嚴格監控河流流量,以因應這些流域挑戰。」

Dam Development Is ‘Silencing’ the Mekong River BANGKOK, Thailand, October 24, 2019 (ENS)

 In five days, the Xayaburi Hydropower Project on the Mekong River in northern Laos will formally begin operations. As the first dam on the lower Mekong mainstream, this marks a turning point for the Mekong River.

The Mekong River is 4,350 kilometers (2,703 miles) long, ranked 12th in length and eighth in water discharge in the world. The river originates in the Tibetan Plateau and flows through China, Myanmar, Laos, and Thailand before pouring into the alluvial floodplains and delta in Cambodia and Vietnam.

The main purpose of the Xayaburi dam is to produce hydroelectric power, 95 percent of which is to be purchased by the Electricity Generating Authority of Thailand.

From the outset, the Xayaburi dam was a controversial project due to widespread concerns over its expected impacts on the river system, including transboundary impacts in neighboring countries.

Major predicted impacts include the destruction of Mekong migratory fisheries and trapping of sediment, preventing it from traveling downstream.

The dam’s environmental impacts, in turn, threaten the food, livelihoods and socio-cultural systems of populations residing within the river basin.

Many experts believe that the Mekong, already suffering from the impacts of six dams installed in China on the Upper Mekong, and with more dams planned downstream in Laos and possibly Cambodia, is in crisis.

During the Xayaburi dam consultation process, many stakeholders raised concerns over the project and questioned the adequacy of the data and studies.

The Vietnamese government called for a project suspension and a 10-year moratorium on all mainstream dams pending further study to better understand the river system and the impacts of planned dams.

In Thailand, community representatives along the Mekong River filed a landmark lawsuit in the Thai Administrative Court challenging Thailand’s power purchase from the project. Originally filed in 2012, following several appeals, the lawsuit remains pending more than seven years later.

Despite this, the Xayaburi dam moved forward, with the developers undertaking a redesign in an effort to mitigate concerns.

Subsequent dam projects have followed. This month, the Mekong River Commission announced the commencement of Prior Consultation for Luang Prabang, the fifth lower Mekong mainstream dam to undergo the process.

In the lead-up to the commissioning of the Xayaburi dam, the U.S.-based nonprofit group International Rivers issued a new report on the dam. The group asked two independent experts to provide comments on the Mekong River Commission’s review of the Xayaburi redesign, released earlier this year.

The report of the experts, Dr. Philip Hirsch, professor of Human Geography at the University of Sydney, Australia; and Dr. Oliver Hensengerth, associate professor of social sciences at Northumbria University, England, examines the pattern of Xayaburi in setting a benchmark for decisions on mainstream dams and highlights “the urgent need for a truly regional approach to safeguard the Mekong’s future.”

Although International Rivers says dam development is “silencing” the Mekong River, this expert commentary is not intended as a critique or assessment of the MRC Review, said the group in a statement. “Rather, it seeks to draw out key points and discuss their implications for Xayaburi and other dams under construction or consideration on the lower Mekong mainstream and within the region.”

On Wednesday, a panel discussion of the International Rivers report with academic, community and civil society speakers at the Foreign Correspondents’ Club of Thailand in Bangkok provoked comments on the project’s history, its flawed decision-making process, the ongoing campaigns, and Xayaburi’s implications for the ecosystems and people of the Mekong Basin.

International Rivers has described the “build first, study later” approach propagated by the Xayaburi Dam process as “a dangerously irresponsible model for dam-building in the Mekong.”

To read the report, “Review of Design Changes Made for the Xayaburi Hydropower Project,” click .

The Mekong floodplains and delta are among the most agriculturally productive and biologically diverse waterscapes of the world, but sea level rise, land subsidence, and the proposed upstream development of over 126 hydropower dams and extensive delta-based water infrastructure have raised concerns about the potential impacts on the hydrology of the region.

International Rivers is not the only environmental group with concerns about the Mekong River Basin.

A Mekong Delta Study conducted by Denmark’s DHI Consulting Group concluded it was likely “that even the best available fish passage technologies’ may not be able to handle either the massive volume of fish migrations, which during peak periods can reach up to three million fish per hour, or the diversity of migration strategies that characterise the hundreds of fish species in the basin.”

The Mekong River Commission, which governs the dam development of the basin, is also concerned, according to the latest report, State of the Basin Report 2018, released on Tuesday in Vientiane, the Laotian capital city.

Established in 1995, the Mekong River Commission, MRC, is an inter-governmental organization that works directly with the governments of Cambodia, Laos, Thailand, and Vietnam to jointly manage the shared water resources and the sustainable development of the Mekong River.

The organization serves as a regional platform for water diplomacy as well as a knowledge hub of water resources management for the sustainable development of the region.

The MRC report warns, “The apparent permanent modification of mainstream flow regime, the substantial reduction in sediment flows due to sediment trapping, the continuing loss of wetlands, the deterioration of riverine habitats, the growing pressures on capture fisheries, and the limited information sharing on current water development facilities and water use,” are some of the major challenges facing countries in the Mekong Basin.

“We need to address these issues now in order to minimize further environmental harm and protect remaining wetlands and riverine habitats before they are gone, while leveraging the benefits of more secure and increased dry season flows and achieving a more optimal and sustainable development of the Mekong basin,” Dr. An Pich Hatda, chief executive officer of the MRC Secretariat, told nearly 100 officials from the four MRC countries at the launch ceremony.

This latest State of the Basin Report advises that “a more proactive regional approach to basin planning and management, with an enhanced and systematic information sharing mechanism and robust monitoring of river flow must be put in place urgently to address these basin-wide challenges.”

※ 全文及圖片詳見:

作者

如果有一件事是重要的,如果能為孩子實現一個願望,那就是人類與大自然和諧共存。

於特有生物研究保育中心服務,小鳥和棲地是主要的研究對象。是龜毛的讀者,認為龜毛是探索世界的美德。

延伸閱讀

本站聲明:網站內容來源環境資訊中心https://e-info.org.tw/,如有侵權,請聯繫我們,我們將及時處理

【其他文章推薦】

※廣告預算用在刀口上,台北網頁設計公司幫您達到更多曝光效益

新北清潔公司,居家、辦公、裝潢細清專業服務

※別再煩惱如何寫文案,掌握八大原則!

※教你寫出一流的銷售文案?

※超省錢租車方案

FB行銷專家,教你從零開始的技巧

分類
發燒車訊

遊客遽增破壞環境 紐西蘭國會報告示警

摘錄自2019年12月18日中央社威靈頓報導

紐西蘭國會今天(18日)提出報告警示,遽增的遊客數量正危害紐西蘭環境,也讓當地聞名遐邇、極具魅力的寧靜印象受到逐步破壞。

法新社報導,紐西蘭一向標榜「100%純淨」和「乾淨又環保」的形象,但近年來遊客數量遽增,許多人朝聖「魔戒」(The Lord of the Rings)電影拍攝地點大玩自拍,還有登山客、健行者及野生動物愛好人士。

紐西蘭國會環境事務專員厄普頓(Simon Upton)提出報告之際,紐國旅遊業正受到嚴格審查,因為白島(White Island)火山在9日爆發,造成16名外籍旅客和2名導遊喪命。

擁有490萬人口的紐西蘭每年吸引近400萬名外國遊客,厄普頓說,這項數據到了2050年可能增加2倍,厄普頓表示,基礎設施變得吃緊、環境承受壓力,紐西蘭原有的諸多品質正在消失,他說:「大批群眾正逐漸破壞許多外國遊客赴紐西蘭旅遊所尋覓的獨處感、寧靜和親近大自然的感覺,我們必須要問:我們是否正在殺雞取卵?」

厄普頓提到,紐西蘭人也是問題的一部分,在紐西蘭國定假期,著名景點湧現的國內遊客人潮比外國遊客還要多。

他還說,紐西蘭人已經習慣東加里羅步道(Tongariro Crossing)等著名景點「被遊客團團包圍」,而且問題只會持續惡化。

本站聲明:網站內容來源環境資訊中心https://e-info.org.tw/,如有侵權,請聯繫我們,我們將及時處理

【其他文章推薦】

新北清潔公司,居家、辦公、裝潢細清專業服務

※別再煩惱如何寫文案,掌握八大原則!

網頁設計一頭霧水該從何著手呢? 台北網頁設計公司幫您輕鬆架站!

※超省錢租車方案

※教你寫出一流的銷售文案?

網頁設計最專業,超強功能平台可客製化

分類
發燒車訊

南非減塑大功臣 寶特瓶廢棄塑膠製成磚

摘錄自2020年2月14日公視報導

在全球都出現塑膠垃圾問題時,南非開始用寶特瓶跟廢棄塑膠包裝,做成環保磚頭,來蓋托兒所等建築,成功減少塑膠垃圾。

根據2018年的「南非廢棄物狀況報告」指出,南非在2017年製造的4200萬噸廢物中,只有約11%被回收再利用。而2012年成立的南非當地民間團體「Waste-ED」,主要協助國家解決廢棄物品問題。除了教育學童相關觀念,還接受諮詢,引進這種塑膠瓶環保磚的製作,用來蓋學校或是簡易建築。

這種塑膠瓶環保磚,起源於菲律賓北部,後來應用在無法解決塑膠垃圾問題的發展中國家,協助當地政府廢物利用。目前開普敦郊區,已經有許多建築,包括托兒中心等建築牆壁,都是用這些環保磚製作。目前開普敦有超過2萬個、塑膠瓶環保磚的收集點,還跟學校合作,帶學童們一起參與製作跟使用環保磚。

本站聲明:網站內容來源環境資訊中心https://e-info.org.tw/,如有侵權,請聯繫我們,我們將及時處理

【其他文章推薦】

※教你寫出一流的銷售文案?

※廣告預算用在刀口上,台北網頁設計公司幫您達到更多曝光效益

※回頭車貨運收費標準

※別再煩惱如何寫文案,掌握八大原則!

※超省錢租車方案

※產品缺大量曝光嗎?你需要的是一流包裝設計!

分類
發燒車訊

007.OpenShift管理應用部署

一 REPLICATION CONTROLLERS

1.1 RC概述

RC確保pod指定數量的副本一直運行。如果pod被殺死或被管理員顯式刪除,複製控制器將自動部署相應的pod。類似地,如果運行的pod數量超過所需的數量,它會根據需要刪除pod,以匹配指定的副本計數。
RC的定義主要包括:

  • 所需的副本數量
  • 用於創建複製pod的pod定義
  • 用於標識後續管理操作的selector

selector是一組label,RC管理的所有pod都必須匹配這些標籤。RC實例化的pod定義中必須包含相同的標籤集。RC使用這個selector來確定已經運行了多少pod實例,以便根據需要進行調整。
提示:不執行自動縮放,因為它不跟蹤負載或流量。
儘管Kubernetes通常直接管理RC,但OpenShift推薦的方法是管理根據需要創建或更改RC的DC。

1.2 從DC創建RC

在OpenShift中創建應用程序的最常見方法是使用oc new-app命令或web控制台。以這種方式創建的應用程序使用DeploymentConfig資源在運行時創建RC來創建應用程序pod。DeploymentConfig資源定義定義了要創建的pod的副本的數量,以及要創建的pod的模板。
注意:不要將DeploymentConfig或ReplicationController資源中的template屬性誤認為OpenShift模板資源類型,OpenShift模板資源用於基於一些常用的語言運行時和框架構建應用程序。

1.3 pod副本數控制

DeploymentConfig或ReplicationController資源中的副本數量可以使用oc scale命令動態更改。
$ oc get dc
NAME REVISION DESIRED CURRENT TRIGGERED BY
myapp 1 3 3 config,image(scaling:latest)
$ oc scale –replicas=5 dc myapp
DeploymentConfig資源將更改信息傳遞至ReplicationController,該控制器通過創建新的pod(副本)或刪除現有的pod來響應更改。
雖然可以直接操作ReplicationController資源,但推薦的做法是操作DeploymentConfig資源。在觸發部署時,直接對ReplicationController資源所做的更改可能會丟失,例如,使用容器image的新版本重新創建pod。

1.4 自動伸縮pod

OpenShift可以通過HorizontalPodAutoscaler資源類型根據應用程序pod上的當前負載自動調整部署配置。
HorizontalPodAutoscaler (HPA)資源使用OpenShift metrics子系統收集的性能指標,即如果沒有度量子系統(模塊),更確切地說是Heapster組件,自動縮放是不可能的。
創建HorizontalPodAutoscaler資源的推薦方法是使用oc autoscale命令,例如:
$ oc autoscale dc/myapp –min 1 –max 10 –cpu-percent=80
該命令創建一個HorizontalPodAutoscaler資源,該資源更改myapp部署配置上的副本數量,以將其pod的CPU使用量控制在請求的總CPU使用量的80%以下。
oc autoscale命令使用DC的名稱作為參數(在前面的示例中是myapp)創建一個HorizontalPodAutoscaler資源。
HorizontalPodAutoscaler資源的最大值和最小值用於容納突發負載,並避免重載OpenShift集群。如果應用程序上的負載變化太快,建議保留一些備用的pod來處理突然出現的用戶請求。相反,過多的pod會耗盡所有集群容量,並影響共享相同OpenShift集群的其他應用程序。
要獲取當前項目中關於HorizontalPodAutoscaler資源的信息,可使用oc get和oc describe命令。例如
$ oc get hpa/frontend
$ oc describe hpa/frontend
注意:HorizontalPodAutoscaler資源只適用於為引用性能指標定義資源請求的pod。
oc new-app命令創建的大多數pod沒有定義任何資源請求。因此,使用OpenShift autoscaler可能需要為應用程序創建定製的YAML或JSON資源文件,或者向項目添加資源範圍資源。

二 擴展程序實驗

2.1 前置準備

準備完整的OpenShift集群,參考《003.OpenShift網絡》2.1。

2.2 創建應用

  1 [student@workstation ~]$ oc login -u developer -p redhat https://master.lab.example.com
  2 [student@workstation ~]$ oc new-project scaling
  3 [student@workstation ~]$ oc new-app -o yaml -i php:7.0 \
  4 http://registry.lab.example.com/scaling > ~/scaling.yml		#將部署的yaml導出至本地
  5 [student@workstation ~]$ vi ~/scaling.yml
  6 ……
  7   spec:
  8     replicas: 3
  9     selector:
 10       app: scaling
 11       deploymentconfig: scaling				#修改副本數
 12 ……
 13 [student@workstation ~]$ oc create -f ~/scaling.yml	#以修改副本數后的yaml部署應用

 

2.3 監視部署

  1 [student@workstation ~]$ watch -n 3 oc get builds
  2 Every 3.0s: oc get builds                                                                Mon Jul 22 11:12:02 2019
  3 
  4 NAME        TYPE      FROM          STATUS     STARTED              DURATION
  5 scaling-1   Source    Git@0bdae71   Complete   About a minute ago   1m0s
  6 [student@workstation ~]$ oc get pods
  7 NAME              READY     STATUS      RESTARTS   AGE
  8 scaling-1-build   0/1       Completed   0          2m
  9 scaling-1-ft249   1/1       Running     0          1m
 10 scaling-1-gjvkp   1/1       Running     0          1m
 11 scaling-1-mtrxr   1/1       Running     0          1m

 

2.4 暴露服務

  1 [student@workstation ~]$ oc expose service scaling \
  2 --hostname=scaling.apps.lab.example.com

 

2.5 web查看相關信息

瀏覽器訪問https://master.lab.example.com,使用developer用戶和redhat密碼登陸。選擇scaling項目。
 

2.6 測試負載均衡

  1 [student@workstation ~]$ for i in {1..5};do curl -s \http://scaling.apps.lab.example.com | grep IP;done	#多次請求
  2  <br/> Server IP: 10.128.0.17
  3  <br/> Server IP: 10.129.0.35
  4  <br/> Server IP: 10.129.0.36
  5  <br/> Server IP: 10.128.0.17
  6  <br/> Server IP: 10.129.0.35

 
提示:瀏覽器可能無法嚴格檢查均衡性,因為OpenShift route存在會話關聯性(也稱為粘性會話)。即來自同一個web瀏覽器的所有請求都將轉到同一個pod。

2.7 擴容應用

  1 [student@workstation ~]$ oc describe dc scaling | grep Replicas
  2 Replicas:       3
  3         Replicas:       3 current / 3 desired
  4 [student@workstation ~]$ oc scale --replicas=5 dc scaling

 

  1 [student@workstation ~]$ oc get pods -o wide

2.8 測試負載均衡

  1 [student@workstation ~]$ for i in {1..5};do curl -s \http://scaling.apps.lab.example.com | grep IP;done	#多次請求
  2  <br/> Server IP: 10.128.0.17
  3  <br/> Server IP: 10.128.0.18
  4  <br/> Server IP: 10.129.0.35
  5  <br/> Server IP: 10.129.0.36
  6  <br/> Server IP: 10.129.0.37

 

三 pod調度控制

3.1 pod調度算法

pod調度程序確定新pod在OpenShift集群中的節點上的位置。該調度算法被設計為可高度配置和適應不同集群。OCP 3.9附帶的默認配置通過使用node label、affinity rules,anti-affinity rules中的定義來支持zone和regions的調用。
在OCP以前的版本中,安裝程序master節點標記為污點標記,表示不允許在master上部署pod。在新版的OCP 3.9中,在安裝和升級過程中,master會自動標記為可調度的。使得可以通過deploy調度pod至maste節點。而不僅僅是作為master的組件運行。
默認節點selector是在安裝和升級期間默認設置的。它被設置為node-role.kubernetes.io/compute=true,除非使用osm_default_node_selector的Ansible變量覆蓋它。
在安裝和升級期間,不管osm_default_node_selector配置如何,都會對庫存文件中定義的主機執行以下自動標記。
compute節點配置non-master、non-dedicated的角色(默認情況下,具有region=infra標籤的節點),節點使用node-role.kubernetes.io/compute=true標記。
master節點被標記為node-role.kubernetes.io/master=true,從而分配master節點角色。

3.2 調度算法步驟

  • 過濾節點

調度程序根據節點資源(如主機端口)的可用性篩選正在運行的節點列表,然後進一步根據節點selector和來自pod的資源請求篩選。最終的縮小是可運行pod的候選node列表。
pod可以定義與集群節點中的標籤匹配的節點選擇器,標籤不匹配的節點視為不合格。
pod還可以為計算資源(如CPU、內存和存儲)定義資源請求,沒有足夠的空閑計算機資源的節點視為不合格。

  • 對過濾后的節點列表進行優先級排序

候選節點列表使用多個優先級標準進行評估,這些標準加起來就是權重,權重值較高的節點更適合運行pod。
其中有affinity(親和規則)和anti-affinity(反親和規則),pod親和力較高的節點得分較高,而anti-affinity較高的節點權重低。
affinity的一個常見用法是:出於性能原因,將相關的pod安排得彼此親和。例如,需要保持彼此同步的pod使用相同的網絡棧。
anti-affinity的一個常見用法是:為了獲得高可用性,將相關的pod安排的盡量分散。例如,避免將所有pod從同一個應用程序調度到同一個節點。

  • 選擇最合適的節點。

根據權重對候選列表進行排序,並選擇權重最高的節點來承載pod。如果多個節點得分相同,則隨機選擇一個節點。
調度程序配置文件位於/etc/original/master/scheduler.json,其定義了一組predicates,用作過濾器或優先級函數。通過這種方式,可以將調度程序配置為支持不同的集群。

3.3 調度拓撲

對於大型數據中心,例如雲提供商,一個常見的拓撲結構是將主機組織成regions和zones:
region:是一個地理區域內的一組主機,這保證了它們之間的內網高速連接;
zone:也稱為可用區,是一組主機,它們可能一起失敗,因為它們共享公共的關鍵基礎設施組件,比如網絡、存儲或電源。
OpenShift pod調度器可支持根據region和zone標籤在集群內調度,如:

    • 從相同的RC創建的或從相同的DC創建的pod副本調度至具有相同region標籤值的節點中運行。
    • 副本Pod調位至具有不同zone標籤的節點中運行。

實例圖如下:

要實現上圖中的樣例拓撲,可以使用集群管理員通過以下命令oc label:

  1 $ oc label node1 region=ZheJiang zone=Cloud1A --overwrite
  2 $ oc label node node2 region=ZheJiang zone=Cloud1A --overwrite
  3 $ oc label node node3 region=ZheJiang zone=Cloud2A --overwrite
  4 $ oc label node node4 region=ZheJiang zone=Cloud2A --overwrite
  5 $ oc label node node5 region=HuNan zone=Cloud1B --overwrite
  6 $ oc label node node6 region=HuNan zone=Cloud1B --overwrite
  7 $ oc label node node7 region=HuNan zone=Cloud2B --overwrite
  8 $ oc label node node8 region=HuNan zone=Cloud2B --overwrite

 
提示:每個節點必須由其完全限定名(FQDN)標識,為了簡潔,如上命令使用了簡短的名稱。
對區域標籤的更改需要–overwrite選項,因為OCP 3.9高級安裝方法默認情況下使用region=infra標籤配置節點。
示例:要檢查分配給節點的標籤,可以使用oc get node命令和–show-labels選項。
$ oc get node node1.lab.example.com –show-labels
注意,一個節點可能有一些OpenShift分配的默認標籤,包含kubernetes.io後綴鍵值的標籤,此類標籤不應由集群管理員人為更改,因為它們由調度程序在內部使用。
集群管理員還可以使用-L選項來確定單個標籤的值。
示例:

  1 $ oc get node node1.lab.example.com -L region
  2 $ oc get node node1.lab.example.com -L region -L zone	#支持oc get跟多個-L選項

 

3.4 UNSCHEDULABLE節點

有時候,集群管理員需要關閉節點進行維護,如節點可能需要硬件升級或內核安全更新。要在對OpenShift集群用戶影響最小的情況下關閉節點,管理員應該遵循兩個步驟。
將節點標記為不可調度,從而防止調度程序向節點分配新的pod。

  1 $ oc adm manage-node --schedulable=false node2.lab.example.com

Drain節點,這將銷毀在pod中運行的所有pod,並假設這些pod將通過DC在其他可用節點中會重新創建。

  1 $ oc adm drain node2.lab.example.com

維護操作完成后,使用oc adm management -node命令將節點標記為可調度的。

  1 $ oc adm manage-node --schedulable=true node2.lab.example.com

3.5 控制pod位置

有些應用程序可能需要在一組指定的node上運行。例如,某些節點為某些類型的工作負載提供硬件加速,或者集群管理員不希望將生產應用程序與開發應用程序混合使用。此類需求,都可以使用節點標籤和節點選擇器來實現。
node selector是pod定義的一部分,但建議更改dc,而不是pod級別的定義。要添加節點選擇器,可使用oc edit命令或oc patch命令更改pod定義。
示例:配置myapp的dc,使其pods只在擁有env=qa標籤的節點上運行。

  1 $ oc patch dc myapp --patch '{"spec":{"template":{"nodeSelector":{"env":"qa"}}}}'

此更改將觸發一個新的部署,並根據新的節點選擇器調度新的pod。
如果集群管理員不希望讓開發人員控制他們pod的節點選擇器,那麼應該在項目資源中配置一個默認的節點選擇器。

3.5 管理默認項目

生產環境一個常見實踐是指定一組節點來運行OCP的系統基礎Pod,比如route和內部倉庫。這些pod在默認項目中定義。
通常可通過以下兩個步驟實現:

  1. 使用region=infra標籤標記專用節點;
  2. 為缺省名稱空間配置缺省節點選擇器。

要配置項目的默認節點選擇器,可使用openshift.io/node-selector鍵值向名稱空間資源添加註釋。可以使用oc edit或oc annotate命令。

  1 $ oc annotate --overwrite namespace default \
  2 openshift.io/node-selector='region=infra'

 
OCP 3.9 quick installer和advanced installer的Ansible playbook都支持Ansible變量,這些變量控制安裝過程中分配給節點的標籤,也控制分配給每個基礎設施pod的節點選擇器。
安裝OCP子系統(如metrics子系統)的劇本還支持這些子系統節點選擇器的變量。

四 控制Pod調度

4.1 前置準備

準備完整的OpenShift集群,參考《003.OpenShift網絡》2.1。

4.2 本練習準備

  1 [student@workstation ~]$ lab schedule-control setup
  2 [student@workstation ~]$ oc login -u admin -p redhat https://master.lab.example.com

 

4.3 查看region

  1 [student@workstation ~]$ oc get nodes -L region
  2 NAME                     STATUS    ROLES     AGE       VERSION             REGION
  3 master.lab.example.com   Ready     master    2d        v1.9.1+a0ce1bc657
  4 node1.lab.example.com    Ready     compute   2d        v1.9.1+a0ce1bc657   infra
  5 node2.lab.example.com    Ready     compute   2d        v1.9.1+a0ce1bc657   infra

 

4.4 創建project

  1 [student@workstation ~]$ oc new-project schedule-control

4.5 創建應用

  1 [student@workstation ~]$ oc new-app --name=hello \
  2 --docker-image=registry.lab.example.com/openshift/hello-openshift

 

4.6 擴展應用

  1 [student@workstation ~]$ oc scale dc hello --replicas=5
  2 deploymentconfig "hello" scaled
  3 [student@workstation ~]$ oc get pod -o wide
  4 NAME            READY     STATUS    RESTARTS   AGE       IP            NODE
  5 hello-1-c5z2n   1/1       Running   0          7s        10.128.0.21   node1.lab.example.com
  6 hello-1-hhvp7   1/1       Running   0          34s       10.129.0.38   node2.lab.example.com
  7 hello-1-jqrkb   1/1       Running   0          7s        10.128.0.20   node1.lab.example.com
  8 hello-1-tgmbr   1/1       Running   0          7s        10.129.0.39   node2.lab.example.com
  9 hello-1-z2bn7   1/1       Running   0          7s        10.128.0.22   node1.lab.example.com

 

4.7 修改節點label

  1 [student@workstation ~]$ oc label node node2.lab.example.com region=apps --overwrite=true
  2 [student@workstation ~]$ oc get nodes -L region		#確認修改
  3 NAME                     STATUS    ROLES     AGE       VERSION             REGION
  4 master.lab.example.com   Ready     master    2d        v1.9.1+a0ce1bc657
  5 node1.lab.example.com    Ready     compute   2d        v1.9.1+a0ce1bc657   infra
  6 node2.lab.example.com    Ready     compute   2d        v1.9.1+a0ce1bc657   apps

 

4.8 導出dc

  1 [student@workstation ~]$ oc get dc hello -o yaml > dc.yaml

4.9 修改node2調度策略

添加dc.yaml中的調度策略,使pod調度至apps標籤的node。

  1 [student@workstation ~]$ vi dc.yaml
  2 ……
  3   template:
  4 ……
  5     spec:
  6       nodeSelector:		#添加節點選擇器
  7         region: apps
  8 ……

 

4.10 應用更新

  1 [student@workstation ~]$ oc apply -f dc.yaml

4.11 確認驗證

  1 [student@workstation ~]$ oc get pod -o wide
  2 NAME            READY     STATUS    RESTARTS   AGE       IP            NODE
  3 hello-2-4c2gv   1/1       Running   0          40s       10.129.0.42   node2.lab.example.com
  4 hello-2-6966b   1/1       Running   0          38s       10.129.0.43   node2.lab.example.com
  5 hello-2-dcqbr   1/1       Running   0          36s       10.129.0.44   node2.lab.example.com
  6 hello-2-dlf8k   1/1       Running   0          36s       10.129.0.45   node2.lab.example.com
  7 hello-2-rnk4w   1/1       Running   0          40s       10.129.0.41   node2.lab.example.com

 
#驗證是否觸發了新的部署,並等待所有新的應用pod都準備好並運行。所有5個pod都應該調度至node2。

4.12 修改node1調度策略

  1 [student@workstation ~]$ oc label node node1.lab.example.com region=apps --overwrite=true
  2 [student@workstation ~]$ oc get node -L region
  3 NAME                     STATUS    ROLES     AGE       VERSION             REGION
  4 master.lab.example.com   Ready     master    2d        v1.9.1+a0ce1bc657
  5 node1.lab.example.com    Ready     compute   2d        v1.9.1+a0ce1bc657   apps
  6 node2.lab.example.com    Ready     compute   2d        v1.9.1+a0ce1bc657   apps

 

4.13 終止node2

  1 [student@workstation ~]$ oc adm manage-node --schedulable=false node2.lab.example.com
  2 NAME                    STATUS                     ROLES     AGE       VERSION
  3 node2.lab.example.com   Ready,SchedulingDisabled   compute   2d        v1.9.1+a0ce1bc657

 

4.14 刪除pod

刪除node2的pod,並使用node1創建的pod替換。

  1 [student@workstation ~]$ oc adm drain node2.lab.example.com --delete-local-data

4.15 查看pod

  1 [student@workstation ~]$ oc get pods -o wide
  2 NAME            READY     STATUS    RESTARTS   AGE       IP            NODE
  3 hello-2-bjsj4   1/1       Running   0          51s       10.128.0.25   node1.lab.example.com
  4 hello-2-kmmmn   1/1       Running   0          50s       10.128.0.23   node1.lab.example.com
  5 hello-2-n6wvj   1/1       Running   0          51s       10.128.0.24   node1.lab.example.com
  6 hello-2-plr65   1/1       Running   0          50s       10.128.0.26   node1.lab.example.com
  7 hello-2-xsz68   1/1       Running   0          51s       10.128.0.27   node1.lab.example.com

 

五 管理IS、image、Templates

5.1 image介紹

在OpenShift中,image是一個可部署的runtime模板,它包含運行單個容器的所有需求,還包括imag功能的元數據。image可以通過多種方式管理,如tag、import、pull和update。
image可以跨多個主機部署在多個容器中。開發人員可以使用Docker構建image,也可以使用OpenShift構建工具。
OpenShift實現了靈活的image管理機制。一個image名稱實際上可以引用同一image的許多不同版本。唯一的image由它的sha256哈希引用,Docker不使用版本號。相反,它使用tag來管理image,例如v1、v2或默認的latest tag。

5.2 IS

IS包括由tags標識的任意數量的容器images。它是相關image的統一虛擬視圖,類似於Docker image倉庫。開發人員有許多與image和IS交互的方法。例如,當添加或修改新image時,build和deployment可以接收通知,並通過運行新build或新deployment做出相應的動作。

5.3 標記image

OCP提供了oc tag命令,它類似於docker tag命令,但是,它是對IS而不是image進行操作。
可以向image添加tag,以便更容易地確定它們包含什麼。tag是指定image版本的標識符。
示例:將Apache web服務器2.4版本的映像,可將該image執行以下標記。
apache: 2.4
如果倉庫包含Apache web服務器的最新版本,他們可以使用latest標籤來表示這是倉庫中可用的最新image。
apache:latest
oc tag命令用於標籤image:
[user@demo ~]$ oc tag source destination
source:現有tag或圖像流中的圖像。
destination:標籤在一個或多個IS中的最新image。
示例:將ruby image的現有latest標記修改為當前版本v2.0標識,
[user@demo ~]$ oc tag ruby:latest ruby:2.0

5.4 刪除tag

若要從image中刪除標記,可使用-d參數。
[user@demo ~]$ oc tag -d ruby:latest
可以使用不同類型的標籤,默認行為使用permanent tag,即源文件發生更改,該tag也會及時指向image,與目標tag無關。
tracking tag指示在導入image期間導入目標tag的元數據。要確保目標tag在源tag更改時得到更新,需使用–alias=true標識。
[user@demo ~]$ oc tag –alias=true source destination
要重新導入tag,可使用–scheduled=true標識。
[user@demo ~]$ oc tag –scheduled=true source destination
要配置Docker始終從內部倉庫中獲取image,可使用–reference-policy=local標誌。默認情況下,image指向本地倉庫。從而實現在之後調用image的時候可以快速pull。
[user@demo ~]$ oc tag –reference-policy=local source destination

5.5 建議的tag形式

在管理tag時,開發人員應該考慮映像的生命周期,參考下錶開發人員用來管理映像的可能的標記命名約定。

描述 示例
Revision myimage:v2.0.1
Architecture myimage:v2.0-x86_64
Base Image myimage:v1.2-rhel7
Latest Image myimage:latest
Latest Stable Image myimage:stable

5.6 Templates介紹

模板描述一組對象,其中包含處理後生成對象列表的參數。可以處理模板來創建開發人員有權在項目中創建的任何內容,例如service、build、configuration和dc。
模板還可以定義一組標籤,應用於它定義的每個對象。開發人員可以使用命令行界面或web控制台從模板創建對象列表。

5.7 Templates管理

開發人員可以用JSON或YAML格式編寫模板,並使用命令行界面或web控制台導入它們。模板被保存到項目中,以供對該特定項目具有適當訪問權限的任何用戶重複使用。
示例:導入模板。
[user@demo ~]$ oc create -f filename
還可以在導入模板時分配標籤,這意味着模板定義的所有對象都將被標記。
[user@demo ~]$ oc create -f filename -l name=mylabel

5.8 使用模板

OCP提供了許多默認的instant app和QuickStart模板,允許開發人員為不同的語言快速創建新的應用程序。為Rails (Ruby)、Django (Python)、Node.js、CakePHP (PHP)和Dancer (Perl)提供了模板。
要列出集群中的可用模板,請運行oc get templates命令。參數-n指定要使用的項目。
[user@demo ~]$ oc get templates -n openshift
開發人員還可以使用web控制台瀏覽模板,當您選擇模板時,可以調整可用的參數來自定義模板定義的資源。

六 管理IS

6.1 前置準備

準備完整的OpenShift集群,參考《003.OpenShift網絡》2.1。

6.2 本練習準備

  1 [student@workstation ~]$ lab schedule-is setup

6.3 創建項目

  1 [student@workstation ~]$ oc login -u developer -p redhat \
  2 https://master.lab.example.com
  3 [student@workstation ~]$ oc new-project schedule-is

 

6.4 創建應用

  1 [student@workstation ~]$ oc new-app --name=phpmyadmin \
  2 --docker-image=registry.lab.example.com/phpmyadmin/phpmyadmin:4.7

 

6.5 創建服務賬戶

  1 [student@workstation ~]$ oc login -u admin -p redhat
  2 [student@workstation ~]$ oc project schedule-is
  3 [student@workstation ~]$ oc create serviceaccount phpmyadmin-account

 

6.6 授權特權運行

  1 [student@workstation ~]$ oc adm policy add-scc-to-user anyuid \
  2 -z phpmyadmin-account

 

6.7 更新pod

  1 [student@workstation ~]$ oc login -u developer
  2 [student@workstation ~]$ oc patch dc/phpmyadmin --patch \
  3 '{"spec":{"template":{"spec":{"serviceAccountName": "phpmyadmin-account"}}}}'

 
更新負責管理phpmyadmin部署的dc資源,以便使用新創建的服務帳戶。可以使用oc patch或oc edit命令。此命令可以從/home/student/DO280/labs/secure-review文件夾中的patch-dc.sh腳本中複製。

  1 [student@workstation ~]$ oc get pods		#確認驗證
  2 NAME                 READY     STATUS    RESTARTS   AGE
  3 phpmyadmin-2-vh29z   1/1       Running   0          3m

 
提示:name后的2表示這個pod是第二次部署,即進行過迭代。

6.8 更新內部倉庫image

  1 [student@workstation ~]$ cd /home/student/DO280/labs/schedule-is/
  2 [student@workstation schedule-is]$ ls
  3 phpmyadmin-latest.tar  trust_internal_registry.sh
  4 [student@workstation schedule-is]$ docker load -i phpmyadmin-latest.tar
  5 #使用docker load命令加載新的image。
  6 [student@workstation schedule-is]$ docker images
  7 REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
  8 <none>              <none>              93d0d7db5ce2        13 months ago       166 MB

 

6.9 tag鏡像

  1 [student@workstation schedule-is]$ docker tag 93d0d7db5ce2 \
  2 docker-registry-default.apps.lab.example.com/schedule-is/phpmyadmin:4.7
  3 #打完標記進行推送。

 

6.10 登錄docker倉庫


結論:docker倉庫會提示因為是自簽名證書,因此判定為不安全的方式。

6.11 修改信任

本環境使用/home/student/DO280/labs/secure-review文件夾中的trust_internal_registry.sh腳本,配置docker倉庫信任OpenShift內部倉庫。

  1 [student@workstation schedule-is]$ ./trust_internal_registry.sh

6.12 推送image

  1 [student@workstation schedule-is]$ docker push \
  2 docker-registry-default.apps.lab.example.com/schedule-is/phpmyadmin:4.7

 

6.13 確認更新

驗證當源image更新后,是否能自動觸發OpenShift進行pod更新。

  1 [student@workstation schedule-is]$ oc get pods
  2 NAME                 READY     STATUS    RESTARTS   AGE
  3 phpmyadmin-3-hnfjk   1/1       Running   0          23s

 

七 管理應用部署實驗

7.1 前置準備

準備完整的OpenShift集群,參考《003.OpenShift網絡》2.1。

7.2 本練習準備

  1 [student@workstation ~]$ lab manage-review setup

7.3 確認region

  1 [student@workstation ~]$ oc login -uadmin -predhat https://master.lab.example.com
  2 [student@workstation ~]$ oc get nodes -L region
  3 NAME                     STATUS    ROLES     AGE       VERSION             REGION
  4 master.lab.example.com   Ready     master    2d        v1.9.1+a0ce1bc657
  5 node1.lab.example.com    Ready     compute   2d        v1.9.1+a0ce1bc657   infra
  6 node2.lab.example.com    Ready     compute   2d        v1.9.1+a0ce1bc657   infra

 

7.4 修改region

  1 [student@workstation ~]$ oc label node node1.lab.example.com region=services --overwrite=true
  2 [student@workstation ~]$ oc label node node2.lab.example.com region=applications --overwrite=true
  3 [student@workstation ~]$ oc get nodes -L region
  4 NAME                     STATUS    ROLES     AGE       VERSION             REGION
  5 master.lab.example.com   Ready     master    2d        v1.9.1+a0ce1bc657
  6 node1.lab.example.com    Ready     compute   2d        v1.9.1+a0ce1bc657   services
  7 node2.lab.example.com    Ready     compute   2d        v1.9.1+a0ce1bc657   applications

 

7.5 創建項目

  1 [student@workstation ~]$ oc new-project manage-review

7.6 創建應用

  1 [student@workstation ~]$ oc new-app -i php:7.0 \
  2 http://registry.lab.example.com/version

 

7.7 擴展應用

  1 [student@workstation ~]$ oc scale dc version --replicas=3
  2 [student@workstation ~]$ oc get pods -o wide		#確認驗證
  3 NAME              READY     STATUS      RESTARTS   AGE       IP            NODE
  4 version-1-9626w   1/1       Running     0          40s       10.129.0.55   node2.lab.example.com
  5 version-1-build   0/1       Completed   0          1m        10.129.0.52   node2.lab.example.com
  6 version-1-f6vj2   1/1       Running     0          40s       10.129.0.56   node2.lab.example.com
  7 version-1-mrhk4   1/1       Running     0          45s       10.129.0.54   node2.lab.example.com

 
結論:應用程序pod並沒有均分在兩個集群node節點之間,因為每個節點屬於不同的region,並且默認的OpenShift調度器配置打開了區域粘性。

7.8 調度pod

  1 [student@workstation ~]$ oc export dc version -o yaml > version-dc.yml	#導出yaml
  2 spac
  3 ……
  4   template:
  5     metadata:
  6 ……
  7     spec:
  8       nodeSelector:		#添加節點選擇器
  9         region: applications
 10 ……

 

7.9 迭代部署

  1 [student@workstation ~]$ oc replace -f version-dc.yml	#迭代

7.10 確認驗證

  1 [student@workstation ~]$ oc get pod -o wide
  2 NAME              READY     STATUS      RESTARTS   AGE       IP            NODE
  3 version-1-build   0/1       Completed   0          15m       10.129.0.52   node2.lab.example.com
  4 version-2-2bmqq   1/1       Running     0          58s       10.129.0.60   node2.lab.example.com
  5 version-2-nz58r   1/1       Running     0          1m        10.129.0.59   node2.lab.example.com
  6 version-2-rlj2h   1/1       Running     0          1m        10.129.0.58   node2.lab.example.com

 
驗證是否啟動了新的部署,並且在node2節點上運行了一組新的版本莢。等待所有三個新的應用程序莢都準備好並運行

7.11 修改region

  1 [student@workstation ~]$ oc label node node1.lab.example.com region=applications --overwrite=true
  2 [student@workstation ~]$ oc get nodes -L region		#確認驗證
  3 NAME                     STATUS    ROLES     AGE       VERSION             REGION
  4 master.lab.example.com   Ready     master    2d        v1.9.1+a0ce1bc657
  5 node1.lab.example.com    Ready     compute   2d        v1.9.1+a0ce1bc657   applications
  6 node2.lab.example.com    Ready     compute   2d        v1.9.1+a0ce1bc657   applications

 

7.12 終止node2

  1 [student@workstation ~]$ oc adm manage-node --schedulable=false node2.lab.example.com
  2 NAME                    STATUS                     ROLES     AGE       VERSION
  3 node2.lab.example.com   Ready,SchedulingDisabled   compute   2d        v1.9.1+a0ce1bc657

 

7.13 刪除pod

刪除node2的pod,並使用node1創建的pod替換。

  1 [student@workstation ~]$ oc adm drain node2.lab.example.com --delete-local-data

7.14 查看pod

  1 [student@workstation ~]$ oc get pods -o wide
  2 NAME              READY     STATUS    RESTARTS   AGE       IP            NODE
  3 version-2-d9fhp   1/1       Running   0          3m        10.128.0.34   node1.lab.example.com
  4 version-2-jp5gr   1/1       Running   0          3m        10.128.0.35   node1.lab.example.com
  5 version-2-z5lv5   1/1       Running   0          3m        10.128.0.33   node1.lab.example.com

 

7.15 暴露服務

  1 [student@workstation ~]$ oc expose service version --hostname=version.apps.lab.example.com
  2 [student@workstation ~]$ curl http://version.apps.lab.example.com	#確認測試
  3 <html>
  4  <head>
  5   <title>PHP Test</title>
  6  </head>
  7  <body>
  8  <p>Version v1</p>
  9  </body>
 10 </html>

 

7.16 確認驗證

  1 [student@workstation ~]$ lab manage-review grade	#環境腳本判斷

7.17 還原環境

  1 [student@workstation ~]$ oc adm manage-node --schedulable=true node2.lab.example.com
  2 [student@workstation ~]$ oc label node node1.lab.example.com region=infra --overwrite=true
  3 [student@workstation ~]$ oc label node node2.lab.example.com region=infra --overwrite=true
  4 [student@workstation ~]$ oc get node -L region
  5 NAME                     STATUS    ROLES     AGE       VERSION             REGION
  6 master.lab.example.com   Ready     master    2d        v1.9.1+a0ce1bc657
  7 node1.lab.example.com    Ready     compute   2d        v1.9.1+a0ce1bc657   infra
  8 node2.lab.example.com    Ready     compute   2d        v1.9.1+a0ce1bc657   infra
  9 [student@workstation ~]$ oc delete project manage-review

  本站聲明:網站內容來源於博客園,如有侵權,請聯繫我們,我們將及時處理

【其他文章推薦】

※帶您來了解什麼是 USB CONNECTOR  ?

※自行創業缺乏曝光? 網頁設計幫您第一時間規劃公司的形象門面

※如何讓商品強力曝光呢? 網頁設計公司幫您建置最吸引人的網站,提高曝光率!

※綠能、環保無空污,成為電動車最新代名詞,目前市場使用率逐漸普及化

※廣告預算用在刀口上,台北網頁設計公司幫您達到更多曝光效益

※教你寫出一流的銷售文案?